Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 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)
|
||||
}
|
||||
29
Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-2.go
Normal file
29
Task/Bitmap-Flood-fill/Go/bitmap-flood-fill-2.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/exec"
|
||||
"raster"
|
||||
)
|
||||
|
||||
func main() {
|
||||
b, err := raster.ReadPpmFile("Unfilledcirc.ppm")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
b.Flood(200, 200, raster.Pixel{127, 0, 0})
|
||||
c := exec.Command("convert", "ppm:-", "flood.png")
|
||||
pipe, err := c.StdinPipe()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err = c.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err = b.WritePpmTo(pipe); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err = pipe.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue