From 9515a8453e0d81c0a6d70ef9fa1482dc8f2042cf Mon Sep 17 00:00:00 2001 From: Adam Iannazzone Date: Tue, 23 Apr 2024 18:53:03 -0400 Subject: [PATCH] Tweaks to gradient rotation algorithm --- scripts/gradient.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/gradient.js b/scripts/gradient.js index f18fd47..64719e3 100644 --- a/scripts/gradient.js +++ b/scripts/gradient.js @@ -6,7 +6,12 @@ reduceMotion(); function updateGradientAngle() { for (let i = 0; i < gradientSpinElems.length; i++) { - gradientAngles[i] += Math.floor(Math.random() * 5) - 5; + gradientAngles[i] += Math.floor(Math.random() * 6) - 2; + if (gradientAngles[i] > 360) { + gradientAngles[i] -= 360; + } else if (gradientAngles[i] < -360) { + gradientAngles[i] += 360; + } gradientSpinElems[i].style.background = `linear-gradient(${gradientAngles[i]}deg, #1a9fff, 15%, #946beb)`; } }