wip: fixing Map, centering

This commit is contained in:
🪞👃🪞 2025-01-01 17:00:28 +01:00
parent 059ff2ca79
commit d17d20e7db
10 changed files with 104 additions and 78 deletions

View file

@ -29,13 +29,13 @@ impl<E: Engine, T: Content<E>> Content<E> for Align<E, T> {
}
pub fn align_areas<N: Coordinate>(alignment: Alignment, on: [N;4], it: [N;4]) -> [N;4] {
let [cfx, cfy] = on.center();
let [cmx, cmy] = it.center();
let center = |cf, cm, m: N|if cf >= cm { m + (cf - cm) } else { m.minus(cm - cf) };
let center_x = center(cfx, cmx, it.x());
let center_y = center(cfy, cmy, it.y());
let east_x = on.x() + on.w().minus(it.w());
let south_y = on.y() + on.h().minus(it.h());
let [cfx, cfy, ..] = on.center();
let [cmx, cmy, ..] = it.center();
let center = |cf, cm, m: N|if cf >= cm { m + (cf - cm) } else { m.minus(cm - cf) };
let center_x = center(cfx, cmx, it.x());
let center_y = center(cfy, cmy, it.y());
let east_x = on.x() + on.w().minus(it.w());
let south_y = on.y() + on.h().minus(it.h());
let [x, y] = match alignment {
Alignment::Center => [center_x, center_y,],