| Crates.io | simple-bezier-easing |
| lib.rs | simple-bezier-easing |
| version | 0.1.1 |
| created_at | 2024-12-04 22:22:17.728446+00 |
| updated_at | 2024-12-14 22:53:47.519592+00 |
| description | A library for calculating cubic Bézier curves using De Casteljau's algorithm. |
| homepage | https://github.com/0xJWLabs/simple-bezier-easing |
| repository | https://github.com/0xJWLabs/simple-bezier-easing |
| max_upload_size | |
| id | 1472592 |
| size | 19,011 |
A Rust library for calculating cubic Bézier curves using De Casteljau's algorithm, with error handling and binary subdivision support for finding curve parameters. This library is ideal for applications like animations, easing functions, and graphics rendering.
x values with high precision.To add this library to your project, include it in your Cargo.toml file:
[dependencies]
simple-bezier-easing = "0.1.0"
use simple_bezier_easing::bezier;
fn main() {
// Define a Bézier curve with control points
let bez = bezier(0.2, 0.4, 0.6, 0.8).unwrap();
// Calculate the y-coordinate for x = 0.5
let y_at_0_5 = bez(0.5).unwrap();
println!("y at x = 0.5: {}", y_at_0_5);
}
The library returns an error for invalid control points, for example:
let invalid_bez = bezier(1.2, 0.4, 0.6, 0.8); // Invalid control point
assert!(invalid_bez.is_err(), "Expected error for invalid control points");
This project is licensed under the MIT License. See the LICENSE file for more details.