From 68424083165e62e341e4e464c02664b8b66b75d2 Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Thu, 12 Sep 2019 12:55:28 +0900 Subject: [PATCH] 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. --- src/ImageSharp.Drawing/Processing/PathGradientBrush.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ImageSharp.Drawing/Processing/PathGradientBrush.cs b/src/ImageSharp.Drawing/Processing/PathGradientBrush.cs index 553ed181c..636551b64 100644 --- a/src/ImageSharp.Drawing/Processing/PathGradientBrush.cs +++ b/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(); + } + PointF intersection = info.Value.Point; Vector4 edgeColor = edge.ColorAt(intersection);