🐛 Fix caps for rounded paths

This commit is contained in:
Alejandro Alonso 2025-06-06 09:50:16 +02:00
parent 8db910baee
commit 78d6166bac
2 changed files with 8 additions and 6 deletions

View file

@ -443,7 +443,7 @@ impl RenderState {
s.canvas().concat(&matrix);
});
if shape.fills.is_empty() && matches!(shape.shape_type, Type::Group(_)) {
if shape.fills.is_empty() && !matches!(shape.shape_type, Type::Group(_)) {
if let Some(fills_to_render) = self.nested_fills.last() {
let fills_to_render = fills_to_render.clone();
for fill in fills_to_render.iter() {
@ -664,7 +664,7 @@ impl RenderState {
}
}
}
if let Type::Group(group) = element.shape_type {
if let Type::Group(_) = element.shape_type {
self.nested_fills.pop();
}
self.surfaces.canvas(SurfaceId::Current).restore();

View file

@ -187,9 +187,11 @@ fn handle_stroke_caps(
scale: f32,
antialias: bool,
) {
let points_count = path.count_points();
let mut points = vec![Point::default(); points_count];
let c_points = path.get_points(&mut points);
let mut points = vec![Point::default(); path.count_points()];
path.get_points(&mut points);
// Curves can have duplicated points, so let's remove consecutive duplicated points
points.dedup();
let c_points = points.len();
// Closed shapes don't have caps
if c_points >= 2 && is_open {
@ -213,7 +215,7 @@ fn handle_stroke_caps(
stroke.width,
&mut paint_stroke,
last_point,
&points[points_count - 2],
&points[c_points - 2],
);
}
}