diff options
| author | Martin Haug <mhaug@live.de> | 2022-05-02 16:51:14 +0200 |
|---|---|---|
| committer | Martin Haug <mhaug@live.de> | 2022-05-02 17:20:47 +0200 |
| commit | f07395f9a47502c50f767f78a233d0e2a6e4445f (patch) | |
| tree | c54fe2afeaaf265780279c893c272f1abfd12393 /src/library | |
| parent | 7b6f3a0ab9ae0dac19f62b62b9ecc96ea942a89e (diff) | |
Move rounding logic out of exporters
Diffstat (limited to 'src/library')
| -rw-r--r-- | src/library/graphics/shape.rs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/library/graphics/shape.rs b/src/library/graphics/shape.rs index f7cda9bf..e6fd2b7d 100644 --- a/src/library/graphics/shape.rs +++ b/src/library/graphics/shape.rs @@ -150,7 +150,7 @@ impl<const S: ShapeKind> Layout for ShapeNode<S> { // Add fill and/or stroke. let fill = styles.get(Self::FILL); - let mut stroke = match styles.get(Self::STROKE) { + let stroke = match styles.get(Self::STROKE) { Smart::Auto if fill.is_none() => Sides::splat(Some(Stroke::default())), Smart::Auto => Sides::splat(None), Smart::Custom(strokes) => { @@ -179,15 +179,23 @@ impl<const S: ShapeKind> Layout for ShapeNode<S> { bottom: radius.bottom.relative_to(size.y / 2.0), }; - if fill.is_some() || (stroke.iter().any(Option::is_some) && stroke.is_uniform()) { - let geometry = if is_round(S) { - Geometry::Ellipse(size) - } else { - Geometry::Rect(size, radius) - }; + let pos = Point::new(-outset.left, -outset.top); - let shape = Shape { geometry, fill, stroke }; - frame.prepend(Point::new(-outset.left, -outset.top), Element::Shape(shape)); + if fill.is_some() || stroke.iter().any(Option::is_some) { + if is_round(S) { + let shape = Shape { + geometry: Geometry::Ellipse(size), + fill, + stroke: stroke.left, + }; + frame.prepend(pos, Element::Shape(shape)); + } else { + for shape in + Rect::new(size, radius).shapes(fill, stroke).into_iter().rev() + { + frame.prepend(pos, Element::Shape(shape)); + } + } } // Apply link if it exists. |
