let colors = ["#3d4635", "#5a734c", "#8e472c", "#a7713b", "#252b21", "#304543", "#b18961", "#cab68c"]
simplex = new openSimplexNoise(Date.now())
for (let a = 0; a < TAU; a += TAU / 120) {
let h = random(height / 15, height / 3.6)
lights.push(new light(width / 2 + cos(a) * width / 3, height * 0.66 + sin(a) * height / 3, h, 0, a, 166))
lights.push((new light(width / 2 + cos(a) * width / 3, height * 0.66 + sin(a) * height / 3, h * 0.66, 1, a, 0)))
let filler = color("#131611")
ellipse(width / 2, height * 0.66, width * 0.666, height * 0.666)
for (let r = 0; r < 0.666; r += 0.002) {
let roff = simplex.noise2D(r * 15, 0.1) * 0.04
let rc = constrain(r + roff, 0, 0.66)
ellipse(width / 2, height * 0.66, width * rc, height * rc)
constructor(x, y, baseH, type, angle, delay) {
this.pos = createVector(x, y)
this.startPos = createVector(x, y)
this.color = color(colorMixer(this.x, colors))
this.targetPos = createVector(0, 0)
this.targetH = this.y + abs(this.baseH) * -1
this.targetPos = createVector(this.pos.x, this.y + abs(this.baseH) * -1)
this.targetH = this.y + sin(this.angle) * (this.baseH)
this.targetPos = createVector(this.x + cos(this.angle) * this.baseH, this.y + sin(this.angle) * (this.baseH))
if (this.currentFrame < this.frames) {
let framesMap = map(this.currentFrame, 0, this.frames, 0, 1);
this.pos = p5.Vector.lerp(this.startPos, this.targetPos, easeOutQuart(framesMap))
let framesMap = map(this.currentFrame, 0, this.frames, 0, 1);
let s = lerp(width / 200, width / 50, easeOutQuart(framesMap))
ellipse(this.pos.x, this.pos.y, s)
let xoff = simplex.noise2D(this.pos.y / 5, this.pos.x / 70) * (this.frames / 10)
let yoff = simplex.noise2D(this.pos.y / 5, this.pos.x / 200) * (this.frames / 100)
ellipse(this.pos.x + xoff, this.pos.y + yoff, s)
if (this.currentFrame > this.frames) {
let index = lights.indexOf(this)
function colorMixer(x, colorArray) {
let c = noise(x) * colorArray.length
let c2 = floor(c + 1) % colorArray.length
let color1 = colorArray[c1]
let color2 = colorArray[c2]
let coloring = spectral.mix(color1, color2, mix)
function easeOutQuart(x) {
return 1 - Math.pow(1 - x, 4);