Skip to content

Commit c69b23b

Browse files
committed
Bug fix: handle special cases for drawing path with width
1 parent 31b8e5a commit c69b23b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/drawing/rasterizer/path.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ fn compute_polygon_vertex(triple: &[BackendCoord; 3], d: f64) -> BackendCoord {
4040
let b1 = -b_t.1;
4141
let c1 = b_p.1 - a_p.1;
4242

43+
// This is the coner case that
44+
if (a0 * b1 - a1 * b0).abs() < 1e-10 {
45+
return (a_p.0 as i32, a_p.1 as i32);
46+
}
47+
4348
let u = (c0 * b1 - c1 * b0) / (a0 * b1 - a1 * b0);
4449

4550
let x = a_p.0 + u * a_t.0;
@@ -81,6 +86,7 @@ fn traverse_vertices<'a>(
8186
recent.swap(0, 1);
8287
recent.swap(1, 2);
8388
recent[2] = *p;
89+
8490
op(compute_polygon_vertex(&recent, f64::from(width) / 2.0));
8591
}
8692

0 commit comments

Comments
 (0)