Skip to content

Commit f346c74

Browse files
committed
run cargo fmt
1 parent 09efa92 commit f346c74

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

src/sketch/shapes.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -756,40 +756,40 @@ impl<S: Clone + Debug + Send + Sync> Sketch<S> {
756756
}
757757

758758
/// Evaluates a Bézier curve at a given parameter `t` using de Casteljau's algorithm.
759-
fn de_casteljau(control: &[[Real; 2]], t: Real) -> (Real, Real) {
760-
let mut points = control.to_vec();
761-
let n = points.len();
762-
763-
for k in 1..n {
764-
for i in 0..(n - k) {
765-
points[i][0] = (1.0 - t) * points[i][0] + t * points[i + 1][0];
766-
points[i][1] = (1.0 - t) * points[i][1] + t * points[i + 1][1];
767-
}
768-
}
769-
(points[0][0], points[0][1])
770-
}
771-
772-
let pts: Vec<(Real, Real)> = (0..=segments)
773-
.map(|i| {
774-
let t = i as Real / segments as Real;
775-
de_casteljau(control, t)
776-
})
777-
.collect();
778-
779-
let is_closed = {
780-
let first = pts[0];
781-
let last = pts[segments];
782-
(first.0 - last.0).abs() < EPSILON && (first.1 - last.1).abs() < EPSILON
783-
};
784-
785-
let geometry = if is_closed {
786-
let ring: LineString<Real> = pts.into();
787-
Geometry::Polygon(GeoPolygon::new(ring, vec![]))
788-
} else {
789-
Geometry::LineString(pts.into())
790-
};
791-
792-
Sketch::from_geo(GeometryCollection(vec![geometry]), metadata)
759+
fn de_casteljau(control: &[[Real; 2]], t: Real) -> (Real, Real) {
760+
let mut points = control.to_vec();
761+
let n = points.len();
762+
763+
for k in 1..n {
764+
for i in 0..(n - k) {
765+
points[i][0] = (1.0 - t) * points[i][0] + t * points[i + 1][0];
766+
points[i][1] = (1.0 - t) * points[i][1] + t * points[i + 1][1];
767+
}
768+
}
769+
(points[0][0], points[0][1])
770+
}
771+
772+
let pts: Vec<(Real, Real)> = (0..=segments)
773+
.map(|i| {
774+
let t = i as Real / segments as Real;
775+
de_casteljau(control, t)
776+
})
777+
.collect();
778+
779+
let is_closed = {
780+
let first = pts[0];
781+
let last = pts[segments];
782+
(first.0 - last.0).abs() < EPSILON && (first.1 - last.1).abs() < EPSILON
783+
};
784+
785+
let geometry = if is_closed {
786+
let ring: LineString<Real> = pts.into();
787+
Geometry::Polygon(GeoPolygon::new(ring, vec![]))
788+
} else {
789+
Geometry::LineString(pts.into())
790+
};
791+
792+
Sketch::from_geo(GeometryCollection(vec![geometry]), metadata)
793793
}
794794

795795
/// Sample an open-uniform B-spline of arbitrary degree (`p`) using the

0 commit comments

Comments
 (0)