Skip to content

Commit d07aeef

Browse files
Remove scaling from clipper
1 parent 7d8cc83 commit d07aeef

File tree

1 file changed

+7
-10
lines changed
  • src/ImageSharp.Drawing/Shapes/PolygonClipper

1 file changed

+7
-10
lines changed

src/ImageSharp.Drawing/Shapes/PolygonClipper/Clipper.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
using System.Numerics;
5-
64
namespace SixLabors.ImageSharp.Drawing.Shapes.PolygonClipper;
75

86
/// <summary>
97
/// Library to clip polygons.
108
/// </summary>
119
internal class Clipper
1210
{
13-
// To make the floating point polygons compatable with clipper we have to scale them.
14-
private const float ScalingFactor = 1000F;
11+
// To make the floating point polygons compatible with clipper we have to scale them.
1512
private readonly PolygonClipper polygonClipper;
1613

1714
/// <summary>
@@ -34,17 +31,17 @@ public IPath[] GenerateClippedShapes(ClippingOperation operation, IntersectionRu
3431
FillRule fillRule = rule == IntersectionRule.EvenOdd ? FillRule.EvenOdd : FillRule.NonZero;
3532
this.polygonClipper.Execute(operation, fillRule, closedPaths, openPaths);
3633

37-
var shapes = new IPath[closedPaths.Count + openPaths.Count];
34+
IPath[] shapes = new IPath[closedPaths.Count + openPaths.Count];
3835

3936
int index = 0;
4037
for (int i = 0; i < closedPaths.Count; i++)
4138
{
4239
PathF path = closedPaths[i];
43-
var points = new PointF[path.Count];
40+
PointF[] points = new PointF[path.Count];
4441

4542
for (int j = 0; j < path.Count; j++)
4643
{
47-
points[j] = path[j] / ScalingFactor;
44+
points[j] = path[j];
4845
}
4946

5047
shapes[index++] = new Polygon(points);
@@ -53,11 +50,11 @@ public IPath[] GenerateClippedShapes(ClippingOperation operation, IntersectionRu
5350
for (int i = 0; i < openPaths.Count; i++)
5451
{
5552
PathF path = openPaths[i];
56-
var points = new PointF[path.Count];
53+
PointF[] points = new PointF[path.Count];
5754

5855
for (int j = 0; j < path.Count; j++)
5956
{
60-
points[j] = path[j] / ScalingFactor;
57+
points[j] = path[j];
6158
}
6259

6360
shapes[index++] = new Polygon(points);
@@ -107,7 +104,7 @@ internal void AddPath(ISimplePath path, ClippingType clippingType)
107104
PathF points = new(vectors.Length);
108105
for (int i = 0; i < vectors.Length; i++)
109106
{
110-
points.Add((Vector2)vectors[i] * ScalingFactor);
107+
points.Add(vectors[i]);
111108
}
112109

113110
this.polygonClipper.AddPath(points, clippingType, !path.IsClosed);

0 commit comments

Comments
 (0)