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

vg,vg/draw: primitives for an Ellipse #641

Open
sbinet opened this issue Oct 26, 2020 · 1 comment
Open

vg,vg/draw: primitives for an Ellipse #641

sbinet opened this issue Oct 26, 2020 · 1 comment

Comments

@sbinet
Copy link
Member

sbinet commented Oct 26, 2020

unless I am mistaken, gonum/plot doesn't expose primitives to draw ellipses nor arcs of ellipses.
vg.Path exposes a vg.ArcComp but that's only to draw a circular arc.

one can of course draw an ellipse with a combination of vg.CurveComp (quad or cubic ones), according to that paper:
Drawing an elliptical arc using polylines, quadratic or cubic Bezier curves", L. Maisonobe

An electronic version may be found at:

I've already provided such an implementation for Gio.
I could probably provide one for gonum/plot as well.

I'd propose to put it into vg/draw:

package draw

// EArc adds an elliptical arc to the path. The implied ellipse is defined
// by its focus points f1 and f2.
// The arc starts in the current point and ends angle radians along the ellipse boundary.
// The sign of angle determines the direction; positive being counter-clockwise,
// negative clockwise.
// If path is nil, a new path is created.
func EArc(path *vg.Path, f1, f2 vg.Point, angle float64) { ... }

WDYT?

@sbinet
Copy link
Member Author

sbinet commented Oct 26, 2020

note that we could also provide other readily usable primitives:

  • Circle (a full circle)
  • Ellipse (a full ellipse)
  • Triangle
  • Square, Rectangle
  • Polygon

filled or stroked.

some of these primitives could probably already be re-used by a few plot/plotter.

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