diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-23 22:04:08 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-23 22:04:08 +0100 |
| commit | 8a88f71cb11565c1a78bd57f02a8df17cb2bf7a0 (patch) | |
| tree | 8802c1ff48e2be118e3872d25bd2f2c1f7a21b4a /src/library/shape.rs | |
| parent | c77c5a0f0ae6560a03a85e847006c29de9c7ae62 (diff) | |
Transformations
Diffstat (limited to 'src/library/shape.rs')
| -rw-r--r-- | src/library/shape.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/library/shape.rs b/src/library/shape.rs index 061b4d25..5d3504d0 100644 --- a/src/library/shape.rs +++ b/src/library/shape.rs @@ -5,8 +5,9 @@ use crate::util::RcExt; /// `rect`: A rectangle with optional content. pub fn rect(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> { - let sizing = Spec::new(args.named("width")?, args.named("height")?); - shape_impl(args, ShapeKind::Rect, sizing) + let width = args.named("width")?; + let height = args.named("height")?; + shape_impl(args, ShapeKind::Rect, width, height) } /// `square`: A square with optional content. @@ -20,14 +21,14 @@ pub fn square(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> { None => args.named("height")?, size => size, }; - let sizing = Spec::new(width, height); - shape_impl(args, ShapeKind::Square, sizing) + shape_impl(args, ShapeKind::Square, width, height) } /// `ellipse`: An ellipse with optional content. pub fn ellipse(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> { - let sizing = Spec::new(args.named("width")?, args.named("height")?); - shape_impl(args, ShapeKind::Ellipse, sizing) + let width = args.named("width")?; + let height = args.named("height")?; + shape_impl(args, ShapeKind::Ellipse, width, height) } /// `circle`: A circle with optional content. @@ -41,14 +42,14 @@ pub fn circle(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> { None => args.named("height")?, diameter => diameter, }; - let sizing = Spec::new(width, height); - shape_impl(args, ShapeKind::Circle, sizing) + shape_impl(args, ShapeKind::Circle, width, height) } fn shape_impl( args: &mut Args, kind: ShapeKind, - sizing: Spec<Option<Linear>>, + width: Option<Linear>, + height: Option<Linear>, ) -> TypResult<Value> { // The default appearance of a shape. let default = Stroke { @@ -80,7 +81,7 @@ fn shape_impl( child: body.as_ref().map(|body| body.pack(style).padded(padding)), } .pack() - .sized(sizing) + .sized(Spec::new(width, height)) }))) } |
