From 450b64ca10c4d45a66b821336a21dde73fff647e Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 16 Jan 2010 21:58:45 +0000 Subject: [PATCH] Fixed a bug in gradrect xor lines drawing where they could sometime get to draw over the menu or even outside the screen. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1265 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- operatio.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/operatio.c b/operatio.c index c349af1e..d528a2c1 100644 --- a/operatio.c +++ b/operatio.c @@ -3404,10 +3404,12 @@ void Grad_rectangle_0_5(void) height = abs(rby - ray); // Check if the rectangle is not fully outside the picture - if (Min(rax, rbx) > Main_image_width || Min(ray, rby) > Main_image_height) + if (Min(rax, rbx) > Main_image_width // Rectangle at right of picture + || Min(ray, rby) > Main_image_height // Rectangle below picture + || Min(ray, rby) - 1 - Main_offset_Y > Menu_Y ) // Rectangle below viewport { - Operation_pop(&rby); // reset the stack - return; // cancel the operation + Operation_pop(&rby); // reset the stack + return; // cancel the operation } // Handle clipping @@ -3426,20 +3428,22 @@ void Grad_rectangle_0_5(void) Min(ray, rby) - Main_offset_Y, width - offset_width); // If not, this line is out of the picture so there is no need to draw it - if (offset_height == 0) + if (offset_height == 0 || Max(ray, rby) - 1 > Menu_Y + Main_offset_Y ) { Horizontal_XOR_line(Min(rax, rbx) - Main_offset_X, Max(ray, rby) - 1 - Main_offset_Y, width - offset_width); } - Vertical_XOR_line(Min(rax, rbx)-Main_offset_X, Min(ray, rby) - - Main_offset_Y, height - offset_height); + if (height > offset_height) { + Vertical_XOR_line(Min(rax, rbx)-Main_offset_X, Min(ray, rby) + - Main_offset_Y, height - offset_height); - if (offset_width == 0) - { - Vertical_XOR_line(Max(rax, rbx) - 1 - Main_offset_X, Min(ray, rby) - - Main_offset_Y, height - offset_height); - } + if (offset_width == 0) + { + Vertical_XOR_line(Max(rax, rbx) - 1 - Main_offset_X, Min(ray, rby) + - Main_offset_Y, height - offset_height); + } + } Update_rect(Min(rax, rbx) - Main_offset_X, Min(ray, rby) - Main_offset_Y, width + 1 - offset_width, height + 1 - offset_height);