xxxxxxxxxx
63
function setup() {
createCanvas(600, 600);
let delta = 0.01;
let r0 = 200;
let sins = [];
let coses = [];
num_modes = 10;
noise_amp = 20;
// center the coordinate system
translate(width/2,height/2);
background(0);
stroke(255,5);
noFill(0);
// now here is the drawing
for (let i=1; i<1000; i++) {
// now let's initiate a bunch of random Fourier modes
r = r0;
for (let j = 1; j < num_modes; j++) {
sins[j]=(random()-0.5)*noise_amp*j;
coses[j]=(random()-0.5)*noise_amp*j;
r = r + coses[j];
}
// initialized.
x_old = r;
y_old = 0;
for (let theta=0; theta<(2*PI); theta+=delta) {
r = r0;
// add up all the modes.
for (let j = 1; j < num_modes; j ++) {
r = r + sins[j]*sin(j*theta) + coses[j]*cos(j*theta);
}
x = r*cos(theta);
y = r*sin(theta);
// draw the line.
//line(r*cos(theta-delta),r*sin(theta-delta),r*cos(theta),r*sin(theta));
line(x_old,y_old,x,y);
x_old = x;
y_old = y;
}
//circle(0,0,10*i);
//circle(0,0,30);
}
}
function draw() {
}