let angle=30;
let nbirds=100;
let b=[];
let x,y,t;
function setup(){
createCanvas(windowWidth,windowHeight);
birds();
angleMode(DEGREES)
}
function draw(){
background(7,99,119,100);
t=frameCount/4
translate(width/2,height/2);
stroke(255);
strokeWeight(2);
translate(width/10, 220);
fractal(80,-1);
noStroke()
circle(-width/3,-height/3,100)
fill(7,99,119)
circle(-width/3-100+(t/2)%300,-height/3,100)
fill(255)
for (let i=0;i<nbirds;i++){
b[i].move();
b[i].display();
}
rect(-width/2-width/10,50,width,300);
}
function fractal(len,refl) {
strokeWeight(3)
tmp = len*refl
line(0, 0, 0, tmp);
translate(0, tmp);
if (len > 3) {
push();
rotate(angle);
fractal(len * 0.70,refl)
pop();
push();
rotate(-angle);
fractal(len * 0.6,refl)
pop();
}
}
function birds(){
for(let i=0;i<nbirds;i++){
b.push(new Birdy(20*sin(i*10)+randomGaussian(-10,10),-90*cos(i)+random(-30,-20)));
}
}
class Birdy{
constructor(x,y){
this.x=x
this.y=y
this.x1=x
this.y1=y
this.m=random(10,20)
this.t=random(0,880)
}
move(){
this.x=this.x1+(width/50+this.t/2)*sin(this.t)
if(this.t<=1000){
this.y=this.y1-this.t/2-width/10
}
if(this.y<=-height){
this.y=this.y1
this.x=this.x1
}
if (this.t>1000){
this.t=0
}
this.t=this.t+0.5;
}
display(){
if(this.y<-width/10){
circle(this.x,this.y,2)
}
}
}