diff options
Diffstat (limited to 'src/pkg/image/names.go')
-rw-r--r-- | src/pkg/image/names.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/pkg/image/names.go b/src/pkg/image/names.go index 6900ec923..c309684ce 100644 --- a/src/pkg/image/names.go +++ b/src/pkg/image/names.go @@ -15,7 +15,7 @@ var ( Opaque = NewColorImage(Alpha16Color{0xffff}) ) -// A ColorImage is a practically infinite-sized Image of uniform Color. +// A ColorImage is an infinite-sized Image of uniform Color. // It implements both the Color and Image interfaces. type ColorImage struct { C Color @@ -43,11 +43,12 @@ func NewColorImage(c Color) *ColorImage { return &ColorImage{c} } -// A Tiled is a practically infinite-sized Image that repeats another Image in -// both directions. Tiled{i}.At(x, y) will equal i.At(x, y) for all points -// within i's Bounds. +// A Tiled is an infinite-sized Image that repeats another Image in both +// directions. Tiled{i, p}.At(x, y) will equal i.At(x+p.X, y+p.Y) for all +// points {x+p.X, y+p.Y} within i's Bounds. type Tiled struct { - I Image + I Image + Offset Point } func (t *Tiled) ColorModel() ColorModel { @@ -57,10 +58,10 @@ func (t *Tiled) ColorModel() ColorModel { func (t *Tiled) Bounds() Rectangle { return Rectangle{Point{-1e9, -1e9}, Point{1e9, 1e9}} } func (t *Tiled) At(x, y int) Color { - p := Point{x, y}.Mod(t.I.Bounds()) + p := Point{x, y}.Add(t.Offset).Mod(t.I.Bounds()) return t.I.At(p.X, p.Y) } -func NewTiled(i Image) *Tiled { - return &Tiled{i} +func NewTiled(i Image, offset Point) *Tiled { + return &Tiled{i, offset} } |