RosettaCodeData/Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-1.go
Ingy döt Net 518da4a923 B
2013-04-10 16:19:29 -07:00

17 lines
397 B
Go

package raster
func (b *Bitmap) Flood(x, y int, repl Pixel) {
targ, _ := b.GetPx(x, y)
var ff func(x, y int)
ff = func(x, y int) {
p, ok := b.GetPx(x, y)
if ok && p.R == targ.R && p.G == targ.G && p.B == targ.B {
b.SetPx(x, y, repl)
ff(x-1, y)
ff(x+1, y)
ff(x, y-1)
ff(x, y+1)
}
}
ff(x, y)
}