Bitmap/Flood fill: Difference between revisions
Content added Content deleted
Line 1,944: | Line 1,944: | ||
PImage img; |
PImage img; |
||
int tolerance |
int tolerance; |
||
color fill_color; |
color fill_color; |
||
boolean allowed; |
boolean allowed; |
||
Line 1,970: | Line 1,970: | ||
void mousePressed() { |
void mousePressed() { |
||
if (mouseButton == RIGHT) { |
|||
⚫ | |||
img = loadImage("image.png"); |
|||
⚫ | |||
} else { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
start_time = millis(); |
|||
⚫ | |||
⚫ | |||
} |
|||
} |
} |
||
Line 2,010: | Line 2,013: | ||
int pp = img.pixels[pixel_position(x, y)]; |
int pp = img.pixels[pixel_position(x, y)]; |
||
boolean test_tolerance = (abs(green(target_color)-green(pp)) < tolerance |
boolean test_tolerance = (abs(green(target_color)-green(pp)) < tolerance |
||
&& abs( red(target_color)- red(pp)) < tolerance |
&& abs( red(target_color)- red(pp)) < tolerance |
||
&& abs( blue(target_color)- blue(pp)) < tolerance); |
&& abs( blue(target_color)- blue(pp)) < tolerance); |
||
if (!test_tolerance) return false; |
if (!test_tolerance) return false; |
||
img.pixels[pixel_position(x, y)] = fill_color; |
img.pixels[pixel_position(x, y)] = fill_color; |
||
return true; |
return true; |
||
⚫ | |||
} |
|||
⚫ | |||
==={{header|Processing Python mode}}=== |
==={{header|Processing Python mode}}=== |