Apply cargo fmt
This commit is contained in:
+7
-2
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user