brush.c: reindent Draw_paintbrush()
This commit is contained in:
parent
860b75d608
commit
8a7bd06d44
194
src/brush.c
194
src/brush.c
@ -286,7 +286,7 @@ void Draw_paintbrush(short x,short y,byte color)
|
|||||||
byte old_color;
|
byte old_color;
|
||||||
|
|
||||||
if ((Main.backups->Pages->Image_mode == IMAGE_MODE_MODE5
|
if ((Main.backups->Pages->Image_mode == IMAGE_MODE_MODE5
|
||||||
|| Main.backups->Pages->Image_mode == IMAGE_MODE_RASTER) && Main.current_layer < 4)
|
|| Main.backups->Pages->Image_mode == IMAGE_MODE_RASTER) && Main.current_layer < 4)
|
||||||
{
|
{
|
||||||
// Flood-fill the enclosing area
|
// Flood-fill the enclosing area
|
||||||
if (x<Main.image_width && y<Main.image_height && x>= 0 && y >= 0
|
if (x<Main.image_width && y<Main.image_height && x>= 0 && y >= 0
|
||||||
@ -298,109 +298,109 @@ void Draw_paintbrush(short x,short y,byte color)
|
|||||||
short min_x,width,min_y,height;
|
short min_x,width,min_y,height;
|
||||||
short xx,yy;
|
short xx,yy;
|
||||||
|
|
||||||
if (Main.backups->Pages->Image_mode == IMAGE_MODE_MODE5)
|
if (Main.backups->Pages->Image_mode == IMAGE_MODE_MODE5)
|
||||||
{
|
{
|
||||||
// determine area
|
// determine area
|
||||||
switch(Main.current_layer)
|
switch(Main.current_layer)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
// Full layer
|
// Full layer
|
||||||
min_x=0;
|
min_x=0;
|
||||||
min_y=0;
|
min_y=0;
|
||||||
width=Main.image_width;
|
width=Main.image_width;
|
||||||
height=Main.image_height;
|
height=Main.image_height;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
// Line
|
// Line
|
||||||
min_x=0;
|
min_x=0;
|
||||||
min_y=y;
|
min_y=y;
|
||||||
width=Main.image_width;
|
width=Main.image_width;
|
||||||
height=1;
|
height=1;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// Segment
|
// Segment
|
||||||
min_x=x / 48 * 48;
|
min_x=x / 48 * 48;
|
||||||
min_y=y;
|
min_y=y;
|
||||||
width=48;
|
width=48;
|
||||||
height=1;
|
height=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int prev_x;
|
int prev_x;
|
||||||
// Raster mode
|
// Raster mode IMAGE_MODE_RASTER
|
||||||
// No matter what, you can always edit only 1 line at a time here, and you will always
|
// No matter what, you can always edit only 1 line at a time here, and you will always
|
||||||
// draw on "nops" boundaries (8 pixels in mode 1)
|
// draw on "nops" boundaries (8 pixels in mode 1)
|
||||||
height=1;
|
height=1;
|
||||||
min_y=y;
|
min_y=y;
|
||||||
min_x=x / 8 * 8;
|
min_x=x / 8 * 8;
|
||||||
width = 8;
|
width = 8;
|
||||||
|
|
||||||
// ????????
|
// ????????
|
||||||
// ^
|
// ^
|
||||||
// A
|
// A
|
||||||
|
|
||||||
// First look for the previous span to see if it is the same color
|
// First look for the previous span to see if it is the same color
|
||||||
prev_x = min_x - 8;
|
prev_x = min_x - 8;
|
||||||
|
|
||||||
old_color = Read_pixel_from_current_screen(prev_x, y);
|
old_color = Read_pixel_from_current_screen(prev_x, y);
|
||||||
|
|
||||||
if (old_color == color) {
|
if (old_color == color) {
|
||||||
// aaaA????
|
// aaaA????
|
||||||
// ^
|
// ^
|
||||||
// A
|
// A
|
||||||
// We are just making the previous span larger
|
// We are just making the previous span larger
|
||||||
width = 8;
|
width = 8;
|
||||||
while ((min_x >= 0) && (width < 32)
|
while ((min_x >= 0) && (width < 32)
|
||||||
&& (Read_pixel_from_current_screen(min_x, y) == color))
|
&& (Read_pixel_from_current_screen(min_x, y) == color))
|
||||||
{
|
{
|
||||||
min_x -= 8;
|
min_x -= 8;
|
||||||
width += 8;
|
width += 8;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ???B????
|
// ???B????
|
||||||
// ^
|
// ^
|
||||||
// A
|
// A
|
||||||
// We are creating a new span. We need to check if the previous span is still large
|
// We are creating a new span. We need to check if the previous span is still large
|
||||||
// enough to be allowed. If it is less than 32 pixels, there is no way to render it
|
// enough to be allowed. If it is less than 32 pixels, there is no way to render it
|
||||||
// on the real hardware (this is the time the OUT instruction to change the palette
|
// on the real hardware (this is the time the OUT instruction to change the palette
|
||||||
// needs)
|
// needs)
|
||||||
while ((min_x - prev_x < 48)
|
while ((min_x - prev_x < 48)
|
||||||
&& (prev_x <= 0 || old_color == Read_pixel_from_current_screen(prev_x, y)))
|
&& (prev_x <= 0 || old_color == Read_pixel_from_current_screen(prev_x, y)))
|
||||||
{
|
{
|
||||||
prev_x -= 8;
|
prev_x -= 8;
|
||||||
}
|
}
|
||||||
prev_x += 8;
|
prev_x += 8;
|
||||||
|
|
||||||
// CBBB????
|
// CBBB????
|
||||||
// p ^
|
// p ^
|
||||||
// A
|
// A
|
||||||
// The previous span is too small, so eat it
|
// The previous span is too small, so eat it
|
||||||
if (min_x - prev_x < 32) {
|
if (min_x - prev_x < 32) {
|
||||||
width += min_x - prev_x;
|
width += min_x - prev_x;
|
||||||
min_x = prev_x;
|
min_x = prev_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width < 32)
|
if (width < 32)
|
||||||
width = 32;
|
width = 32;
|
||||||
}
|
}
|
||||||
// Now, we also need to check if the next span is still large enough, as we are going to
|
// Now, we also need to check if the next span is still large enough, as we are going to
|
||||||
// remove 8 pixels from it. If it is not, we just replace it with the current color and
|
// remove 8 pixels from it. If it is not, we just replace it with the current color and
|
||||||
// let the user figure out how to reinsert it without breaking everything.
|
// let the user figure out how to reinsert it without breaking everything.
|
||||||
prev_x = min_x + width;
|
prev_x = min_x + width;
|
||||||
old_color = Read_pixel_from_current_screen(prev_x, y);
|
old_color = Read_pixel_from_current_screen(prev_x, y);
|
||||||
if (old_color != color) {
|
if (old_color != color) {
|
||||||
while ((prev_x - (min_x + width) < 40)
|
while ((prev_x - (min_x + width) < 40)
|
||||||
&& (prev_x > Main.image_width || old_color == Read_pixel_from_current_screen(prev_x, y)))
|
&& (prev_x > Main.image_width || old_color == Read_pixel_from_current_screen(prev_x, y)))
|
||||||
{
|
{
|
||||||
prev_x += 8;
|
prev_x += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_x - (min_x + width) < 32)
|
if (prev_x - (min_x + width) < 32)
|
||||||
width = prev_x - min_x;
|
width = prev_x - min_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Clip the bottom edge.
|
// Clip the bottom edge.
|
||||||
// (Necessary if image height is not a multiple)
|
// (Necessary if image height is not a multiple)
|
||||||
if (min_y+height>=Main.image_height)
|
if (min_y+height>=Main.image_height)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user