Little Collor Changing Square | Skillshare Projects

Matt Punchman

You can't fake low-end torque.



Little Collor Changing Square

I like the lesson, but I like random colors more. 

Created a square who changes his color every 500 milli.

I'm sure there is a better way to write this:

Random numbers are the best kind of numbers.
Let's make a square, and paint it with a random color.
...maybe this color should change after a little while.

// setup some variables
color cOld;
int dTimer;

void setup(){
// build your world
size(200, 200);
// set your framerate
frameRate(24); // I like 24fps, sorry WETA.
// paint the Background Black as hope.


void draw(){

// color your shape (let's f' with the colors)
if( millis() - dTimer > 500){
color cNew = fadeColor(cOld);

// WTF is lerpColor?
color cLerp = lerpColor(cOld, cNew, 1);
fill( cLerp );
dTimer = millis();

// everything new is old again
cOld = cNew;

// You know what's cool? Squares.
rect(50, 50, 100, 100);

color fadeColor(color cOld){
color tempC = color( random(255),random(255),random(255) );
// kick out the Jams
return( tempC );


Please sign in or sign up to comment.