Skip to content

Commit f27a95a

Browse files
Delete unused internal Distance code
1 parent 42054e0 commit f27a95a

4 files changed

Lines changed: 0 additions & 124 deletions

File tree

src/ImageSharp.Drawing/Shapes/InternalPath.cs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -117,47 +117,6 @@ private InternalPath(PointData[] points, bool isClosedPath)
117117
/// </summary>
118118
public int PointCount => this.points.Length;
119119

120-
/// <summary>
121-
/// Calculates the distance from the path.
122-
/// </summary>
123-
/// <param name="point">The point.</param>
124-
/// <returns>Returns the distance from the path</returns>
125-
public PointInfo DistanceFromPath(PointF point)
126-
{
127-
PointInfoInternal internalInfo = default;
128-
internalInfo.DistanceSquared = float.MaxValue; // Set it to max so that CalculateShorterDistance can reduce it back down
129-
130-
int polyCorners = this.points.Length;
131-
132-
if (!this.closedPath)
133-
{
134-
polyCorners--;
135-
}
136-
137-
int closestPoint = 0;
138-
for (int i = 0; i < polyCorners; i++)
139-
{
140-
int next = i + 1;
141-
if (this.closedPath && next == polyCorners)
142-
{
143-
next = 0;
144-
}
145-
146-
if (this.CalculateShorterDistance(this.points[i].Point, this.points[next].Point, point, ref internalInfo))
147-
{
148-
closestPoint = i;
149-
}
150-
}
151-
152-
return new PointInfo
153-
{
154-
DistanceAlongPath = this.points[closestPoint].TotalLength + Vector2.Distance(this.points[closestPoint].Point, internalInfo.PointOnLine),
155-
DistanceFromPath = MathF.Sqrt(internalInfo.DistanceSquared),
156-
SearchPoint = point,
157-
ClosestPointOnPath = internalInfo.PointOnLine
158-
};
159-
}
160-
161120
/// <summary>
162121
/// Based on a line described by <paramref name="start" /> and <paramref name="end" />
163122
/// populates a buffer for all points on the path that the line intersects.

src/ImageSharp.Drawing/Shapes/PointInfo.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/ImageSharp.Drawing.Tests/Drawing/Paths/ShapeRegionTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ public abstract class MockPath : IPath, IPathInternals
1919

2020
public abstract SegmentInfo PointAlongPath(float distanceAlongPath);
2121

22-
public abstract PointInfo Distance(PointF point);
23-
2422
public abstract IEnumerable<ISimplePath> Flatten();
2523

2624
public abstract bool Contains(PointF point);

tests/ImageSharp.Drawing.Tests/Shapes/InternalPathTests.cs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -85,37 +85,6 @@ private static InternalPath Create(PointF location, SizeF size, bool closed = tr
8585
},
8686
};
8787

88-
public static TheoryData<TestPoint, float, float> PathDistanceTheoryData { get; }
89-
= new TheoryData<TestPoint, float, float>
90-
{
91-
{ new PointF(0, 0), 0f, 0f },
92-
{ new PointF(1, 0), 0f, 1f },
93-
{ new PointF(9, 0), 0f, 9f },
94-
{ new PointF(10, 0), 0f, 10f },
95-
{ new PointF(10, 1), 0f, 11f },
96-
{ new PointF(10, 9), 0f, 19f },
97-
{ new PointF(10, 10), 0f, 20f },
98-
{ new PointF(9, 10), 0f, 21f },
99-
{ new PointF(1, 10), 0f, 29f },
100-
{ new PointF(0, 10), 0f, 30f },
101-
{ new PointF(0, 9), 0f, 31f },
102-
{ new PointF(0, 1), 0f, 39f },
103-
{ new PointF(4, 3), 3f, 4f },
104-
{ new PointF(3, 4), 3f, 36f },
105-
{ new PointF(-1, 0), 1f, 0f },
106-
{ new PointF(1, -1), 1f, 1f },
107-
{ new PointF(9, -1), 1f, 9f },
108-
{ new PointF(11, 0), 1f, 10f },
109-
{ new PointF(11, 1), 1f, 11f },
110-
{ new PointF(11, 9), 1f, 19f },
111-
{ new PointF(11, 10), 1f, 20f },
112-
{ new PointF(9, 11), 1f, 21f },
113-
{ new PointF(1, 11), 1f, 29f },
114-
{ new PointF(-1, 10), 1f, 30f },
115-
{ new PointF(-1, 9), 1f, 31f },
116-
{ new PointF(-1, 1), 1f, 39f },
117-
};
118-
11988
[Theory]
12089
[MemberData(nameof(PointInPolygonTheoryData))]
12190
public void PointInPolygon(TestPoint location, TestSize size, TestPoint point, bool isInside)
@@ -155,25 +124,6 @@ public void PointOnPath(float distance, float expectedX, float expectedY, float
155124
Assert.Equal(expectedAngle, point.Angle, 4);
156125
}
157126

158-
[Theory]
159-
[MemberData(nameof(PathDistanceTheoryData))]
160-
public void DistanceFromPath_Path(TestPoint point, float expectedDistance, float alongPath)
161-
{
162-
InternalPath shape = Create(new PointF(0, 0), new Size(10, 10));
163-
PointInfo info = shape.DistanceFromPath(point);
164-
Assert.Equal(expectedDistance, info.DistanceFromPath);
165-
Assert.Equal(alongPath, info.DistanceAlongPath);
166-
}
167-
168-
[Fact]
169-
public void DistanceFromPath_Path_Closed()
170-
{
171-
InternalPath shape = Create(new PointF(0, 0), new Size(10, 10), false);
172-
PointInfo info = shape.DistanceFromPath(new PointF(5, 5));
173-
Assert.Equal(5, info.DistanceFromPath);
174-
Assert.Equal(5, info.DistanceAlongPath);
175-
}
176-
177127
[Fact]
178128
public void Intersections_buffer()
179129
{

0 commit comments

Comments
 (0)