Can't figure out what's wrong with this:
in
Programming Questions
•
1 year ago
This code is supposed to step through the x and y coordinates of a picture, fifty pixels at a time, and draw a box of random size at these locations. Can't get it to work. Can't see what's wrong.
size (4000, 2000);
loadPixels();
int step = 50;
for (int x = step; x == (width - step); x = x + step)
{
for (int y = step; y == (height - step); y = y + step)
{
int boxx = int(random(step));
int boxy = int(random(step));
color c = color(random(255), random(255), random(255), random(100));
//print (c + " ");
int pix = y * width + x;
for (int p = 0; p < boxx; p++)
{
pix = pix + p;
for (int q = 0; q < boxy; q++)
{
pix = pix + q * width;
pixels[pix] = color (c);
}
}
}
}
updatePixels();
loadPixels();
int step = 50;
for (int x = step; x == (width - step); x = x + step)
{
for (int y = step; y == (height - step); y = y + step)
{
int boxx = int(random(step));
int boxy = int(random(step));
color c = color(random(255), random(255), random(255), random(100));
//print (c + " ");
int pix = y * width + x;
for (int p = 0; p < boxx; p++)
{
pix = pix + p;
for (int q = 0; q < boxy; q++)
{
pix = pix + q * width;
pixels[pix] = color (c);
}
}
}
}
updatePixels();
1