aboutsummaryrefslogtreecommitdiff
path: root/units.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-11-14 00:42:23 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-11-14 00:42:23 +0100
commit05af31880498bf60316b85415f9d4c1dfa0d1577 (patch)
treee7040c967ee8e98ae67c3c89ab9bf6d9d5acb5f8 /units.go
parent360abb4272dea659de237b1c58d46acc1746ffa7 (diff)
wip
Diffstat (limited to 'units.go')
-rw-r--r--units.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/units.go b/units.go
index 1acd3e1..03026bb 100644
--- a/units.go
+++ b/units.go
@@ -44,14 +44,15 @@ type Point struct {
X, Y Unit
}
+func (p Point) Swap() Point { return Point{X: p.Y, Y: p.X} }
+
func (p Point) String() (s string) {
switch orientation {
case Portrait:
- s = fmt.Sprintf("%v,%v", p.X, p.Y)
case Landscape:
- s = fmt.Sprintf("%v,%v", p.Y, p.X)
+ p = p.Swap()
}
- return
+ return fmt.Sprintf("%v,%v", p.X, p.Y)
}
func (p Point) Scale(f Unit) Point {
@@ -86,10 +87,10 @@ 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)
+func (p Path) Scale(f Unit) Path {
+ ret := make(Path, len(p))
+ for i, pt := range p {
+ ret[i] = pt.Scale(f)
}
return ret
}