gg/examples/ellipse.go

21 lines
431 B
Go
Raw Normal View History

2016-02-19 19:16:40 +01:00
package main
import "github.com/fogleman/gg"
func main() {
const S = 1024
dc := gg.NewContext(S, S)
2016-02-19 19:34:04 +01:00
dc.SetRGBA(0, 0, 0, 0.1)
2016-02-19 19:16:40 +01:00
for i := 0; i < 360; i += 15 {
2016-02-19 19:34:04 +01:00
dc.Push()
2016-02-19 19:16:40 +01:00
dc.RotateAbout(gg.Radians(float64(i)), S/2, S/2)
dc.DrawEllipse(S/2, S/2, S*7/16, S/8)
dc.Fill()
2016-02-19 19:34:04 +01:00
dc.Pop()
2016-02-19 19:16:40 +01:00
}
2016-02-25 21:06:04 +01:00
if im, err := gg.LoadImage("examples/gopher.png"); err == nil {
2016-02-20 03:35:56 +01:00
dc.DrawImageAnchored(im, S/2, S/2, 0.5, 0.5)
2016-02-20 01:45:57 +01:00
}
2016-02-19 19:54:55 +01:00
dc.SavePNG("out.png")
2016-02-19 19:16:40 +01:00
}