https://github.com/bodoni/curve
Toolbox for Bézier curves
https://github.com/bodoni/curve
Last synced: 10 months ago
JSON representation
Toolbox for Bézier curves
- Host: GitHub
- URL: https://github.com/bodoni/curve
- Owner: bodoni
- License: other
- Created: 2015-08-30T05:57:06.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2025-01-19T10:53:22.000Z (over 1 year ago)
- Last Synced: 2025-07-14T11:51:35.125Z (11 months ago)
- Language: Rust
- Homepage:
- Size: 89.8 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Curve [![Package][package-img]][package-url] [![Documentation][documentation-img]][documentation-url] [![Build][build-img]][build-url]
The package provides curves.
## Examples
Trace a Bézier curve:
```rust
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::>();
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:
```rust
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::>();
assert_eq!(quadratics.len(), 4);
```
## Contribution
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](LICENSE.md).
[build-img]: https://github.com/bodoni/curve/workflows/build/badge.svg
[build-url]: https://github.com/bodoni/curve/actions/workflows/build.yml
[documentation-img]: https://docs.rs/curve/badge.svg
[documentation-url]: https://docs.rs/curve
[package-img]: https://img.shields.io/crates/v/curve.svg
[package-url]: https://crates.io/crates/curve