Changing source image in between a sequence
in
Programming Questions
•
1 year ago
I've got this Pointillism code, just wondering if there's a way to switch the image that is processed/referenced half way through the sequence:
// Learning Processing
// Daniel Shiffman
// Example 15-14: "Pointillism"
PImage img;
int pointillize = 15;
void setup() {
size(800,500);
img = loadImage("20.JPG");
background(255);
smooth();
}
void draw() {
// Pick a random point
int x = int(random(img.width));
int y = int(random(img.height));
int loc = x + y*img.width;
// Look up the RGB color in the source image
loadPixels();
float r = red(img.pixels[loc]);
float g = green(img.pixels[loc]);
float b = blue(img.pixels[loc]);
// Back to shapes! Instead of setting a pixel, we use the color from a pixel to draw a circle.
noStroke();
fill(r,g,b,90);
rect(x,y,pointillize,pointillize);
saveFrame("/output/seq-####.jpg");
}
1