Last active
December 23, 2015 18:59
-
-
Save ohmygodwin/6680004 to your computer and use it in GitHub Desktop.
Week III of ICM
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
int count = 0; | |
SquareSpin[] square = new SquareSpin[300]; | |
void setup() { | |
size(662, 300); | |
for (int a = -320; a <= 320; a = a + 40) { | |
for (int b = -320; b <= 320; b = b + 40) { | |
square[count] = new SquareSpin(a, b); | |
count++; | |
} | |
} | |
} | |
void draw() { | |
background(255); | |
pushMatrix(); | |
translate(width/128, height/128); | |
int f = 0; | |
float d = map(mouseX, 0, width, 5, 100); | |
while (f < count) { | |
square[f].go(); | |
square[f].show(); | |
square[f].updateSize(d); | |
f++; | |
} | |
popMatrix(); | |
} | |
class SquareSpin { | |
float speed = random(-0.05, 0.05); | |
float angle = 0; | |
float d = 20; | |
int x, y; | |
SquareSpin(int xpos, int ypos) { | |
x = xpos; | |
y = ypos; | |
} | |
void go() { | |
angle += speed; | |
} | |
void show() { | |
pushMatrix(); | |
translate(((width/2)+x), ((height/2)+y)); | |
rotate(angle); | |
rectMode(CENTER); | |
noFill(); | |
rect(x/128, y/128, d, d); popMatrix(); | |
} | |
void updateSize(float size) { | |
d = size; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment