Rect -> [u16;4] in core

This commit is contained in:
🪞👃🪞 2024-09-07 12:40:27 +03:00
parent 4b92465073
commit fa739a49b2
7 changed files with 86 additions and 112 deletions

View file

@ -3,30 +3,18 @@ use crate::*;
pub trait Point<N: Number> {
fn x (&self) -> N;
fn y (&self) -> N;
fn w (&self) -> N {
self.x()
}
fn h (&self) -> N {
self.y()
}
fn w (&self) -> N { self.x() }
fn h (&self) -> N { self.y() }
}
impl<N: Number> Point<N> for (N, N) {
fn x (&self) -> N {
self.0
}
fn y (&self) -> N {
self.1
}
fn x (&self) -> N { self.0 }
fn y (&self) -> N { self.1 }
}
impl<N: Number> Point<N> for [N;2] {
fn x (&self) -> N {
self[0]
}
fn y (&self) -> N {
self[1]
}
fn x (&self) -> N { self[0] }
fn y (&self) -> N { self[1] }
}
pub trait Area<N: Number> {
@ -34,42 +22,28 @@ pub trait Area<N: Number> {
fn y (&self) -> N;
fn w (&self) -> N;
fn h (&self) -> N;
fn x2 (&self) -> N {
self.x() + self.w()
fn x2 (&self) -> N { self.x() + self.w() }
fn y2 (&self) -> N { self.y() + self.h() }
fn xywh (&self) -> [N;4] {
[self.x(), self.y(), self.w(), self.h()]
}
fn y2 (&self) -> N {
self.y() + self.h()
fn lrtb (&self) -> [N;4] {
[self.x(), self.x2(), self.y(), self.y2()]
}
}
impl<N: Number> Area<N> for (N, N, N, N) {
fn x (&self) -> N {
self.0
}
fn y (&self) -> N {
self.1
}
fn w (&self) -> N {
self.2
}
fn h (&self) -> N {
self.3
}
fn x (&self) -> N { self.0 }
fn y (&self) -> N { self.1 }
fn w (&self) -> N { self.2 }
fn h (&self) -> N { self.3 }
}
impl<N: Number> Area<N> for [N;4] {
fn x (&self) -> N {
self[0]
}
fn y (&self) -> N {
self[1]
}
fn w (&self) -> N {
self[2]
}
fn h (&self) -> N {
self[3]
}
fn x (&self) -> N { self[0] }
fn y (&self) -> N { self[1] }
fn w (&self) -> N { self[2] }
fn h (&self) -> N { self[3] }
}
macro_rules! impl_axis_common { ($A:ident $T:ty) => {