diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-08 17:08:30 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-09 12:02:35 +0200 |
| commit | 29eb13ca6214461a4b0deb63d589cd39ad6d41c2 (patch) | |
| tree | c86797d440cfcc801c87a3c64f479e39f2c068b1 /src/library/graphics/shape.rs | |
| parent | 712c00ecb72b67da2c0788e5d3eb4dcc6366b2a7 (diff) | |
Sum color and length into stroke
Diffstat (limited to 'src/library/graphics/shape.rs')
| -rw-r--r-- | src/library/graphics/shape.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/library/graphics/shape.rs b/src/library/graphics/shape.rs index ec6f735b..a159a3af 100644 --- a/src/library/graphics/shape.rs +++ b/src/library/graphics/shape.rs @@ -24,10 +24,8 @@ impl<const S: ShapeKind> ShapeNode<S> { /// How to fill the shape. pub const FILL: Option<Paint> = None; /// How to stroke the shape. - pub const STROKE: Smart<Option<Paint>> = Smart::Auto; - /// The stroke's thickness. - #[property(resolve)] - pub const THICKNESS: RawLength = Length::pt(1.0).into(); + #[property(resolve, fold)] + pub const STROKE: Smart<Option<RawStroke>> = Smart::Auto; /// How much to pad the shape's content. pub const PADDING: Relative<RawLength> = Relative::zero(); @@ -115,11 +113,10 @@ impl<const S: ShapeKind> Layout for ShapeNode<S> { // Add fill and/or stroke. let fill = styles.get(Self::FILL); - let thickness = styles.get(Self::THICKNESS); - let stroke = styles - .get(Self::STROKE) - .unwrap_or(fill.is_none().then(|| Color::BLACK.into())) - .map(|paint| Stroke { paint, thickness }); + let stroke = match styles.get(Self::STROKE) { + Smart::Auto => fill.is_none().then(Stroke::default), + Smart::Custom(stroke) => stroke.map(RawStroke::unwrap_or_default), + }; if fill.is_some() || stroke.is_some() { let geometry = if is_round(S) { |
