I would like to change every dark pixel of an image in moving bubbles, using a class.
after loading an image, I do a "for" sequence to get the current color of each pixel and convert it to a greyscale, and then I load my class. The bubble size is mapped to the greyscale value.
What isn't working is the vector part to make my "bubble" class move: I want all the bubbles to move in random directions, but they don't move at all.
I think I messed up with my vector variables inside the "for" sequence, but I can't figure out how to make this work... Any idea??
// Test the brightness against the threshold if (brightness(img.pixels[loc]) > threshold) { img.pixels[loc] = color(255); // White } else { // get current color color c = img.pixels[gridY*img.width+gridX]; // greyscale conversion int greyscale =round(red(c)*0.222+green(c)*0.707+blue(c)*0.071);
//map bubble size to greyscale value float r2 = map(greyscale, 0, 255, 25, 0); r2 = r2*0.5;
Vec3D origin = new Vec3D (posX, posY, 0);
//load class myBubble = new bubble (origin, r2, r2); myBubble.run(); } } } }
my "bubble" class :
class bubble {
float dimX = 0; float dimY = 0;
Vec3D loc = new Vec3D (0, 0, 0); Vec3D speed = new Vec3D(random(-2, 2), random(-2, 2), 0);