From 09067cfbedb18de674595c56425953afd493c57c Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 24 Sep 2016 03:44:16 +0200 Subject: resort definitions --- units.go | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'units.go') 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 +) -- cgit v1.2.3