2016-11-20 13:31:05 +01:00
|
|
|
package main
|
|
|
|
|
2016-11-21 07:57:15 +01:00
|
|
|
import "github.com/fogleman/gg"
|
2016-11-20 13:31:05 +01:00
|
|
|
|
|
|
|
func main() {
|
2019-02-20 23:12:06 +01:00
|
|
|
im, err := gg.LoadPNG("examples/baboon.png")
|
2016-11-20 13:31:05 +01:00
|
|
|
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")
|
|
|
|
}
|