Skip to content

Commit d244b89

Browse files
Remove unneeded clipper scaling
1 parent 3a50436 commit d244b89

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
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
/// Wrapper for clipper offset
108
/// </summary>
119
internal class ClipperOffset
1210
{
13-
// To make the floating point polygons compatible with clipper we have to scale them.
14-
private const float ScalingFactor = 1000F;
1511
private readonly PolygonOffsetter polygonClipperOffset;
1612

1713
/// <summary>
@@ -30,16 +26,16 @@ public ClipperOffset(float meterLimit = 2F, float arcTolerance = .25F)
3026
public ComplexPolygon Execute(float width)
3127
{
3228
PathsF solution = new();
33-
this.polygonClipperOffset.Execute(width * ScalingFactor, solution);
29+
this.polygonClipperOffset.Execute(width, solution);
3430

35-
var polygons = new Polygon[solution.Count];
31+
Polygon[] polygons = new Polygon[solution.Count];
3632
for (int i = 0; i < solution.Count; i++)
3733
{
3834
PathF pt = solution[i];
39-
var points = new PointF[pt.Count];
35+
PointF[] points = new PointF[pt.Count];
4036
for (int j = 0; j < pt.Count; j++)
4137
{
42-
points[j] = pt[j] / ScalingFactor;
38+
points[j] = pt[j];
4339
}
4440

4541
polygons[i] = new Polygon(points);
@@ -59,7 +55,7 @@ public void AddPath(ReadOnlySpan<PointF> pathPoints, JointStyle jointStyle, EndC
5955
PathF points = new(pathPoints.Length);
6056
for (int i = 0; i < pathPoints.Length; i++)
6157
{
62-
points.Add((Vector2)pathPoints[i] * ScalingFactor);
58+
points.Add(pathPoints[i]);
6359
}
6460

6561
this.polygonClipperOffset.AddPath(points, jointStyle, endCapStyle);

0 commit comments

Comments
 (0)