Bitmap/Flood fill: Difference between revisions

Line 1,944:
 
PImage img;
int tolerance, start_time;
color fill_color;
boolean allowed;
Line 1,970:
 
void mousePressed() {
if (mouseButton == RIGHT) {
img.loadPixels();
img = loadImage("image.png");
flood(mouseX, mouseY);
} else {
img.updatePixels();
img.loadPixels();
allowed = true;
flood(mouseX, mouseY);
start_time = millis();
img.updatePixels();
allowed = true;
}
}
 
Line 2,010 ⟶ 2,013:
int pp = img.pixels[pixel_position(x, y)];
boolean test_tolerance = (abs(green(target_color)-green(pp)) < tolerance
&& abs( red(target_color)- red(pp)) < tolerance
&& abs( blue(target_color)- blue(pp)) < tolerance);
if (!test_tolerance) return false;
img.pixels[pixel_position(x, y)] = fill_color;
return true;
}</lang>
}
</lang>
 
==={{header|Processing Python mode}}===
47

edits