1 // Copyright ©2015 The Gonum Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package vg 6 7 import "gonum.org/v1/plot/font" 8 9 // A Length is a unit-independent representation of length. 10 // Internally, the length is stored in postscript points. 11 type Length = font.Length 12 13 // Points returns a length for the given number of points. 14 func Points(pt float64) Length { 15 return font.Points(pt) 16 } 17 18 // Common lengths. 19 const ( 20 Inch = font.Inch 21 Centimeter = font.Centimeter 22 Millimeter = font.Millimeter 23 ) 24 25 // ParseLength parses a Length string. 26 // A Length string is a possible signed floating number with a unit. 27 // e.g. "42cm" "2.4in" "66pt" 28 // If no unit was given, ParseLength assumes it was (postscript) points. 29 // Currently valid units are: 30 // 31 // - mm (millimeter) 32 // - cm (centimeter) 33 // - in (inch) 34 // - pt (point) 35 func ParseLength(value string) (Length, error) { 36 return font.ParseLength(value) 37 } 38