gg/examples/pattern-fill.go

21 lines
381 B
Go
Raw Normal View History

package main
2016-11-21 07:57:15 +01:00
import "github.com/fogleman/gg"
func main() {
2019-02-20 23:12:06 +01:00
im, err := gg.LoadPNG("examples/baboon.png")
if err != nil {
panic(err)
}
pattern := gg.NewSurfacePattern(im, gg.RepeatBoth)
dc := gg.NewContext(600, 600)
dc.MoveTo(20, 20)
dc.LineTo(590, 20)
dc.LineTo(590, 590)
dc.LineTo(20, 590)
dc.ClosePath()
dc.SetFillStyle(pattern)
dc.Fill()
dc.SavePNG("out.png")
}