Hello,
I’m new to processing and working with Daniel Shiffman’s book.
I fisrt wanted to display an image pixel by pixel, from top left to bottom right.I think I succeded in what I wanted (making appear an image pixel by pixel or square by square). Now I want to do something more complex but I can’t figure out wich loop to use.
I want this (like a cascade)
First turn: x = 0 and y = 0
pixel appears
Second turn: (x=0 and y=1) and (x = 1 and y = 0
)
Third turn: (x = 0 and y = 2) and (x = 1 and y = 1) and (x=2 and y=0) 4th turn : (x = 0 and y = 3)
and (x = 1 and y = 2) and (x=2 and y=1) and (x=3 and y=0)
And so on…
That’s the code I have when it’s appearing square by square :
PImage soleil;
int x=0;
int y=0;
void setup() {
size(1228,1818);
soleil = loadImage("img1.JPG");
background(0);
frameRate(100000);
}
void draw() {
int loc= x+y*soleil.width;
soleil.loadPixels();
int c = soleil.pixels[loc];
fill(c);
noStroke();
rect(y,x,10,10);
updatePixels();
x=x+10;
if(x>soleil.width-1){
y=y+10;
x=0;
}
}
I suppose I need a dobble loop, but I tried several things with no success.
Thank’s a lot!
Ilalande