-
-
Save jkwok91/930a66ad4296ab18b65c to your computer and use it in GitHub Desktop.
why haven't i made one of these already
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
rect moving | |
*/ | |
float theta; | |
int side; | |
void setup() { | |
size(300, 300); | |
background(255); | |
side = 20; | |
} | |
void draw() { | |
background(255); | |
for (int h = 0; h < height/side; h++) { | |
for (int w = 0; w < width/side; w++) { | |
makeT(w, h); | |
} | |
} | |
theta += 0.1; | |
} | |
void makeT(int w, int h) { | |
pushMatrix(); | |
translate(w*(side+5), h*(side+5)); | |
rotate(theta); | |
float delta = dist(mouseX, mouseY, w, h); | |
color c = getColor(mouseX+delta); | |
fill(c); | |
rect(-side/2, -side/2, side, side); | |
popMatrix(); | |
} | |
/* | |
resources: | |
http://krazydad.com/tutorials/makecolors.php | |
*/ | |
color getColor(float i) { | |
int center = 205; //pastelly | |
int widthh = 55; | |
double frequency = .3; | |
int red = (int)Math.ceil(Math.sin(frequency*i+0) * widthh + center); | |
int green = (int)Math.ceil(Math.sin(frequency*i+2) * widthh + center); | |
int blue = (int)Math.ceil(Math.sin(frequency*i+4) * widthh + center); | |
return color(red,green,blue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment