fix underflow when calculating new bounds

This commit is contained in:
edwloef 2025-05-29 23:55:05 +02:00
parent c1ab626307
commit 6f935f3449
No known key found for this signature in database

View file

@ -246,8 +246,8 @@ impl Rectangle<f32> {
let top_left = self.position().snap();
let bottom_right = (self.position() + self.size().into()).snap();
let width = bottom_right.x - top_left.x;
let height = bottom_right.y - top_left.y;
let width = bottom_right.x.checked_sub(top_left.x)?;
let height = bottom_right.y.checked_sub(top_left.y)?;
if width < 1 || height < 1 {
return None;