@@ -16,7 +16,14 @@ public class EllipseData : ShapeData
public override void Rasterize(DrawingSurface drawingSurface)
{
- using ChunkyImage img = new ChunkyImage(new VecI((int)Radius.X * 2, (int)Radius.Y * 2));
+ var imageSize = new VecI((int)Radius.X * 2, (int)Radius.Y * 2) + (VecI)Center;
+
+ if (imageSize.HasNegativeComponent())
+ {
+ return;
+ }
+ using ChunkyImage img = new ChunkyImage(imageSize);
RectI rect = new RectI((int)Center.X - (int)Radius.X, (int)Center.Y - (int)Radius.Y, (int)Radius.X * 2, (int)Radius.Y * 2);
img.EnqueueDrawEllipse(rect, StrokeColor, FillColor, StrokeWidth);
@@ -86,6 +86,8 @@ public struct VecI : IEquatable<VecI>, IComparable<VecI>
return new VecI(Math.Clamp(X, rect.Left, rect.Right), Math.Clamp(Y, rect.Top, rect.Bottom));
}
+ public bool HasNegativeComponent() => X < 0 || Y < 0;
public byte[] ToByteArray()
var data = new byte[sizeof(int) * 2];