alignment!!!

This commit is contained in:
2025-08-28 21:55:34 -04:00
parent 46c7d8ba26
commit 1204e3728e
11 changed files with 190 additions and 86 deletions

View File

@@ -2,25 +2,6 @@ use std::ops::Not;
use crate::layout::{Vec2, vec2};
#[derive(Clone, Copy, Debug)]
pub enum Corner {
TopLeft,
TopRight,
BotLeft,
BotRight,
}
impl Corner {
pub const fn anchor(&self) -> Vec2 {
match self {
Corner::TopLeft => vec2(0.0, 0.0),
Corner::TopRight => vec2(1.0, 0.0),
Corner::BotLeft => vec2(0.0, 1.0),
Corner::BotRight => vec2(1.0, 1.0),
}
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum Axis {
X,
@@ -89,3 +70,33 @@ impl Vec2 {
}
}
}
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Align {
TopLeft,
Top,
TopRight,
Left,
Center,
Right,
BotLeft,
Bot,
BotRight,
}
impl Align {
pub const fn anchor(&self) -> Vec2 {
match self {
Self::TopLeft => vec2(0.0, 0.0),
Self::Top => vec2(0.5, 0.0),
Self::TopRight => vec2(1.0, 0.0),
Self::Left => vec2(0.0, 0.5),
Self::Center => vec2(0.5, 0.5),
Self::Right => vec2(1.0, 0.5),
Self::BotLeft => vec2(0.0, 1.0),
Self::Bot => vec2(0.5, 1.0),
Self::BotRight => vec2(1.0, 1.0),
}
}
}