Crate splines [−] [src]
splines
To construct a BezierCurve
you should use BezierCurveBuilder
.
Using splines
For a Bezier curve with a certain degree
you need degree+1
control vertices (CVs).
extern crate splines; extern crate nalgebra as na; use na::Vec4; fn main() { // degree 2 curve (needs 3 CVs) let pt1 = Vec4::new(0.0, 0.0, 0.0, 1.0); // 0 0 let pt2 = Vec4::new(1.0, 1.0, 0.0, 1.0); // 1 1 let pt3 = Vec4::new(2.0, 0.0, 0.0, 1.0); // 2 0 let curve = splines::BezierCurveBuilder::new() .add_cv(pt1) .add_cv(pt2) .add_cv(pt3) .finalize(); println!("{:?}", curve); // degree 3 curve (needs 4 CVs) let pt1 = Vec4::new(0.0, 0.0, 0.0, 1.0); // 0 0 let pt2 = Vec4::new(0.0, 1.0, 0.0, 1.0); // 0 1 let pt3 = Vec4::new(1.0, 1.0, 0.0, 1.0); // 1 1 let pt4 = Vec4::new(1.0, 0.0, 0.0, 1.0); // 1 0 let curve = splines::BezierCurveBuilder::new() .add_cv(pt1) .add_cv(pt2) .add_cv(pt3) .add_cv(pt4) .finalize(); println!("{:?}", curve); }
Structs
BezierCurve | |
BezierCurveBuilder |
Helper to construct a BezierCurve. |