Reintroduce support for custom primitives in iced_wgpu

This commit is contained in:
Héctor Ramón Jiménez 2024-04-08 15:04:35 +02:00
parent 6ea763c2a7
commit d922b47815
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
11 changed files with 220 additions and 173 deletions

View file

@ -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.