mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
fix Fixed
This commit is contained in:
parent
01dacd407d
commit
8c28ef2bd7
4 changed files with 31 additions and 29 deletions
|
|
@ -128,15 +128,15 @@ pub trait Area<N: Coordinate> {
|
|||
}
|
||||
#[inline] fn center_x (&self, n: N) -> [N;4] {
|
||||
let [x, y, w, h] = self.xywh();
|
||||
[x + w / 2.into() - n, y + h / 2.into(), n, 1.into()]
|
||||
[(x + w / 2.into()).minus(n / 2.into()), y + h / 2.into(), n, 1.into()]
|
||||
}
|
||||
#[inline] fn center_y (&self, m: N) -> [N;4] {
|
||||
let [x, y, w, h] = self.xywh();
|
||||
[x + w / 2.into(), y + h / 2.into() - m, 1.into(), m]
|
||||
[x + w / 2.into(), (y + h / 2.into()).minus(m / 2.into()), 1.into(), m]
|
||||
}
|
||||
#[inline] fn center_xy (&self, [n, m]: [N;2]) -> [N;4] {
|
||||
let [x, y, w, h] = self.xywh();
|
||||
[x + w / 2.into() - n, y + h / 2.into() - n - m, n, m]
|
||||
[(x + w / 2.into()).minus(n / 2.into()), (y + h / 2.into()).minus(m / 2.into()), n, m]
|
||||
}
|
||||
#[inline] fn centered (&self) -> [N;2] {
|
||||
[self.x().minus(self.w()/2.into()), self.y().minus(self.h()/2.into())]
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ impl TuiOut {
|
|||
|
||||
impl Content<Tui> for &str {
|
||||
fn layout (&self, to: [u16;4]) -> [u16;4] {
|
||||
to.center_x(self.chars().count() as u16)
|
||||
to.center_xy([self.chars().count() as u16, 1])
|
||||
}
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
to.blit(self, to.area.x(), to.area.y(), None)
|
||||
|
|
@ -80,7 +80,7 @@ impl Content<Tui> for &str {
|
|||
|
||||
impl Content<Tui> for String {
|
||||
fn layout (&self, to: [u16;4]) -> [u16;4] {
|
||||
to.center_x(self.chars().count() as u16)
|
||||
to.center_xy([self.chars().count() as u16, 1])
|
||||
}
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
to.blit(self, to.area.x(), to.area.y(), None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue