properly handle close in get_current_point

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev 2025-06-04 19:42:12 +02:00
parent 9b204867c0
commit a281f3553e

View file

@ -708,7 +708,7 @@ impl GenericPathBuilder<RaqoteBackend> for PathBuilder {
PathOp::MoveTo(point) | PathOp::LineTo(point) => Some(Point2D::new(point.x, point.y)), PathOp::MoveTo(point) | PathOp::LineTo(point) => Some(Point2D::new(point.x, point.y)),
PathOp::CubicTo(_, _, point) => Some(Point2D::new(point.x, point.y)), PathOp::CubicTo(_, _, point) => Some(Point2D::new(point.x, point.y)),
PathOp::QuadTo(_, point) => Some(Point2D::new(point.x, point.y)), PathOp::QuadTo(_, point) => Some(Point2D::new(point.x, point.y)),
PathOp::Close => None, PathOp::Close => path.ops.first().and_then(get_first_point),
}) })
} }
@ -731,6 +731,15 @@ impl GenericPathBuilder<RaqoteBackend> for PathBuilder {
} }
} }
fn get_first_point(op: &PathOp) -> Option<euclid::Point2D<f32, euclid::UnknownUnit>> {
match op {
PathOp::MoveTo(point) | PathOp::LineTo(point) => Some(Point2D::new(point.x, point.y)),
PathOp::CubicTo(point, _, _) => Some(Point2D::new(point.x, point.y)),
PathOp::QuadTo(point, _) => Some(Point2D::new(point.x, point.y)),
PathOp::Close => None,
}
}
pub trait ToRaqoteStyle { pub trait ToRaqoteStyle {
type Target; type Target;