From e70a7c5e85dd944282da867fcda9f4119f74d583 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 20 Jun 2020 11:19:44 -0400 Subject: [PATCH] Make sure the edge is sharp at 0 smoothness --- xray.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xray.js b/xray.js index 3494736..683a345 100644 --- a/xray.js +++ b/xray.js @@ -417,12 +417,16 @@ function updateOverlay(points, clicked) { const gradient = overlayCtx.createRadialGradient(x, y, 0, x, y, Math.floor(radius * scale)); - const maxOpacity = ease(0, 1 / (0.001 + softness / 100)); + const maxOpacity = ease(0, 1 / (0.00001 + softness / 100)); - for (let t=0 ; t <= 20; t+= 1) { - let eased = ease(t/20.0, 1 / (0.001 + softness / 100)) / maxOpacity; - gradient.addColorStop(t/20.0, `rgba(0, 0, 0, ${eased}`); + const steps = 20; + for (let t=0 ; t <= steps; t+= 1) { + let eased = ease(t/steps, 1 / (0.00001 + softness / 100)) / maxOpacity; + gradient.addColorStop(t/steps, `rgba(0, 0, 0, ${eased}`); } + + let eased = ease(0.999, 1 / (0.00001 + softness / 100)) / maxOpacity; + gradient.addColorStop(0.999, `rgba(0, 0, 0, ${eased}`); overlayCtx.fillStyle = gradient; overlayCtx.fill();