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

@ -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>;