Area merging

This commit is contained in:
2026-02-01 19:03:12 +01:00
parent 25bebcbb81
commit 2606e9b4e1
2 changed files with 49 additions and 0 deletions
+18
View File
@@ -114,3 +114,21 @@ impl DrawContext {
self.drawing.clear();
}
}
impl Area {
fn right(&self) -> u16 {
self.x + self.width
}
fn bottom(&self) -> u16 {
self.y + self.height
}
pub fn merge(&mut self, other: &Self) {
self.x = self.x.min(other.x);
self.y = self.y.min(other.y);
self.width = self.right().max(other.right()) - self.x;
self.height = self.bottom().max(other.bottom()) - self.y;
}
}