Added Shift method
This commit is contained in:
parent
13548be874
commit
7ce029ea08
1 changed files with 11 additions and 0 deletions
11
path.go
11
path.go
|
@ -160,6 +160,17 @@ func (p *Path) IsEmpty() bool {
|
||||||
return len(p.Components) == 0
|
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
|
// String returns a debug text view of the path
|
||||||
func (p *Path) String() string {
|
func (p *Path) String() string {
|
||||||
s := ""
|
s := ""
|
||||||
|
|
Loading…
Reference in a new issue