Skip to content

Commit

Permalink
Check empty crop size
Browse files Browse the repository at this point in the history
  • Loading branch information
pol-rivero committed Dec 30, 2024
1 parent 676530f commit 0df085b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/femtovg_area/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,11 @@ impl FemtoVgAreaMut {
.crop_tool
.borrow()
.get_crop()
.map(|c| rect_ensure_in_bounds(c.get_rectangle(), bounds))
.map(|c| c.get_rectangle())
.map(|rect| rect_ensure_in_bounds(rect, bounds))
.map(rect_round)
.unwrap_or((
Vec2D::zero(),
Vec2D::new(
self.background_image.width() as f32,
self.background_image.height() as f32,
),
));
.filter(|(_, size)| !size.is_zero())
.unwrap_or(bounds);

// create render-target
let image_id = canvas.create_image_empty(
Expand Down
4 changes: 4 additions & 0 deletions src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ impl Vec2D {
Vec2D::new(-a, -b)
}
}

pub fn is_zero(&self) -> bool {
self.x.abs() < f32::EPSILON && self.y.abs() < f32::EPSILON
}
}

impl Add for Vec2D {
Expand Down

0 comments on commit 0df085b

Please sign in to comment.