Rainstorm Precipitation
Meteorological atmospheric downpour integrating aerodynamic terminal velocity fall rates, aerodynamic wind shear slant, and damped Bessel ground collision ripples.
60 FPS • Canvas 2D
Click + Drag to interact with field
</>
Full Executable Algorithm Code
116 lines
3954 chars
// 041 - Rainstorm Precipitation (fluid)
// 1:1 Original algorithm engine source
function createRainEffect() {
const MAX_DROPS = 600;
const MAX_RIPPLES = 48;
const dropX = new Float32Array(MAX_DROPS);
const dropY = new Float32Array(MAX_DROPS);
const dropSpeed = new Float32Array(MAX_DROPS);
const dropLength = new Float32Array(MAX_DROPS);
const ripX = new Float32Array(MAX_RIPPLES);
const ripY = new Float32Array(MAX_RIPPLES);
const ripRadius = new Float32Array(MAX_RIPPLES);
const ripLife = new Float32Array(MAX_RIPPLES);
let nextRipIdx = 0;
return {
setup(context) {
for (let i = 0; i < MAX_DROPS; i++) {
dropX[i] = Math.random() * context.width;
dropY[i] = Math.random() * context.height;
dropSpeed[i] = 400 + Math.random() * 500;
dropLength[i] = 12 + Math.random() * 18;
}
ripLife.fill(-1);
},
render(context, timeState, params) {
const { ctx, width, height } = context;
const intensity = Number(params.rainDensity || 450);
const windAngle = Number(params.windShear || 0.15);
const dt = Math.min(timeState.deltaTime, 0.05);
const groundY = height * 0.88;
ctx.fillStyle = "rgba(4, 6, 12, 0.25)";
ctx.fillRect(0, 0, width, height);
const activeCount = Math.min(MAX_DROPS, intensity);
const windDx = Math.sin(windAngle);
const windDy = Math.cos(windAngle);
for (let i = 0; i < activeCount; i++) {
dropY[i] += dropSpeed[i] * dt;
dropX[i] += dropSpeed[i] * windDx * dt;
if (dropY[i] >= groundY) {
dropY[i] = 0;
dropX[i] = Math.random() * (width + 200) - 100;
ripX[nextRipIdx] = dropX[i];
ripY[nextRipIdx] = groundY + (Math.random() - 0.5) * 20;
ripRadius[nextRipIdx] = 2;
ripLife[nextRipIdx] = 1;
nextRipIdx = (nextRipIdx + 1) % MAX_RIPPLES;
}
const headX = dropX[i];
const headY = dropY[i];
const tailX = headX - windDx * dropLength[i];
const tailY = headY - windDy * dropLength[i];
ctx.beginPath();
ctx.moveTo(tailX, tailY);
ctx.lineTo(headX, headY);
ctx.strokeStyle = "rgba(186, 230, 253, 0.55)";
ctx.lineWidth = 1.1;
ctx.stroke();
}
for (let r = 0; r < MAX_RIPPLES; r++) {
if (ripLife[r] > 0) {
ripLife[r] -= dt * 2.2;
ripRadius[r] += dt * 45;
ctx.beginPath();
ctx.ellipse(ripX[r], ripY[r], ripRadius[r], ripRadius[r] * 0.35, 0, 0, Math.PI * 2);
ctx.strokeStyle = hsla(195, 90, 75, ripLife[r] * 0.7);
ctx.lineWidth = 1.2;
ctx.stroke();
}
}
ctx.fillStyle = "rgba(56, 189, 248, 0.04)";
ctx.fillRect(0, groundY - 15, width, height - groundY + 15);
}
};
}
// Default parameters from content metadata
const defaultParams = [
{
"key": "rainDensity",
"label": "Rainfall Intensity",
"type": "range",
"min": 100,
"max": 600,
"step": 20,
"defaultValue": 450,
"description": "Active precipitation streak count"
},
{
"key": "windShear",
"label": "Wind Shear Slant",
"type": "range",
"min": -0.5,
"max": 0.5,
"step": 0.05,
"defaultValue": 0.15,
"description": "Horizontal gale deflection angle"
}
];
if (!window.__art_instances) window.__art_instances = {};
if (!window.__art_instances['rain-effect']) {
const inst = typeof createRainEffect === 'function' ? createRainEffect() : null;
if (inst && inst.setup) {
inst.setup({ ctx, width, height, dpr: 1, aspectRatio: width / height }, defaultParams);
}
window.__art_instances['rain-effect'] = inst;
}
const instance = window.__art_instances['rain-effect'];
if (instance && instance.render) {
instance.render(
{ ctx, width, height, dpr: 1, aspectRatio: width / height },
{ time, deltaTime: dt, frameCount: Math.floor(time * 60), fps: 60 },
defaultParams
);
} Edit in Interactive Playground
Zero Dependencies • Standalone Canvas 2D
ƒ
Mathematical Formulation
medium
Analytical Equation
vterm=ρACd2mg,v=vterm[sinθwindcosθwind],rripple(t)=vwave(t−timpact)
Click to expand
∑
Rainstorm Precipitation
Full Mathematical System • fluid
100%
Complete System of Equations
[Governing Law][Discrete Progression][Domain & Space][Parameter State]vterm=ρACd2mg,v=vterm[sinθwindcosθwind],rripple(t)=vwave(t−timpact)y+=speed⋅dt,x+=speed⋅sin(wind)⋅dt,ripple=ellipse(x,y,r,0.35r)⋅exp(−γt)x∈R2,t∈R+,ω∈[0,2π]λrainDensity=450(Rainfall Intensity),λwindShear=0.15(Wind Shear Slant)
vterm=ρACd2mg,v=vterm[sinθwindcosθwind],rripple(t)=vwave(t−timpact)
Computational Implementation (JavaScript Engine Equivalent)
y += speed * dt, x += speed * sin(wind) * dt, ripple = ellipse(x, y, r, 0.35r) * exp(-γt) Compact Formula
y += speed * dt, x += speed * sin(wind) * dt, ripple = ellipse(x, y, r, 0.35r) * exp(-γt) Mathematical Tags
#rain
#precipitation
#weather
#fluid
#ripples
#atmosphere
#water
Author: Math Art Core Target: 60 FPS
Press ESC or F to exit