diff --git a/examples/star.go b/examples/star.go index cbc29f6..f874e4d 100644 --- a/examples/star.go +++ b/examples/star.go @@ -20,20 +20,21 @@ func Polygon(n int, x, y, r float64) []Point { } func main() { - points := Polygon(5, 512, 512, 400) - indexes := []int{0, 2, 4, 1, 3, 0} + n := 5 + points := Polygon(n, 512, 512, 400) dc := dd.NewContext(1024, 1024) dc.SetSourceRGB(1, 1, 1) dc.Paint() - for _, index := range indexes { + for i := 0; i < n+1; i++ { + index := (i * 2) % n p := points[index] 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.FillPreserve() - dc.SetSourceRGB(0, 0, 0) - dc.SetLineWidth(8) + dc.SetSourceRGBA(0, 1, 0, 0.5) + dc.SetLineWidth(16) dc.Stroke() dc.WriteToPNG("out.png") }