diff options
author | Nigel Tao <nigeltao@golang.org> | 2010-10-13 12:05:21 +1100 |
---|---|---|
committer | Nigel Tao <nigeltao@golang.org> | 2010-10-13 12:05:21 +1100 |
commit | fb9be1c5383e7ba286f4b00084601550b2207aad (patch) | |
tree | aab80fdc721d1a444541833ed840cedb24c91ebb /src/pkg/image/geom.go | |
parent | 0e45f1b92999818163b5671cd449acfc43a09c7e (diff) | |
download | go-fb9be1c5383e7ba286f4b00084601550b2207aad.tar.gz |
image: add an offset to Tiled.
R=r, r2
CC=golang-dev
http://codereview.appspot.com/2469041
Diffstat (limited to 'src/pkg/image/geom.go')
-rw-r--r-- | src/pkg/image/geom.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/pkg/image/geom.go b/src/pkg/image/geom.go index 5a7b0b8a8..ccfe9cdb0 100644 --- a/src/pkg/image/geom.go +++ b/src/pkg/image/geom.go @@ -43,15 +43,13 @@ func (p Point) Div(k int) Point { func (p Point) Mod(r Rectangle) Point { w, h := r.Dx(), r.Dy() p = p.Sub(r.Min) - if p.X >= 0 { - p.X = p.X % w - } else { - p.X = w - 1 - (-1-p.X)%w + p.X = p.X % w + if p.X < 0 { + p.X += w } - if p.Y >= 0 { - p.Y = p.Y % h - } else { - p.Y = h - 1 - (-1-p.Y)%h + p.Y = p.Y % h + if p.Y < 0 { + p.Y += h } return p.Add(r.Min) } |