String st = "Polar: r = 200 * sin( 4 / 13 * θ)";
int l = 500;
PVector p0 = new PVector(l / 2, l / 2);
float theta = 2*PI;
color cl = #E61C64;
int value;
void setup(){
smooth();
size(l, l);
background(255);
fill(0, 102, 153);
text(st, 25, l-25);
line(0, l / 2, l, l / 2);
line(l / 2, 0, l / 2, l);
strokeWeight(2);
}
void draw(){
float r = 200 * sin(theta / 13 * 4);
PVector p = PVector.add(p0, new PVector(r * cos(theta), - r * sin(theta)));
stroke(cl, 25);
line(l / 2, l / 2, p.x, p.y);
stroke(cl);
point(p.x, p.y);
theta *= (1 + 5 / (500 + abs(r * theta)));
noStroke();
fill(255);
rect(l / 2 + 25, l-35, 100, 10);
fill(0, 102, 153);
text("θ = "+theta, l / 2 + 25, l-25);
}
void mousePressed(){
if(value == 0){
noLoop();
value = 1;
} else {
loop();
value = 0;
}
}
int l = 500;
PVector p0 = new PVector(l / 2, l / 2);
float theta = 2*PI;
color cl = #E61C64;
int value;
void setup(){
smooth();
size(l, l);
background(255);
fill(0, 102, 153);
text(st, 25, l-25);
line(0, l / 2, l, l / 2);
line(l / 2, 0, l / 2, l);
strokeWeight(2);
}
void draw(){
float r = 200 * sin(theta / 13 * 4);
PVector p = PVector.add(p0, new PVector(r * cos(theta), - r * sin(theta)));
stroke(cl, 25);
line(l / 2, l / 2, p.x, p.y);
stroke(cl);
point(p.x, p.y);
theta *= (1 + 5 / (500 + abs(r * theta)));
noStroke();
fill(255);
rect(l / 2 + 25, l-35, 100, 10);
fill(0, 102, 153);
text("θ = "+theta, l / 2 + 25, l-25);
}
void mousePressed(){
if(value == 0){
noLoop();
value = 1;
} else {
loop();
value = 0;
}
}