diff --git a/clock.js b/clock.js index 44e0283..29ff9c4 100644 --- a/clock.js +++ b/clock.js @@ -41,25 +41,26 @@ } // Position markers based on the current clock size - const radius = clock.offsetWidth / 2 - 20; + const markerRadius = clock.offsetWidth / 2 - 20; markers.forEach((m, i) => { const angle = (i / 16) * 2 * Math.PI; - const x = radius * Math.sin(angle); - const y = -radius * Math.cos(angle); + const x = markerRadius * Math.sin(angle); + const y = -markerRadius * Math.cos(angle); m.style.left = `${clock.offsetWidth / 2 + x}px`; m.style.top = `${clock.offsetHeight / 2 + y}px`; }); - // Tick lengths based on radius - const lenBig = radius * 0.12; - const lenMid = radius * 0.08; - const lenSmall = radius * 0.05; + // Tick lengths based on the marker radius + const lenBig = markerRadius * 0.12; + const lenMid = markerRadius * 0.08; + const lenSmall = markerRadius * 0.05; ticks.forEach((t, i) => { let len = lenSmall; if (t.classList.contains('big')) len = lenBig; else if (t.classList.contains('mid')) len = lenMid; - const innerR = radius - len; + const outerR = clock.offsetWidth / 2 - 2; + const innerR = outerR - len; const angle = (i / 256) * 2 * Math.PI; const x = innerR * Math.sin(angle); const y = -innerR * Math.cos(angle);