diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-03-25 21:32:33 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-03-25 21:32:33 +0100 |
| commit | 76fc4cca62f5b955200b2c62cc85b69eea491ece (patch) | |
| tree | 5b8492268c996cf23b13e26c7a4356fbd156286d /src/library/shapes.rs | |
| parent | e8057a53856dc09594c9e5861f1cd328531616e0 (diff) | |
Refactor alignments & directions 📐
- Adds lang function
- Refactors execution context
- Adds StackChild and ParChild enums
Diffstat (limited to 'src/library/shapes.rs')
| -rw-r--r-- | src/library/shapes.rs | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/library/shapes.rs b/src/library/shapes.rs index 9f705ef7..6f9e6677 100644 --- a/src/library/shapes.rs +++ b/src/library/shapes.rs @@ -59,21 +59,18 @@ fn rect_impl( body: TemplateValue, ) -> Value { Value::template(name, move |ctx| { - let snapshot = ctx.state.clone(); - let child = ctx.exec(&body).into(); + let child = ctx.exec_group(&body).into(); let node = FixedNode { width, height, aspect, child }; if let Some(color) = fill { - ctx.push(BackgroundNode { + ctx.push_into_par(BackgroundNode { shape: BackgroundShape::Rect, fill: Fill::Color(color), child: node.into(), }); } else { - ctx.push(node); + ctx.push_into_par(node); } - - ctx.state = snapshot; }) } @@ -136,8 +133,7 @@ fn ellipse_impl( // perfectly into the ellipse. const PAD: f64 = 0.5 - SQRT_2 / 4.0; - let snapshot = ctx.state.clone(); - let child = ctx.exec(&body).into(); + let child = ctx.exec_group(&body).into(); let node = FixedNode { width, height, @@ -150,15 +146,13 @@ fn ellipse_impl( }; if let Some(color) = fill { - ctx.push(BackgroundNode { + ctx.push_into_par(BackgroundNode { shape: BackgroundShape::Ellipse, fill: Fill::Color(color), child: node.into(), }); } else { - ctx.push(node); + ctx.push_into_par(node); } - - ctx.state = snapshot; }) } |
