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