mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +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
|
|
@ -1,5 +1,15 @@
|
|||
use crate::*;
|
||||
|
||||
// TODO: Convert to component
|
||||
// pub enum Align { Center, NW, N, NE, E, SE, S, SW, W, }
|
||||
pub fn center_box (area: Rect, w: u16, h: u16) -> Rect {
|
||||
let width = w.min(area.width * 3 / 5);
|
||||
let height = h.min(area.width * 3 / 5);
|
||||
let x = area.x + (area.width - width) / 2;
|
||||
let y = area.y + (area.height - height) / 2;
|
||||
Rect { x, y, width, height }
|
||||
}
|
||||
|
||||
/// Trait for structs that compute drawing area before rendering
|
||||
pub trait Layout<E: Engine>: Render<E> {
|
||||
fn layout (&self, area: E::Area) -> Perhaps<E::Area>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue