fading squares
in
Programming Questions
•
9 months ago
I am currently trying to build a script that allows for interactive squares. In setting up the functions for doing this my squares (5 x 5 squares centered within the window) have suddenly dropped off the screen. Could someone explain how this has happened? I can't figure it out. (i've only just started on processing)
If anyone has any pointers I'd be very grateful! Many thanks in advance
The code:
//VARIABLES
float xcoord;
float ycoord;
float division;
float xdivider;
float ydivider;
color start=color(0,0,0);
color finish;
float amt = 0.0;
//SETUP
void setup() {
size(600,600);
background(start);
finish = color(random(255),random(255),random(255));
division=6;
xdivider=width/division;
ydivider=height/division;
smooth();
strokeWeight(1.5);
rectMode(CENTER);
}
//DRAWING
void draw() {
amt+=.01;
if (amt >= 1) {
amt = 0.0;
start = finish;
finish = color(random(255),random(255),random(255));
}
background (lerpColor(start,finish,amt));
fill(255, 204);
for (xcoord=xdivider; xcoord<=width-xdivider; xcoord=xcoord+xdivider)
{
for (ycoord=ydivider; ycoord<=height-ydivider; ycoord=ycoord+ydivider)
{
}
//RECTANGLE
pushMatrix();
translate(xcoord, ycoord);
stroke(255);
rect( 0, 0, 50, 50 );
popMatrix();
}
}
1