diff --git a/client/src/main.ts b/client/src/main.ts index c365a61..80a83ea 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -127,13 +127,21 @@ const render = (state: State, ctx: CanvasRenderingContext2D) => { for (const particle of state.particles) { const progress = (particle.age / MAX_AGE) const opacity = Math.min(1, Math.pow(1-progress, 3)) * (particle.maxRadius / MAX_RADIUS) + const [x, y] = particle.position + const scaledX = x * document.body.offsetWidth + const scaledY = y * document.body.offsetHeight + const radius = (progress * (particle.maxRadius - MIN_RADIUS)) + MIN_RADIUS + const gradient = ctx.createRadialGradient(scaledX, scaledY, 0, scaledX, scaledY, radius) + gradient.addColorStop(0, `rgba(120, 120, 240, 0)`) + gradient.addColorStop(0.33, `rgba(120, 120, 240, 0)`) + gradient.addColorStop(1, `rgba(120, 120, 240, ${opacity/5})`) ctx.beginPath() - ctx.strokeStyle = `rgba(40, 40, 40, ${opacity})` - const [x, y] = particle.position - const radius = (progress * (particle.maxRadius - MIN_RADIUS)) + MIN_RADIUS - ctx.ellipse(x * document.body.offsetWidth, y * document.body.offsetHeight, radius, radius, 0, 0, Math.PI * 2) + ctx.fillStyle = gradient + ctx.strokeStyle = `rgba(255,255,255,0)` + ctx.ellipse(scaledX, scaledY, radius, radius, 0, 0, Math.PI * 2) ctx.stroke() + ctx.fill() } }