forked from gographics/imagick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (31 loc) · 945 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Port of http://members.shaw.ca/el.supremo/MagickWand/floodfill.htm to Go
package main
import (
"os"
"gopkg.in/gographics/imagick.v3/imagick"
)
func main() {
imagick.Initialize()
defer imagick.Terminate()
var err error
mw := imagick.NewMagickWand()
// fillcolor and bordercolor
fc, bc := imagick.NewPixelWand(), imagick.NewPixelWand()
fc.SetColor("none")
bc.SetColor("white")
err = mw.ReadImage("logo:")
if err != nil {
panic(err)
}
rgba := imagick.CHANNELS_RGB | imagick.CHANNEL_ALPHA
// The bordercolor (with fuzz of 20 applied) is replaced by the fill
// colour starting at the given coordinate - in this case 0, 0.
// Normally the last argument is false so that the colours are matched
// but if it is true then it floodfills any pixel that does *not* match
// the target color
mw.FloodfillPaintImage(rgba, fc, 20, bc, 0, 0, false)
mw.DisplayImage(os.Getenv("DISPLAY"))
if err != nil {
panic(err)
}
}