// Uses half-sample symmetry. func Symmetric(im image.Image, p image.Point) color.Color { b := im.Bounds() // Make twice as big. d := image.Rectangle{b.Min, b.Max.Add(b.Size())} p = p.Mod(d) // Move to origin. p = p.Sub(b.Min) w, h := b.Dx(), b.Dy() if p.X > w-1 { p.X = 2*w - 1 - p.X } if p.Y > h-1 { p.Y = 2*h - 1 - p.Y } p = p.Add(b.Min) return im.At(p.X, p.Y) }
func Periodic(im image.Image, p image.Point) color.Color { p = p.Mod(im.Bounds()) return im.At(p.X, p.Y) }