Apply cargo fmt

This commit is contained in:
2026-09-10 11:49:20 +02:00
parent ada2c3d89d
commit 4884aca3dd
8 changed files with 302 additions and 122 deletions
+7 -2
View File
@@ -99,7 +99,9 @@ pub fn bezier_point(p: [Pos2; 4], t: f32) -> Pos2 {
/// Derivative of a cubic Bézier at `t`; the direction the curve travels in.
pub fn bezier_tangent(p: [Pos2; 4], t: f32) -> Vec2 {
let u = 1.0 - t;
let d = (p[1] - p[0]) * (3.0 * u * u) + (p[2] - p[1]) * (6.0 * u * t) + (p[3] - p[2]) * (3.0 * t * t);
let d = (p[1] - p[0]) * (3.0 * u * u)
+ (p[2] - p[1]) * (6.0 * u * t)
+ (p[3] - p[2]) * (3.0 * t * t);
if d.length() > f32::EPSILON {
d.normalized()
} else {
@@ -126,7 +128,10 @@ pub fn distance_to_curve(p: [Pos2; 4], point: Pos2) -> f32 {
pub fn curve_bounds(p: [Pos2; 4]) -> Rect {
let mut rect = Rect::from_points(&[p[0], p[3]]);
for i in 1..SAMPLES {
rect = rect.union(Rect::from_points(&[bezier_point(p, i as f32 / SAMPLES as f32)]));
rect = rect.union(Rect::from_points(&[bezier_point(
p,
i as f32 / SAMPLES as f32,
)]));
}
rect
}