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

Drawing a path with nannou::geom::path should expose lyon's end() method on builder #933

Open
andrew-goldie opened this issue Aug 9, 2023 · 0 comments

Comments

@andrew-goldie
Copy link

andrew-goldie commented Aug 9, 2023

Drawing a non-closed (open?) curve requires lower-level use of lyon crate just to get to the end(false) method.

use nannou::{prelude::*, lyon::{geom::euclid::Point2D, path::Path}};

let mut b = lyon::path::Path::builder();
b.begin(Point2D::new(0.0, 0.0));
b.quadratic_bezier_to(Point2D::new(50.0, 0.0), Point2D::new(100.0, 100.0));
b.end(false);
let p = b.build();
draw.path().stroke().hsva(0.0, 0.0, 1.0, 1.0).stroke_weight(self.stroke_weight).events(p.iter());

Using the convenient nannou wrapper, I can only get a closed curve (leaving the close() function out and attempting to call build() causes a panic since the set of points is considered invalid by lyon):

use nannou::{prelude::*, geom::path};

// panics
let p = path().begin(pt2(0.0, 0.0)).quadratic_bezier_to(pt2(50.0, 0), pt2(100.0, 100.0)).build();

// does not panic but produces closed curve
let p = path().begin(pt2(0.0, 0.0)).quadratic_bezier_to(pt2(50.0, 0), pt2(100.0, 100.0)).close().build();

// suggested feature request
let p = path().begin(pt2(0.0, 0.0)).quadratic_bezier_to(pt2(50.0, 0), pt2(100.0, 100.0)).end(false).build();
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

Successfully merging a pull request may close this issue.

1 participant