Hello, I’m really new to this and having a hard time figure out how to make my colors cycle, or blink with random values if you will. They should change at a rate of 5 frames per second, which I think I’ve got right, but they are just static with no change. Please forgive the overdone commenting, it helps me learn what i’m doing.
float Width; //Assign Width (using cap W to avoid errors, and float in case /10 is not int)
float Height; //Assign Height (using cap H to avoid errors, and float in case /10 is not int)
float X1; //Assign X1 corner (float used again because of 'float to int error')
float Y1; //Assign Y1 corner (float used again because of 'float to int error')
float X2; //Assign X2 corner (float used again because of 'float to int error')
float Y2; //Assign Y2 corner (float used again because of 'float to int error')
void setup()
{//assume default corner mode (no entry)
size(640, 640); // sets window size
background(255); // sets background to white
frameRate(5); // reduce frame rate to reduce migraine chances :)
Width = width/10; //make sqaure width 1/10 of window height to work on any window size
Height = height/10; //make sqaure height 1/10 of window height to work on any window size
X1 = 0; //sets first X1 corner at origin
Y1 = 0; //sets first Y1 corner at origin
X2 = width - Width; //moves box
Y2 = 0;
}
void draw()
{
while(X1 < width && Y1 < height)
{
fill(random(256), random(256), random(256));
rect(X1, Y1, Width, Height);
X1 = X1 + Width;
Y1 = Y1 + Height;
}
while(X2 < width && Y2 < height)
{
fill(random(0, 255), random(0, 255), random(0, 255));
rect(X2, Y2, Width, Height);
X2 = X2 - Width;
Y2 = Y2 + Height;
}
}
please repair above code posting using </> Preformatted text from the editr header menu
your code run out and away with x,y
float Width; //Assign Width (using cap W to avoid errors, and float in case /10 is not int)
float Height; //Assign Height (using cap H to avoid errors, and float in case /10 is not int)
float X1; //Assign X1 corner (float used again because of ‘float to int error’)
float Y1; //Assign Y1 corner (float used again because of ‘float to int error’)
float X2; //Assign X2 corner (float used again because of ‘float to int error’)
float Y2; //Assign Y2 corner (float used again because of ‘float to int error’)
void setup() { //assume default corner mode (no entry)
size(640, 640); // sets window size
background(255); // sets background to white
frameRate(5); // reduce frame rate to reduce migraine chances :slight_smile:
Width = width/10; //make sqaure width 1/10 of window height to work on any window size
Height = height/10; //make sqaure height 1/10 of window height to work on any window size
reset();
}
void reset() {
X1 = 0; //sets first X1 corner at origin
Y1 = 0; //sets first Y1 corner at origin
X2 = width - Width; //moves box
Y2 = 0;
}
void draw() {
background(200,200,0);
reset();
while (X1 < width && Y1 < height) {
fill(random(256), random(256), random(256));
rect(X1, Y1, Width, Height);
X1 = X1 + Width;
Y1 = Y1 + Height;
}
while (X2 < width && Y2 < height) {
fill(random(0, 255), random(0, 255), random(0, 255));
rect(X2, Y2, Width, Height);
X2 = X2 - Width;
Y2 = Y2 + Height;
}
}
Thanks for the advice on how to post. I’m sure that’ll save some headaches for people helping in the future. And thanks for the ‘fix’. Quick question…what do you mean out and away? And again I’m new. Do we rate responses? Just want to help those who help me