Skip to content

Commit 7c23b33

Browse files
committed
Add workaround for Out of memory exception in DrawEllipse for small circles
1 parent 07ea7e9 commit 7c23b33

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

solution/GraphicalDebugging/Viewport.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ public override void DrawOne(Drawer drawer, float translation, bool fill, bool d
550550

551551
float cx = c_rel.X - r + translation;
552552
float cy = c_rel.Y - r;
553-
float d = r * 2;
553+
// DrawEllipse throws 'Out of memory' exception for sizes around 0.05
554+
float d = Math.Max(r * 2, 1.0f);
554555

555556
if (!drawDots || Math.Abs(translation) < 0.001)
556557
{
@@ -565,6 +566,7 @@ public override void DrawOne(Drawer drawer, float translation, bool fill, bool d
565566
{
566567
drawer.graphics.FillEllipse(drawer.brush, cx, cy, d, d);
567568
}
569+
568570
}
569571

570572
protected PointF c_rel;

0 commit comments

Comments
 (0)