diff --git a/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs b/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs index 1ea540a6..e2279c9f 100644 --- a/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs +++ b/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs @@ -12,7 +12,6 @@ internal class StreamGeometryImpl : IStreamGeometryImpl { private readonly List _fills; private readonly List _strokes; - private Rect _bounds; public StreamGeometryImpl() { @@ -25,23 +24,25 @@ public StreamGeometryImpl() public IReadOnlyList Fills => _fills; // private SKPath _path; - public Rect Bounds => _bounds; + public Rect Bounds { get; private set; } public double ContourLength => _strokes.Sum(l => l.ContourLength); public IStreamGeometryImpl Clone() { - var clone = new StreamGeometryImpl(); - foreach (Line line in _strokes) clone._strokes.Add(line); - foreach (Rectangle rect in _fills) clone._fills.Add(rect); - clone._bounds = _bounds; - return clone; + var cloneGeometry = new StreamGeometryImpl(); + foreach (Line cloneLine in _strokes.Select(l => new Line(l.PStart, l.PEnd, this, l.Transform))) + cloneGeometry._strokes.Add(cloneLine); + foreach (Rectangle cloneRect in _fills.Select(r => new Rectangle(r.Rect, r, r.Transform))) + cloneGeometry._fills.Add(cloneRect); + cloneGeometry.Bounds = Bounds; + return cloneGeometry; } public bool FillContains(Point point) { - return _bounds.Contains(point); + return _fills.Any(rect => rect.FillContains(point)); } public Rect GetRenderBounds(IPen pen) @@ -177,11 +178,8 @@ public void LineTo(Point point) public void EndFigure(bool isClosed) { Rect bound = _geometryImpl._strokes.Aggregate(new Rect(), (rect, line) => rect.Union(line.Bounds)); - _geometryImpl._bounds = bound; - if (_isFilled) - { - // _geometryImpl._fills.Add(new Rectangle(bound)); - } + _geometryImpl.Bounds = bound; + if (_isFilled) _geometryImpl._fills.Add(new Rectangle(bound)); } ///