From d36cf2d14af96b097e45e8a60201c9ad86128ac3 Mon Sep 17 00:00:00 2001 From: Kiri Jolly Date: Wed, 23 Dec 2020 20:06:02 -0800 Subject: [PATCH] Fixed writing pixels out of bounds when using the gradient ellipse (corners) tool. Gradient ellipse (corners) tool had no clipping code, and would draw off the bottom or right edge of the image. Clipping code has been added, similar to other tools. --- src/graph.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/graph.c b/src/graph.c index d5c005fa..47800d51 100644 --- a/src/graph.c +++ b/src/graph.c @@ -2513,6 +2513,16 @@ void Draw_grad_inscribed_ellipse(short x1, short y1, short x2, short y2, short s if (Gradient_total_range==0) Gradient_total_range=1; + // Apply limits to final dimensions to draw. + if (left < Limit_left) + left = Limit_left; + if (top < Limit_top) + top = Limit_top; + if (right > Limit_right) + right = Limit_right; + if (bottom > Limit_bottom) + bottom = Limit_bottom; + for (y_pos = top; y_pos <= bottom; y_pos++) { long dbl_y = 2*y_pos - dbl_center_y;