From 44aa8a136a176739720cc01596a6c7b9d616a9c5 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Fri, 27 Feb 2026 15:43:59 +0100 Subject: [PATCH] Fix gradientBall.html bug could cause it to spin EXTREMELY quickly --- gradientBall.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gradientBall.html b/gradientBall.html index dcaaeea..fd2041b 100644 --- a/gradientBall.html +++ b/gradientBall.html @@ -74,7 +74,8 @@ if (h == -1 || s == -1 || l == -1) { [h, s, l] = hexToHSL(fg); } - // Reset canvas + // Reset canvas transform and clear + ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.fillStyle = bg; ctx.fillRect(0, 0, width, height); @@ -84,8 +85,8 @@ y: (height / 2) - distance }; - // Increment rotation - rotate += speed + // Increment rotation (wrap to avoid precision loss) + rotate = (rotate + speed) % 6283.185 // Define gradient for ball var grd = ctx.createRadialGradient(midPoint.x, midPoint.y, 0, midPoint.x, midPoint.y, radius);