B
This commit is contained in:
parent
e5e8880e41
commit
518da4a923
1019 changed files with 15877 additions and 0 deletions
17
Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-1.go
Normal file
17
Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-1.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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)
|
||||
}
|
||||
20
Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-2.go
Normal file
20
Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-2.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"raster"
|
||||
)
|
||||
|
||||
func main() {
|
||||
b, err := raster.ReadPpmFile("Unfilledcirc.ppm")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
b.Flood(200, 200, raster.Pixel{127, 0, 0})
|
||||
err = b.WritePpmFile("flood.ppm")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue