updated example

This commit is contained in:
Michael Fogleman 2016-02-18 21:34:57 -05:00
parent dd5567cfb4
commit d2a761c38b

View File

@ -20,20 +20,21 @@ func Polygon(n int, x, y, r float64) []Point {
} }
func main() { func main() {
points := Polygon(5, 512, 512, 400) n := 5
indexes := []int{0, 2, 4, 1, 3, 0} points := Polygon(n, 512, 512, 400)
dc := dd.NewContext(1024, 1024) dc := dd.NewContext(1024, 1024)
dc.SetSourceRGB(1, 1, 1) dc.SetSourceRGB(1, 1, 1)
dc.Paint() dc.Paint()
for _, index := range indexes { for i := 0; i < n+1; i++ {
index := (i * 2) % n
p := points[index] p := points[index]
dc.LineTo(p.X, p.Y) dc.LineTo(p.X, p.Y)
} }
dc.SetSourceRGBA(1, 0, 0, 0.5) dc.SetSourceRGBA(0, 0.5, 0, 1)
dc.SetFillRule(dd.FillRuleEvenOdd) dc.SetFillRule(dd.FillRuleEvenOdd)
dc.FillPreserve() dc.FillPreserve()
dc.SetSourceRGB(0, 0, 0) dc.SetSourceRGBA(0, 1, 0, 0.5)
dc.SetLineWidth(8) dc.SetLineWidth(16)
dc.Stroke() dc.Stroke()
dc.WriteToPNG("out.png") dc.WriteToPNG("out.png")
} }