fractalkitty looking for math? fractalkitty.com

100 days of code

timeLapse

#random#classes#interactive#animation

starAStar

let t=0,p=true
let starA=[];
function setup(){   
  noStroke()
  cnv=createCanvas(windowWidth,windowHeight); 
  angleMode(DEGREES);
  n=int(width*2);
  for(let i=0;i<n;i++){
    starA.push(new Star())
  }
  background(0)
}
function draw(){
  background(0,0,0,5);
  if (p==true){
    t=frameCount/6
  }
  if (p==false){
    t=(frameCount-1)/6
    frameCount = frameCount-1
  }
  translate(width/2,height/2);
  fill(255);
  push()
  rotate(t)
  for(let i=0;i<n;i++){
    starA[i].move();
    starA[i].display();
  }
  pop()
}


class Star{
  constructor(){
    this.x=random(-width,width);
    this.y=random(-height,height);
    this.r=random(0,width/2)
    this.b=random(0.1,1.5)
  }
  display(){
    circle(this.x,this.y,this.b);
  }
  move(){
      this.x=this.x
      this.y=this.y;
  }
}
function mousePressed(){
    p= !p
    background(00,0,0,150)
}