mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
sweeeeping sweep
This commit is contained in:
parent
c9b09b7dea
commit
e677d1d7d4
38 changed files with 766 additions and 691 deletions
|
|
@ -26,12 +26,12 @@ macro_rules! transform_xy {
|
|||
}
|
||||
impl<E: Engine, T: Content<E>> Content<E> for $Enum<E, T> {
|
||||
fn content (&self) -> Option<impl Content<E>> {
|
||||
match self {
|
||||
Self::_Unused(_) => None,
|
||||
Self::X(item) => Some(item),
|
||||
Self::Y(item) => Some(item),
|
||||
Self::XY(item) => Some(item),
|
||||
}
|
||||
Some(match self {
|
||||
Self::X(item) => item,
|
||||
Self::Y(item) => item,
|
||||
Self::XY(item) => item,
|
||||
_ => unreachable!()
|
||||
})
|
||||
}
|
||||
fn area (&$self, $to: <E as Engine>::Area) -> <E as Engine>::Area {
|
||||
$area
|
||||
|
|
@ -42,16 +42,13 @@ macro_rules! transform_xy {
|
|||
|
||||
transform_xy!(self: Fill |to|{
|
||||
let [x0, y0, wmax, hmax] = to.xywh();
|
||||
if let Some(content) = self.content() {
|
||||
let [x, y, w, h] = content.area(to).xywh();
|
||||
return match self {
|
||||
Self::X(_) => [x0, y, wmax, h],
|
||||
Self::Y(_) => [x, y0, w, hmax],
|
||||
Self::XY(_) => [x0, y0, wmax, hmax],
|
||||
_ => unreachable!()
|
||||
}.into()
|
||||
}
|
||||
return [0.into(), 0.into(), 0.into(), 0.into(),].into()
|
||||
let [x, y, w, h] = self.content().unwrap().area(to).xywh();
|
||||
return match self {
|
||||
Self::X(_) => [x0, y, wmax, h],
|
||||
Self::Y(_) => [x, y0, w, hmax],
|
||||
Self::XY(_) => [x0, y0, wmax, hmax],
|
||||
_ => unreachable!()
|
||||
}.into()
|
||||
});
|
||||
|
||||
/// Defines an enum that transforms its content parametrically
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue