createCanvas(windowWidth, windowHeight);
bg=createGraphics(width, height)
for(let i=0; i<100; i++){
let v1=createVector(width+width*0.5, random(-height*0.4, 0))
let v2=createVector(0, height+ random(-height*0.3, height*0.3))
let beamWidth= random(height*0.05, height)
bg.triangle(v1.x, v1.y, v2.x, v2.y-beamWidth/2, v2.x, v2.y+beamWidth/2)
motes.push(new mote(random(width), random(height)))
this.pos=createVector(x, y);
this.vel=createVector(random(-0.01, -0.3), random(0.01, 0.3));
this.depth= random(-20, 20)
this.wave=createVector(0, 0)
let waver= map(noise(this.pos.x/100, this.pos.y/100, frameCount/200), 0, 1, -0.2, 0.2)
this.depth= constrain(this.depth, -20, 20)
if(this.pos.x<-maxSize/2 || this.pos.y>height+maxSize/2){
let newPlace= random(-width*0.2, height*0.2)
this.pos= createVector(width+newPlace, -maxSize/2)
this.pos= createVector(width+maxSize/2, newPlace)
let mpos=createVector(mouseX, mouseY)
let d= p5.Vector.dist(this.pos, mpos)
let power= map(d, 0, 200, 3, 0)
let xnvel= map(noise(this.pos.x/100, frameCount/100, this.depth), 0, 1, -power, power)
let ynvel= map(noise(this.pos.y/100, frameCount/100, this.depth), 0, 1, -power, power)
this.wave= createVector(xnvel, ynvel)
if(!mouseMoving && this.wave.mag()>0){
if(this.wave.mag()<0.01){
let size= map(this.depth, -20, 20, minSize, maxSize)
let alpha=map(this.depth, 0, 20, 0, 150)
blur= map(abs(this.depth), 0, 20, 0, maxSize)
drawingContext.shadowOffsetX = -size/4;
drawingContext.shadowOffsetY = size/4;
drawingContext.shadowBlur = blur;
let g= bg.get(this.pos.x, this.pos.y)
let bger= (g[0]+g[1]+g[2])/3
let b= map(bger, 0, 100, 0, 255)
drawingContext.shadowColor = color(b)
ellipse(this.pos.x, this.pos.y, size)