From 0cdb44d15fb62169dd8b8948583145e43d9e45f0 Mon Sep 17 00:00:00 2001 From: Tom Laird-McConnell Date: Fri, 13 Dec 2024 07:05:38 -0800 Subject: [PATCH 1/2] cleanup cloning as per review --- src/Consolonia.Core/Drawing/StreamGeometryImpl.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs b/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs index 1ea540a6..8c306730 100644 --- a/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs +++ b/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs @@ -32,16 +32,16 @@ public StreamGeometryImpl() 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, transform: 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) @@ -180,7 +180,7 @@ public void EndFigure(bool isClosed) _geometryImpl._bounds = bound; if (_isFilled) { - // _geometryImpl._fills.Add(new Rectangle(bound)); + _geometryImpl._fills.Add(new Rectangle(bound)); } } From e04d8baeb169e82270cec526f6dc44f945ffec25 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:12:32 +0000 Subject: [PATCH 2/2] Automated JetBrains cleanup Co-authored-by: <+@users.noreply.github.com> --- .../Drawing/StreamGeometryImpl.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs b/src/Consolonia.Core/Drawing/StreamGeometryImpl.cs index 8c306730..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,7 +24,7 @@ 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); @@ -33,9 +32,11 @@ public StreamGeometryImpl() public IStreamGeometryImpl Clone() { var cloneGeometry = new StreamGeometryImpl(); - foreach (Line cloneLine in _strokes.Select(l => new Line(l.PStart, l.PEnd, this, transform: 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; + 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; } @@ -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)); } ///