nannou icon indicating copy to clipboard operation
nannou copied to clipboard

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

Open andrew-goldie opened this issue 1 year ago • 0 comments

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();

andrew-goldie avatar Aug 09 '23 10:08 andrew-goldie