Skip to content

Instantly share code, notes, and snippets.

@elliptic-shiho
Created July 30, 2015 10:23
Show Gist options
  • Save elliptic-shiho/395fc90c298326c2fb71 to your computer and use it in GitHub Desktop.
Save elliptic-shiho/395fc90c298326c2fb71 to your computer and use it in GitHub Desktop.
My First Processing
float theta = 0;
float sh = 0;
float[] rotate(int a, int b) {
float c = cos(theta);
float s = sin(theta);
return mat(a, b, c, -s, s, c);
}
float[] mat(float a, float b, float A, float B, float C, float D) {
return new float[]{
a * A + b * B,
a * C + b * D
};
}
void setup () {
size(640, 480);
}
void draw() {
background(255);
color(0, 0, 0);
line(width/2, 0, width/2, height);
line(0, height/2, width, height/2);
int zero[] = {width/20, height/20};
color(255, 0, 0);
for(int i = zero[0] - 4; i < zero[0] + 5; i++) {
for(int j = zero[1] - 4; j < zero[1] + 5; j++) {
float v[] = rotate(10*(i - zero[0]), 10*(j - zero[1]));
ellipse((v[0] * (sh + 1) + zero[0] * 10), (v[1] * (sh + 1) + zero[1] * 10), 1, 1);
}
}
}
void mouseMoved() {
sh = mouseY / 250.0;
theta = mouseX / 50.0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment