Skip to content

Commit 9bcc640

Browse files
committed
Add zero-division guard for pattern wraparound prevention
1 parent 6e1f127 commit 9bcc640

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

node-graph/libraries/rendering/src/render_ext.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ impl RenderExt for List<Graphic> {
246246
Some(Graphic::Vector(_)) | Some(Graphic::RasterCPU(_)) | Some(Graphic::RasterGPU(_)) | Some(Graphic::Graphic(_)) => {
247247
let bounds = if target == PaintTarget::Stroke {
248248
// To prevent a wraparound artefact occurring when the tile boundary and the stroke region are perfectly aligned, the local coordinate is expanded slightly.
249-
let inflate = DVec2::new(1.0 / item_transform.matrix2.x_axis.length(), 1.0 / item_transform.matrix2.y_axis.length());
249+
let inverse = |len: f64| if len > 0. { 1.0 / len } else { 0. };
250+
let inflate = DVec2::new(inverse(item_transform.matrix2.x_axis.length()), inverse(item_transform.matrix2.y_axis.length()));
250251
let min = bounds.transform_point2(DVec2::ZERO) - inflate;
251252
let max = bounds.transform_point2(DVec2::ONE) + inflate;
252253
DAffine2::from_scale_angle_translation(max - min, 0., min)

0 commit comments

Comments
 (0)