Last active
October 7, 2019 15:26
-
-
Save racecraftr/60036003d123c15cb9009b95ba312f72 to your computer and use it in GitHub Desktop.
make a cool cardioid!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initalize the variables | |
float r, b;// r is the radius, b defines how many lobes it has | |
float theta;// theta is the angle | |
// sets up the program | |
void setup() { | |
size(600, 600); | |
r = height * .25; | |
b = 3;// the number of lobes will always be b-1. this will produce 2 lobes* | |
theta = 0;// initializes theta* | |
background(0);// black background* | |
frameRate(1000);// sets the framerate* | |
pixelDensity(2); | |
} | |
// draws everything out | |
void draw() { | |
stroke(random(255), random(255), 255);// makes colorful dots * | |
strokeWeight(random(5));// the thickness of the stroke is up to 5 | |
pushMatrix();// pushes the grid to a certain point | |
translate(width/2, height/2);// makes (0,0) at the center of the canvas * | |
// the first xy coordinates | |
float x = r*sin(theta/1); | |
float y = r*cos(theta/1); | |
// the second xy coordinates, making it b times the original xy | |
float x2 = r*sin(b*theta); | |
float y2 = r*cos(b*theta); | |
// subtracts both from each other, making so that it produces a point at the xy coordinates: (r*sin((b-1)*theta), r*cos((b-1)*theta)) | |
point((x2-x)/1, (y2-y)/1);//* | |
theta+=0.5;//* | |
r = 90;//* | |
popMatrix(); | |
} | |
// * -> play around with these variables | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment