implement align for all azimuths
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
facile pop culture reference 2026-07-15 14:28:19 +03:00
parent 482b624169
commit aa0dd37d88

View file

@ -290,24 +290,24 @@ pub struct Align<T>(Option<Azimuth>, T);
impl_draw!(<S: Screen, T: Draw<S>,>|self: Align<T>, to: S|{
use Azimuth::*;
let XYWH(x0, y0, w0, h0) = to.area();
Ok(if let Some(XYWH(x, y, w, h)) = self.1.layout(to.area())? {
if let Some(XYWH(x, y, w, h)) = self.1.layout(to.area())? {
to.clip(match self.0 {
Some(NW) => XYWH(x0, y0, w, h),
Some(N) => todo!(),
Some(NE) => todo!(),
Some(W) => todo!(),
Some(C) => todo!(),
Some(E) => todo!(),
Some(SW) => todo!(),
Some(S) => XYWH(x0 + w0.sub(w) / 2.into(), (y0 + h0).sub(h), w, h),
Some(SE) => todo!(),
Some(X) => todo!(),
Some(Y) => todo!(),
None => to.area()
}, |to|self.1.draw(to))?
Some(NW) => XYWH(x0, y0, w, h),
Some(N) => XYWH(x0 + w0.sub(w) / 2.into(), y0, w, h),
Some(NE) => XYWH((x0 + w0).sub(w), y0, w, h),
Some(W) => XYWH(x0, y0 + h0.sub(h) / 2.into(), w, h),
Some(C) => XYWH(x0 + w0.sub(w) / 2.into(), y0 + h0.sub(h) / 2.into(), w, h),
Some(E) => XYWH((x0 + w0).sub(w), y0 + h0.sub(h) / 2.into(), w, h),
Some(SW) => XYWH(x0, (y0 + h0).sub(h), w, h),
Some(S) => XYWH(x0 + w0.sub(w) / 2.into(), (y0 + h0).sub(h), w, h),
Some(SE) => XYWH((x0 + w0).sub(w), (y0 + h0).sub(h), w, h),
Some(X) => XYWH(x0 + w0.sub(w) / 2.into(), y, w, h),
Some(Y) => XYWH(x, y0 + h0.sub(h) / 2.into(), w, h),
None => to.area()
}, |to|self.1.draw(to))
} else {
None
})
self.1.draw(to)
}
});
/// Where is [0, 0] located?