mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
wip: fixing Map, centering
This commit is contained in:
parent
059ff2ca79
commit
d17d20e7db
10 changed files with 104 additions and 78 deletions
|
|
@ -90,6 +90,9 @@ pub trait Area<N: Coordinate> {
|
|||
Ok(self)
|
||||
}
|
||||
}
|
||||
#[inline] fn xy (&self) -> [N;2] {
|
||||
[self.x(), self.y()]
|
||||
}
|
||||
#[inline] fn wh (&self) -> [N;2] {
|
||||
[self.w(), self.h()]
|
||||
}
|
||||
|
|
@ -121,7 +124,10 @@ pub trait Area<N: Coordinate> {
|
|||
[self.x(), self.x2(), self.y(), self.y2()]
|
||||
}
|
||||
#[inline] fn center (&self) -> [N;2] {
|
||||
[self.x() + self.w() / 2.into(), self.y() + self.h() / 2.into()]
|
||||
[self.x() + self.w()/2.into(), self.y() + self.h()/2.into()]
|
||||
}
|
||||
#[inline] fn centered (&self) -> [N;2] {
|
||||
[self.x().minus(self.w()/2.into()), self.y().minus(self.h()/2.into())]
|
||||
}
|
||||
fn zero () -> [N;4] {
|
||||
[N::zero(), N::zero(), N::zero(), N::zero()]
|
||||
|
|
|
|||
|
|
@ -30,16 +30,13 @@ pub trait Content<E: Engine>: Send + Sync {
|
|||
}
|
||||
}
|
||||
|
||||
/// The platonic ideal item of content: emptiness at dead center.
|
||||
/// The platonic ideal unit of [Content]: total emptiness at dead center.
|
||||
impl<E: Engine> Content<E> for () {
|
||||
fn layout (&self, area: E::Area) -> E::Area {
|
||||
let [x, y, w, h] = area.xywh();
|
||||
let x = x + w / 2.into();
|
||||
let y = y + h / 2.into();
|
||||
let [x, y] = area.center();
|
||||
[x, y, 0.into(), 0.into()].into()
|
||||
}
|
||||
fn render (&self, _: &mut E::Output) {
|
||||
}
|
||||
fn render (&self, _: &mut E::Output) {}
|
||||
}
|
||||
|
||||
impl<E: Engine, T: Content<E>> Content<E> for &T {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue