Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
metal3d opened this issue May 31, 2022 · 0 comments
Open

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

metal3d opened this issue May 31, 2022 · 0 comments

Comments

@metal3d
Copy link

metal3d commented May 31, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant