summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-05-17 15:23:04 +0200
committerLaurenz <laurmaedje@gmail.com>2021-05-17 15:23:04 +0200
commit24c4a746bc68874f2d1b0d1b726596930acaadcf (patch)
tree8288a78ab53c4d07952f0975ff5166068d4f4526 /src/library
parent1003d320d40aa46a0a3fba49b09425ead1b4b584 (diff)
Move aspect ratio into stack
Diffstat (limited to 'src/library')
-rw-r--r--src/library/shapes.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/library/shapes.rs b/src/library/shapes.rs
index 6c6a2f0b..c87a0ac3 100644
--- a/src/library/shapes.rs
+++ b/src/library/shapes.rs
@@ -59,17 +59,19 @@ fn rect_impl(
body: TemplateValue,
) -> Value {
Value::template(name, move |ctx| {
- let child = ctx.exec_group(&body).into();
- let node = FixedNode { width, height, aspect, child };
+ let mut stack = ctx.exec_group(&body);
+ stack.aspect = aspect;
+
+ let fixed = FixedNode { width, height, child: stack.into() };
if let Some(color) = fill {
ctx.push(BackgroundNode {
shape: BackgroundShape::Rect,
fill: Fill::Color(color),
- child: node.into(),
+ child: fixed.into(),
});
} else {
- ctx.push(node);
+ ctx.push(fixed);
}
})
}
@@ -133,14 +135,15 @@ fn ellipse_impl(
// perfectly into the ellipse.
const PAD: f64 = 0.5 - SQRT_2 / 4.0;
- let child = ctx.exec_group(&body).into();
- let node = FixedNode {
+ let mut stack = ctx.exec_group(&body);
+ stack.aspect = aspect;
+
+ let fixed = FixedNode {
width,
height,
- aspect,
child: PadNode {
padding: Sides::uniform(Relative::new(PAD).into()),
- child,
+ child: stack.into(),
}
.into(),
};
@@ -149,10 +152,10 @@ fn ellipse_impl(
ctx.push(BackgroundNode {
shape: BackgroundShape::Ellipse,
fill: Fill::Color(color),
- child: node.into(),
+ child: fixed.into(),
});
} else {
- ctx.push(node);
+ ctx.push(fixed);
}
})
}