fractalkitty looking for math? fractalkitty.com

100 days of code

pascal

#trig#interactive#math#geometry#polar

linePoints

let y1,y2,y3,y4,t;
let r=80;
function setup(){
  createCanvas(600,600);
  stroke(255);
  background(255,255,255);
  translate(width/2-10,height/2-10);
  linePoints()
  angleMode(DEGREES)
}
function draw(){
  t=20*sin(frameCount);
  background(255,255,255,0.5);
  translate(width/2,height/2);
  rotate(frameCount/3)
  fill(41, 67, 115)
  stroke(200)
  circle(0,0,r*2)
  linePoints();
  
}
function linePoints(){
  stroke(255)
  fill(250)
  stroke(200,250,255)
  strokeWeight(2)
  px1=-r*sin(t/2+40)
  px2=-r*sin(t+10-t/10)
  px3=-r*sin(t-40-t/2)
  py1=-r*cos(t/2+40)
  py2=-r*cos(t+10-t/10)
  py3=-r*cos(t-40-t/2)
  circle(px1,py1,9);
  circle(px2,py2,9);
  circle(px3,py3,9);
         
  px4=r*sin(-t*2-60)
  px5=r*sin(30*sin(t)+10)
  px6=r*sin(-t+80)
  py4=r*cos(-t*2-60)
  py5=r*cos(30*sin(t)+10)
  py6=r*cos(-t+80)
  circle(px4,py4,9);
  circle(px5,py5,9);
  circle(px6,py6,9);
  stroke(103, 171, 155)
  line(px1,py1,px5,py5);//l1
  line(px2,py2,px4,py4)//l2
  ml1=(py1-py5)/(px1-px5);
  ml2=(py2-py4)/(px2-px4);
  intX1=(ml1*px1-py1-ml2*px2+py2)/(ml1-ml2)
  intY1=ml1*(intX1-px1)+py1;
  circle(intX1,intY1,10)
  
  
  stroke(181, 123, 114)
  line(px1,py1,px6,py6)
  line(px3,py3,px4,py4)
  ml3=(py1-py6)/(px1-px6);
  ml4=(py3-py4)/(px3-px4);
  intX2=(ml3*px1-py1-ml4*px3+py3)/(ml3-ml4)
  intY2=ml3*(intX2-px1)+py1;
  circle(intX2,intY2,10)
  
  stroke(52, 135, 173)
  line(px2,py2,px6,py6)
  line(px3,py3,px5,py5)
  ml5=(py2-py6)/(px2-px6);
  ml6=(py3-py5)/(px3-px5);
  intX3=(ml5*px2-py2-ml6*px5+py5)/(ml5-ml6)
  intY3=ml5*(intX3-px2)+py2;
  circle(intX3,intY3,10)
  
  mInt=(intY3-intY1)/(intX3-intX1);
  ploty1=mInt*(-width/3-intX1)+intY1;
  ploty2=mInt*(width/3-intX1)+intY1;
  stroke(55-70*sin(frameCount),75-50*sin(frameCount)*sin(frameCount),105-50*sin(frameCount)*sin(frameCount))
  strokeWeight(2-1.5*cos(frameCount))
  line(-width/3,ploty1,width/3,ploty2);
}

function mousePressed(){
  noLoop()
}