|
|
@ -94,7 +94,8 @@ namespace ImageSharp.Drawing.Shapes |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (inside) { |
|
|
if (inside) |
|
|
|
|
|
{ |
|
|
return -dist; |
|
|
return -dist; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -154,7 +155,6 @@ namespace ImageSharp.Drawing.Shapes |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ExtractOutlines(ClipperLib.PolyNode tree, List<IShape> shapes) |
|
|
private void ExtractOutlines(ClipperLib.PolyNode tree, List<IShape> shapes) |
|
|
{ |
|
|
{ |
|
|
if (tree.Contour.Any()) |
|
|
if (tree.Contour.Any()) |
|
|
@ -184,18 +184,16 @@ namespace ImageSharp.Drawing.Shapes |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The source.</param>
|
|
|
/// <param name="source">The source.</param>
|
|
|
/// <param name="target">The target.</param>
|
|
|
/// <param name="target">The target.</param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns>true if the 2 shapes bounding boxes overlap.</returns>
|
|
|
private bool OverlappingBoundingBoxes(IShape source, IShape target) |
|
|
private bool OverlappingBoundingBoxes(IShape source, IShape target) |
|
|
{ |
|
|
{ |
|
|
return source.Bounds.Intersects(target.Bounds); |
|
|
return source.Bounds.Intersects(target.Bounds); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void FixAndSetShapes(IShape[] outlines, IShape[] holes) |
|
|
private void FixAndSetShapes(IShape[] outlines, IShape[] holes) |
|
|
{ |
|
|
{ |
|
|
// if any outline doesn't overlap another shape then we don't have to bother with sending them through clipper
|
|
|
// if any outline doesn't overlap another shape then we don't have to bother with sending them through clipper
|
|
|
// as sending then though clipper will turn them into generic polygons and loose thier shape specific optimisations
|
|
|
// as sending then though clipper will turn them into generic polygons and loose thier shape specific optimisations
|
|
|
|
|
|
|
|
|
int outlineLength = outlines.Length; |
|
|
int outlineLength = outlines.Length; |
|
|
int holesLength = holes?.Length ?? 0; |
|
|
int holesLength = holes?.Length ?? 0; |
|
|
bool[] overlappingOutlines = new bool[outlineLength]; |
|
|
bool[] overlappingOutlines = new bool[outlineLength]; |
|
|
@ -210,7 +208,7 @@ namespace ImageSharp.Drawing.Shapes |
|
|
// skip the bounds check if they are already tested
|
|
|
// skip the bounds check if they are already tested
|
|
|
if (overlappingOutlines[i] == false || overlappingOutlines[j] == false) |
|
|
if (overlappingOutlines[i] == false || overlappingOutlines[j] == false) |
|
|
{ |
|
|
{ |
|
|
if (OverlappingBoundingBoxes(outlines[i], outlines[j])) |
|
|
if (this.OverlappingBoundingBoxes(outlines[i], outlines[j])) |
|
|
{ |
|
|
{ |
|
|
overlappingOutlines[i] = true; |
|
|
overlappingOutlines[i] = true; |
|
|
overlappingOutlines[j] = true; |
|
|
overlappingOutlines[j] = true; |
|
|
@ -223,7 +221,7 @@ namespace ImageSharp.Drawing.Shapes |
|
|
{ |
|
|
{ |
|
|
if (overlappingOutlines[i] == false || overlappingHoles[k] == false) |
|
|
if (overlappingOutlines[i] == false || overlappingHoles[k] == false) |
|
|
{ |
|
|
{ |
|
|
if (OverlappingBoundingBoxes(outlines[i], holes[k])) |
|
|
if (this.OverlappingBoundingBoxes(outlines[i], holes[k])) |
|
|
{ |
|
|
{ |
|
|
overlappingOutlines[i] = true; |
|
|
overlappingOutlines[i] = true; |
|
|
overlappingHoles[k] = true; |
|
|
overlappingHoles[k] = true; |
|
|
@ -263,7 +261,8 @@ namespace ImageSharp.Drawing.Shapes |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.shapes = newShapes.ToArray(); |
|
|
this.shapes = newShapes.ToArray(); |
|
|
}else |
|
|
} |
|
|
|
|
|
else |
|
|
{ |
|
|
{ |
|
|
this.shapes = outlines; |
|
|
this.shapes = outlines; |
|
|
} |
|
|
} |
|
|
|