5 releases (breaking)

0.7.0 Oct 16, 2024
0.5.0 Feb 13, 2023
0.4.0 Dec 4, 2022
0.2.0 Oct 25, 2022
0.1.0 Aug 3, 2022

#242 in Graphics APIs

Download history 60/week @ 2024-07-19 123/week @ 2024-07-26 51/week @ 2024-08-02 38/week @ 2024-08-09 86/week @ 2024-08-16 98/week @ 2024-08-23 122/week @ 2024-08-30 84/week @ 2024-09-06 101/week @ 2024-09-13 95/week @ 2024-09-20 23/week @ 2024-09-27 12/week @ 2024-10-04 152/week @ 2024-10-11 121/week @ 2024-10-18 48/week @ 2024-10-25 91/week @ 2024-11-01

413 downloads per month
Used in 3 crates (via roughr)

MIT license

43KB
437 lines

points_on_curve 〰️ 📌

Crates.io Documentation License

This crate is a rustlang port of points-on-curve npm package written by @pshihn.

This package exposes functions to sample points on a bezier curve with certain tolerance. There is also a utility funtion to simplify the shape to use fewer points. This can really be useful when estimating lines/polygons for curves in WebGL or for Hit/Collision detections. Reverse of this operation is also supported meaning given some points generate bezier curve points passing through this points

📦 Cargo.toml

[dependencies]
points_on_curve = "0.1"

🔧 Example

use euclid::{default, point2};
use points_on_curve::points_on_bezier_curves;

let input = vec![
        point2(70.0, 240.0),
        point2(145.0, 60.0),
        point2(275.0, 90.0),
        point2(300.0, 230.0),
    ];
let result_015 = points_on_bezier_curves(&input, 0.2, Some(0.15));

🖨️ Output

This picture shows computed points with 4 different distance values 0.15, 0.75, 1.5 and 3.0 with tolerance 2.0.

tolerance

🔭 Examples

For more examples have a look at the examples folder.

📝 License

Licensed under MIT License (LICENSE).

🚧 Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.

Dependencies

~645KB
~15K SLoC