xxxxxxxxxx
49
var r; //radius
var angle
var step //distance between steps in radians
function setup() {
createCanvas(800, 800, SVG);
noFill();
//initialize variables
r = 280;
angle = 0;
step = TWO_PI/360; //in radians equivalent of 360/6 in degrees
beginShape();
}
function draw() {
// background(220);
plotCircle();
}
function plotCircle(){
//move 0,0 to the center of the screen
translate(width/2, height/2);
//convert polar coordinates to cartesian coordinates
var x = r * sin(angle);
var n = random(0, 5);
if (n > 4){
var y = r * cos(angle)+(random(-10, 10));
} else {
var y = r * cos(angle)+(random(0, 4));
}
//draw ellipse at every x,y point
// ellipse(x, y, 2);
//vertex / point
vertex(x, y);
//increase angle by step size
angle = angle + step;
}
function doubleClicked() {
endShape();
noLoop();
save("plot.svg"); // give file name
print("saved svg");
}