aboutsummaryrefslogtreecommitdiff
path: root/units.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-09-24 03:44:16 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-09-24 03:44:16 +0200
commit09067cfbedb18de674595c56425953afd493c57c (patch)
tree3e4d5ae3cafd3b22a2d4879623926dfab12a2a83 /units.go
parent2931ed698a28544ad1510c2fb5d1cb2b4be4ef6e (diff)
resort definitions
Diffstat (limited to 'units.go')
-rw-r--r--units.go47
1 files changed, 45 insertions, 2 deletions
diff --git a/units.go b/units.go
index 7939c65..1acd3e1 100644
--- a/units.go
+++ b/units.go
@@ -31,12 +31,19 @@ func parseUnit(s string) (u Unit) {
return
}
+type Orientation int
+
+const (
+ Portrait Orientation = iota
+ Landscape
+)
+
+var orientation = Portrait
+
type Point struct {
X, Y Unit
}
-var orientation = Portrait
-
func (p Point) String() (s string) {
switch orientation {
case Portrait:
@@ -47,6 +54,10 @@ func (p Point) String() (s string) {
return
}
+func (p Point) Scale(f Unit) Point {
+ return Point{p.X * f, p.Y * f}
+}
+
func parsePoint(s string) (p Point) {
fmt.Sscanf(s, "%v,%v", &p.X, &p.Y)
return
@@ -74,3 +85,35 @@ func (p Path) String() string {
}
return strings.Join(pp, ",")
}
+
+func (ph Path) Scale(f Unit) Path {
+ ret := make(Path, len(ph))
+ for i, p := range ph {
+ ret[i] = p.Scale(f)
+ }
+ return ret
+}
+
+type LineStyle int
+
+const (
+ Solid LineStyle = iota
+ Dots
+ ShortDash
+ Dash
+ LongDash
+ DashDot
+ DashLongDot
+ DashDoubleDot
+ DashLongDoubleDot
+)
+
+type Direction byte
+
+const (
+ Stop Direction = 1 << iota >> 1
+ Down
+ Up
+ Right
+ Left
+)