From 7acc06baeb86f69674122462f4e9ae800ba961af Mon Sep 17 00:00:00 2001 From: Cade Scroggins Date: Fri, 31 Mar 2023 13:49:23 -0700 Subject: [PATCH] fully fade out previous rain drop streak --- index.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.html b/index.html index 146e112..8599be4 100644 --- a/index.html +++ b/index.html @@ -812,6 +812,16 @@ const x = i * this.#rainWidth; const y = this.#drops[i] * this.#rainHeight; this.#ctx.fillRect(x, y, this.#rainWidth, this.#rainHeight); + + if (this.#drops[i] <= 4) { + // fully fade out previous rain drop streak + this.#ctx.fillStyle = this.#backgroundColor; + this.#ctx.globalAlpha = this.#drops[i] === 4 ? 1 : 0.4; + const eraseY = y + this.#rainHeight; + const eraseHeight = this.#canvas.height - eraseY; + this.#ctx.fillRect(x, eraseY, this.#rainWidth, eraseHeight); + } + const reset = Math.random() > CONFIG.rainResilience; if (reset || y > this.#canvas.height) this.#drops[i] = 0; else this.#drops[i]++;