Skip to content

Instantly share code, notes, and snippets.

@koji
Created December 29, 2016 21:38
Show Gist options
  • Save koji/b3fd9fb6ed642258a591b9dbc63ba0c5 to your computer and use it in GitHub Desktop.
Save koji/b3fd9fb6ed642258a591b9dbc63ba0c5 to your computer and use it in GitHub Desktop.
PImage img;
float m,t;
void setup() {
size(500, 500);
noFill();
stroke(255);
strokeWeight(2);
m=0.0;
t=0.0;
img = loadImage("formular.png");
image(img, width/2, 0);
}
void draw() {
background(0);
fill(random(255),random(255),random(255));
translate(width/2, height/2);
beginShape();
for (float theta =0; theta <= 2*PI; theta += 0.01) {
float rad = r(theta,
2, // a
2, // b
m, // m
random(3), // n1
sin(t) * 2 + 0.5, // n2
cos(t)) * 2 + 0.5 ; // n3
float x = rad * cos(theta)*50;
float y = rad * sin(theta)*50;
vertex(x,y);
}
endShape();
m += 0.1;
t += 0.1;
}
float r(float theta, float a, float b, float m, float n1, float n2, float n3) {
return pow(pow(abs(cos(m*theta/4.0))/a, n2)+pow(abs(sin(m*theta/4.0))/b, n3),-1.0/n1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment