fractalkitty looking for math? fractalkitty.com

100 days of code

night

#random#classes#interactive#animation#nature#sky#time

starAtArraytArray2tTimeStar

let t=0,p=true
let starA=[];
let tArray=[];
let tArray2=[];
let tTime=1;
let c = 2;
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()
  fill(60, 40, 90)
  triangle(-width/3,+60,-width/2-100,height/2,width/5,height/2)
  triangle(width/3,+60,width/2+100,height/2,-width/5,height/2)
  fill(85, 54, 105);
  triangle(0,+60,-width/2,height/2,width/2,height/2);
  fill(54, 105, 92);
  ellipse(0,height/2+height/3,width,height);
  fill(45, 95, 82);
  ellipse(width/2,height/2+height/3,width,height)
  ellipse(-width/2,height/2+height/3,width,height)
  fill(54, 105, 92);
  ellipse(0,height/2+height/3,width,height);
  
}


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(0,0,0,200)
}