mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
Rect -> [u16;4] in core
This commit is contained in:
parent
4b92465073
commit
fa739a49b2
7 changed files with 86 additions and 112 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue