Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (55 sloc) 1.23 KB
void setup()
{
size(250, 250);
noStroke();
frameRate(24);
}
int boxsize = 20;
int spacing = boxsize + 10;
int boxcount = ceil(width / spacing) + 1;
int halo = 8;
int tx = 0, ty = 0;
int angleRange = 200;
int angle = 0;
int defaultBg = 120;
int bg = defaultBg;
void draw()
{
background(bg);
rectMode(CENTER);
translate(tx + (spacing >> 1), ty + (spacing >> 1));
for (x = -1; x < boxcount; x++) {
int shade = 255;
for (y = -1; y < boxcount; y++) {
pushMatrix();
translate(x * spacing, y * spacing);
rotate(TWO_PI * (angle / angleRange));
for (i = 0; i < halo; i+= 3) {
fill(255, 100 + 10 * i);
rect(0, 0, boxsize + (halo - i), boxsize + (halo - i));
}
fill(shade);
rect(0, 0, boxsize, boxsize);
popMatrix();
shade -= 10;
}
}
angle = (angle + 1) % angleRange;
}
int mdx, mdy, mdtx, mdty;
void mousePressed() {
mdx = mouseX;
mdy = mouseY;
mdtx = tx;
mdty = ty;
bg = 0;
}
void mouseReleased() {
bg = defaultBg;
}
void mouseDragged() {
int deltax = mouseX - mdx;
int deltay = mouseY - mdy;
tx = (mdtx + deltax) % spacing;
ty = (mdty + deltay) % spacing;
}
Jump to Line
Something went wrong with that request. Please try again.