[paint] ignore negatively sized rectangles and circles

This commit is contained in:
Emil Ernerfeldt 2020-06-07 15:24:03 +02:00
parent 53dbbd0d53
commit bff7232e9d

View file

@ -573,6 +573,7 @@ pub fn paint_command_into_triangles(
outline, outline,
radius, radius,
} => { } => {
if radius > 0.0 {
path.add_circle(center, radius); path.add_circle(center, radius);
if let Some(fill) = fill { if let Some(fill) = fill {
fill_closed_path(out, options, &path.0, fill); fill_closed_path(out, options, &path.0, fill);
@ -581,6 +582,7 @@ pub fn paint_command_into_triangles(
paint_path_outline(out, options, Closed, &path.0, outline); paint_path_outline(out, options, Closed, &path.0, outline);
} }
} }
}
PaintCmd::Triangles(triangles) => { PaintCmd::Triangles(triangles) => {
out.append(&triangles); out.append(&triangles);
} }
@ -614,8 +616,9 @@ pub fn paint_command_into_triangles(
outline, outline,
mut rect, mut rect,
} => { } => {
// Common bug is to accidentally create an infinitely sized ractangle. if !rect.is_empty() {
// Make sure we can visualize that: // It is common to (sometimes accidentally) create an infinitely sized ractangle.
// Make sure we can handle that:
rect.min = rect.min.max(pos2(-1e7, -1e7)); rect.min = rect.min.max(pos2(-1e7, -1e7));
rect.max = rect.max.min(pos2(1e7, 1e7)); rect.max = rect.max.min(pos2(1e7, 1e7));
@ -627,6 +630,7 @@ pub fn paint_command_into_triangles(
paint_path_outline(out, options, Closed, &path.0, outline); paint_path_outline(out, options, Closed, &path.0, outline);
} }
} }
}
PaintCmd::Text { PaintCmd::Text {
pos, pos,
galley, galley,