mirror of
https://github.com/xvvvyz/tilde.git
synced 2026-03-11 14:44:24 +00:00
add rain speed config option
This commit is contained in:
parent
2796c03706
commit
da70da90b7
1 changed files with 8 additions and 4 deletions
12
index.html
12
index.html
|
|
@ -44,6 +44,7 @@
|
|||
rainFade: 0.2,
|
||||
rainFrameRate: 1000 / 18,
|
||||
rainResilience: 0.8,
|
||||
rainSpeed: 1,
|
||||
suggestionLimit: 4,
|
||||
};
|
||||
|
||||
|
|
@ -754,7 +755,8 @@
|
|||
#drops;
|
||||
#lastRender;
|
||||
#rainColor;
|
||||
#size;
|
||||
#rainHeight;
|
||||
#rainWidth;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
|
@ -787,7 +789,8 @@
|
|||
#renderCanvas = () => {
|
||||
this.#canvas.height = window.innerHeight;
|
||||
this.#canvas.width = window.innerWidth;
|
||||
this.#size = Math.ceil(this.#canvas.width / CONFIG.rainColumns);
|
||||
this.#rainWidth = Math.ceil(this.#canvas.width / CONFIG.rainColumns);
|
||||
this.#rainHeight = this.#rainWidth * CONFIG.rainSpeed;
|
||||
this.#backgroundColor = Rain.cssVar('--color-background');
|
||||
this.#rainColor = Rain.cssVar('--color-rain');
|
||||
this.#ctx.fillStyle = this.#backgroundColor;
|
||||
|
|
@ -806,8 +809,9 @@
|
|||
for (let i = 0; i < this.#drops.length; i++) {
|
||||
this.#ctx.fillStyle = this.#rainColor;
|
||||
this.#ctx.globalAlpha = 1;
|
||||
const y = this.#drops[i] * this.#size;
|
||||
this.#ctx.fillRect(i * this.#size, y, this.#size, this.#size);
|
||||
const x = i * this.#rainWidth;
|
||||
const y = this.#drops[i] * this.#rainHeight;
|
||||
this.#ctx.fillRect(x, y, this.#rainWidth, this.#rainHeight);
|
||||
const reset = Math.random() > CONFIG.rainResilience;
|
||||
if (reset || y > this.#canvas.height) this.#drops[i] = 0;
|
||||
else this.#drops[i]++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue