Skip to content

Instantly share code, notes, and snippets.

@becojo
Last active December 28, 2015 16:19
Show Gist options
  • Save becojo/7528045 to your computer and use it in GitHub Desktop.
Save becojo/7528045 to your computer and use it in GitHub Desktop.
int square = 20;
int dw, dh, hw, hh, hs;
void setup() {
size(500, 500);
dw = width / square / 2;
dh = height / square / 2;
hw = width / 2;
hh = height / 2;
hs = square / 2;
strokeWeight(2);
noFill();
}
void draw() {
background(255);
int i, j;
int x, y;
float a, b;
float r = frameCount / -20.0;
float mx = hw - cos(r) * 100;
float my = hh - sin(r) * 100;
rect(mx, my, 1, 1);
for(i = 1; i < dw - 1; i++) {
beginShape();
for(j = 4; j < dh - 4; j++) {
x = square + i * 2 * square;
y = square + j * 2 * square;
r = atan2(my - y, mx - x);
a = cos(r) * square; // * (i - dw / 2);
b = sin(r) * square; // * (j - dw / 2);
//rect(x, y, square, square);
//rect(x + a, y + b, square, square);
//line(x, y, x + a, y + b);
//line(x, y + square, x + a, y + b + square);
//line(x + square, y, x + square + a, y + b);
//line(x + square, y + square, x + square + a, y + square + b);
vertex(x + a, y + b);
/*
beginShape();
vertex(x, y);
vertex(x + a, y + b);
vertex(x + a + square, y + b);
vertex(x + square, y);
vertex(x + square, y + square);
vertex(x + a + square, y + b + square);
vertex(x + a, y + b + square);
vertex(x, y + square);
endShape(CLOSE);
*/
}
endShape();
}
//saveFrame("frame-######.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment