I'm working on a chart widget for Fyne, I use rasterx
package (https://github.com/srwiley/rasterx) and it works well. But I spent hours to try to make a circle arc (to create a pie chart elements) without success.
Let's take this starting point:
cx, cy := float64(w/2.0), float64(h/2.0)
r := float64(w / 3.0)
angle := 45.0
rot := angle * math.Pi / 180.0
I take the AddArc
function at https://github.com/srwiley/rasterx/blob/master/shapes.go#L99 to understand the principle and do:
points := []float64{r, r, angle, 1, 0, px, py}
stroker.Start(rasterx.ToFixedP(px, py))
rasterx.AddArc(points, cx, cy, px, py, stroker)
stroker.Stop(false)
stroker.Draw()
The result is a circle, not an arc.
As the rasterx
package is based on SVG 2.0 spec, maybe I miss something. Can you please give me a hand to show me how to create a "pie chart element" for a given angle?
Thanks a lot.
PS: I should not use other package than rasterx
, please do not tell me to use another one.
px
andpy
are, but I suspect that having the same value in thepoints
as passed in toAddArc
may relate - that is what they do in theAddEllipse
function, which is desiring a completed 360degs