fractalkitty looking for math? fractalkitty.com

100 days of code

devilsCurve_Day18

#random#trig#animation#math#parametric

num1devilsCurve

let a = 100,b=50,c = 0,num1=10;
function setup() {
  createCanvas(500, 500);
  angleMode(DEGREES);
  fill(0);
}


function draw() {
  translate(width/2,width/2);
  for(let i=0;i<100;i++){
    noStroke()
    fill(255,105,105,5)
    circle(random(-width/2,width/2),random(-width/2,width/2),50)
  }
  background(0,0,0,5);
  c = 0;
  for (let i=num1;i>0;i--){
    fill(c+100,c+10,c+10);
    devilsCurve((num1/8)*i/num1)
    c = c + (255/num1);
  }
  t = frameCount/10
  a = 200*cos(t)+1
  b = 200*sin(t)+1
}

function devilsCurve(n){
  beginShape()
  for(t=0;t<360;t++){
  x=n*cos(t)* sqrt((a*a*sin(t)*sin(t)-b*b*cos(t)*cos(t))/(sin(t)*sin(t)-cos(t)*cos(t)));
  y = n*sin(t)*sqrt((a*a*sin(t)*sin(t)-b*b*cos(t)*cos(t))/(sin(t)*sin(t)-cos(t)*cos(t)));
  vertex(x,y);
  }
  endShape(CLOSE)
}