Skip to content

Instantly share code, notes, and snippets.

@somecho
Created April 30, 2020 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somecho/d19f9f46707c3ae06e0b24e9d5a72b32 to your computer and use it in GitHub Desktop.
Save somecho/d19f9f46707c3ae06e0b24e9d5a72b32 to your computer and use it in GitHub Desktop.
//CIRCULAR MATRIX TRANSFORMATIONS
//SAMUEL CHO
//2020
// ------------------------------
float numLines = 360.0;
float arcSize = 360.0 / numLines;
float lineStart = -50;
float lineEnd = 50;
float translateHeight = -50;
float rotateOffset = 90;
float globalRotationSpeed = 1;
float localRotationSpeed = 1;
float opacity = 120;
float t;
float globalAngle;
float localAngle;
void setup(){
size(1024,720,P2D);
stroke(255,opacity);
}
void update(){
t = millis()/1000.0;
localAngle += localRotationSpeed;
globalAngle += globalRotationSpeed;
}
void draw(){
update();
background(0);
push();
translate(width/2, height/2);
for(int i = 0; i < numLines; i++){
push();
rotate(radians(arcSize*i+globalAngle));
translate(0,translateHeight);
push();
rotate(radians(rotateOffset*i+localAngle));
line(0,lineStart,0,lineEnd);
pop();
pop();
}
pop();
}
void keyPressed(){
//Press R to randomize values
if( key == 'r'){
randomize();
}
}
void randomize(){
numLines = random(180,360);
arcSize = 360 / numLines;
lineStart = random( -height/2);
lineEnd = random(height/2);
translateHeight = random(-height/2);
rotateOffset = random(180);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment