From 7ce029ea0834151bb89116c420fe3ff007cdb6fe Mon Sep 17 00:00:00 2001 From: redstarcoder Date: Sat, 15 Oct 2016 11:19:58 -0400 Subject: [PATCH] Added Shift method --- path.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/path.go b/path.go index 57ba3ff..0de1bcb 100644 --- a/path.go +++ b/path.go @@ -160,6 +160,17 @@ func (p *Path) IsEmpty() bool { return len(p.Components) == 0 } +// Shift moves every point in the path by x and y. +func (p *Path) Shift(x, y float64) { + if len(p.Points) % 2 != 0 { + panic("Invalid Path (odd number of points)") + } + for i := 0;i < len(p.Points);i += 2 { + p.Points[i] += x + p.Points[i+1] += y + } +} + // String returns a debug text view of the path func (p *Path) String() string { s := ""