From 8a88f71cb11565c1a78bd57f02a8df17cb2bf7a0 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 23 Nov 2021 22:04:08 +0100 Subject: Transformations --- src/library/shape.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/library/shape.rs') 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 { - 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 { 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 { - 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 { 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>, + width: Option, + height: Option, ) -> TypResult { // 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)) }))) } -- cgit v1.2.3