Crates.io | curve |
lib.rs | curve |
version | 0.11.0 |
created_at | 2015-08-30 06:00:13.597391+00 |
updated_at | 2025-01-19 10:53:47.883439+00 |
description | The package provides curves. |
homepage | https://github.com/bodoni/curve |
repository | https://github.com/bodoni/curve |
max_upload_size | |
id | 2961 |
size | 25,994 |
The package provides curves.
Trace a Bézier curve:
use curve::bezier::Linear;
use curve::Trace;
let curve = (Linear::new(1.0, 5.0), Linear::new(2.0, 3.0));
let points = Trace::new(curve, 3).collect::<Vec<_>>();
assert_eq!(points, vec![(1.0, 2.0), (3.0, 2.5), (5.0, 3.0)]);
Approximate a cubic Bézier curve with a sequence of quadratic:
use curve::bezier::goodness::CrudeIndependentAbsolute;
use curve::bezier::Cubic;
use curve::Approximation;
let goodness = CrudeIndependentAbsolute::new(1.0, f64::MAX, usize::MAX);
let cubic = (Cubic::new(0.0, 0.0, 90.0, 100.0), Cubic::new(0.0, 50.0, 0.0, 0.0));
let quadratics = Approximation::new(cubic, goodness).collect::<Vec<_>>();
assert_eq!(quadratics.len(), 4);
Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.md.