fractalkitty looking for math? fractalkitty.com

100 days of code

theScanningEntity_Day6

#random#trig#interactive#animation

xCenteryCenteroldxoldynCircplotPnewCirc

let d = [];
let xCenter = [];
let yCenter = [];
let oldx=0,oldy=0;
let nCirc = 1;
function setup() {
  createCanvas(600, 600);
  angleMode(DEGREES);
  d[0] = 600;
  xCenter[0]=0;
  yCenter[0]=0;
  stroke(255);
  strokeWeight(0.01);
  fill(255,255,255,40);
  a = random(-3,3);
  b = random(-3,3);
}

function draw() {
  translate(width/2,width/2)
  background(0,0,0,5);
  for(i=1;i<nCirc;i++){
    plotP(xCenter[i],yCenter[i],a,0,1);
  }
  if (frameCount < 2000){
    newCirc()
  }
  if(frameCount>640){
     for(i=0;i<nCirc;i++){
  }
  }
}

function plotP(x,y,r,shift,m){
  t = frameCount/2
  px = 80*r*sin(a*oldx)+80*sin(frameCount+r)*cos(oldx+a*frameCount);
  py = 80*r*cos(b*oldy*r+frameCount-oldx)+80*sin(b*oldx)*cos(oldy+1.4*frameCount);
  circle(px,py,2);
  line(x,y,px,py)
  oldx = px
  oldy = py;
}

function newCirc(){
  if (nCirc<100){
  xCenter[nCirc] = a*sin(frameCount);
  yCenter[nCirc] = a*cos(frameCount);
  nCirc = nCirc+1;  
  }
}

function mousePressed (){
let xCenter = [];
let yCenter = [];
let oldx=0,oldy=0;
let nCirc = 1;
  a = random(-3,3)
  b = random(-3,3)
}