Browse Source

Ignore invalid gradient positions rather than throwing an error

There can be such cases where it fails to find intersection points for
a given position, especially when the polygon is small.

Such an input would result in an error previously, but now it renders
correctly.
pull/1007/head
Xavier Cho 7 years ago
parent
commit
6842408316
  1. 5
      src/ImageSharp.Drawing/Processing/PathGradientBrush.cs

5
src/ImageSharp.Drawing/Processing/PathGradientBrush.cs

@ -237,6 +237,11 @@ namespace SixLabors.ImageSharp.Processing
(Edge edge, Intersection? info) = this.FindIntersection(point, end);
if (!info.HasValue)
{
return Color.Transparent.ToPixel<TPixel>();
}
PointF intersection = info.Value.Point;
Vector4 edgeColor = edge.ColorAt(intersection);

Loading…
Cancel
Save