Skip to content

Please explain the AddArc parameters, e.g. to make a "pie part" #13

@metal3d

Description

@metal3d

Hi,
I spent hours making tests and trying to understand the parameters, and the "points" content and I didn't find my way to make a "pie part". Whatever I do, the path becomes a circle.

Using this

	cx, cy := float64(w/2.0), float64(h/2.0)
	r := float64(w / 3.0)
	angle := 45.0
	rot := angle * math.Pi / 180.0

	// find the point on circle of radius r at angle rot
	px := cx + r*math.Cos(rot)
	py := cy + r*math.Sin(rot)

	points := []float64{r, r, angle, 1, 0, px, py}

	stroker.Start(rasterx.ToFixedP(cx, cy))
	//stroker.Line(rasterx.ToFixedP(cx, cy+r))
	stroker.Start(rasterx.ToFixedP(px, py))
	rasterx.AddArc(points, cx, cy, px, py, stroker)
	//stroker.Stop(false)
	//stroker.Line(rasterx.ToFixedP(cx, cy))
	stroker.Stop(false)
	stroker.Draw()

out

With this:

	stroker.Start(rasterx.ToFixedP(cx, cy))
	stroker.Line(rasterx.ToFixedP(cx, cy+r))
	stroker.Start(rasterx.ToFixedP(px, py))
	rasterx.AddArc(points, cx, cy, px, py, stroker)
	stroker.Line(rasterx.ToFixedP(cx, cy))
	stroker.Stop(false)
	stroker.Draw()

out

I made several other tests to start the path somewhere else, with no idea of how to make a "pie chart element".

This is the wanted shape:
image

The goal is to make a pie chart (of course :) ) but (sorry to say this) the code is not well documented... Can you please give a simple example of a pie chart element?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions