summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-04-08 15:04:35 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-04-08 15:04:35 +0200
commitd922b478156488a7bc03c6e791e05c040d702634 (patch)
tree767e9b9fa2c6527a0b3e3b3dd1c21b29cd533ee8 /core/src
parent6ea763c2a79292e5b10be2240b4b57b920223616 (diff)
downloadiced-d922b478156488a7bc03c6e791e05c040d702634.tar.gz
iced-d922b478156488a7bc03c6e791e05c040d702634.tar.bz2
iced-d922b478156488a7bc03c6e791e05c040d702634.zip
Reintroduce support for custom primitives in `iced_wgpu`
Diffstat (limited to 'core/src')
-rw-r--r--core/src/rectangle.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/core/src/rectangle.rs b/core/src/rectangle.rs
index 446d3769..2ab50137 100644
--- a/core/src/rectangle.rs
+++ b/core/src/rectangle.rs
@@ -147,13 +147,20 @@ impl Rectangle<f32> {
}
/// Snaps the [`Rectangle`] to __unsigned__ integer coordinates.
- pub fn snap(self) -> Rectangle<u32> {
- Rectangle {
+ pub fn snap(self) -> Option<Rectangle<u32>> {
+ let width = self.width as u32;
+ let height = self.height as u32;
+
+ if width < 1 || height < 1 {
+ return None;
+ }
+
+ Some(Rectangle {
x: self.x as u32,
y: self.y as u32,
- width: self.width as u32,
- height: self.height as u32,
- }
+ width,
+ height,
+ })
}
/// Expands the [`Rectangle`] a given amount.