1
0
Fork 0
forked from wry/wry

autocommit 2022-04-04 23:09:39 CEST

This commit is contained in:
Julian Orth 2022-04-04 23:09:39 +02:00
parent e897d271af
commit 5f79aab15f
21 changed files with 870 additions and 731 deletions

View file

@ -1,3 +1,10 @@
mod region;
#[cfg(test)]
mod tests;
pub use region::RegionBuilder;
use smallvec::SmallVec;
use std::fmt::{Debug, Formatter};
#[derive(Copy, Clone, Eq, PartialEq, Default)]
@ -8,6 +15,14 @@ pub struct Rect {
y2: i32,
}
type Container = SmallVec<[Rect; 1]>;
#[derive(Default)]
pub struct Region {
rects: Container,
extents: Rect,
}
impl Debug for Rect {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Rect")
@ -60,6 +75,10 @@ impl Rect {
Some(Self { x1, y1, x2, y2 })
}
fn new_unchecked(x1: i32, y1: i32, x2: i32, y2: i32) -> Self {
Self { x1, y1, x2, y2 }
}
pub fn new_sized(x1: i32, y1: i32, width: i32, height: i32) -> Option<Self> {
if width < 0 || height < 0 {
return None;