Fix ball sizing

This commit is contained in:
Marco van Dijk 2023-03-10 17:08:11 +01:00 committed by GitHub
parent 80dfd671f6
commit 02f6c978b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,14 +98,12 @@
grd.addColorStop(1, `hsla(${h}, ${s}%, ${l}%, 0)`); grd.addColorStop(1, `hsla(${h}, ${s}%, ${l}%, 0)`);
ctx.beginPath(); ctx.beginPath();
// Rotate Ball around center // Rotate canvas around the ball
ctx.translate(midPoint.x, midPoint.y); ctx.translate(midPoint.x, midPoint.y + distance);
ctx.translate(0, distance);
ctx.rotate(0.001 * rotate); ctx.rotate(0.001 * rotate);
ctx.translate(-midPoint.x, -midPoint.y); ctx.translate(-midPoint.x, -midPoint.y - distance);
ctx.translate(0, -distance);
// Draw Ball // Draw Ball
ctx.arc(midPoint.x, midPoint.y, midPoint.x - 2, 0, Math.PI * 2, false); ctx.arc(midPoint.x, midPoint.y, radius, 0, Math.PI * 2, false);
ctx.fillStyle = grd; ctx.fillStyle = grd;
ctx.fill(); ctx.fill();
ctx.closePath(); ctx.closePath();
@ -113,4 +111,4 @@
window.requestAnimationFrame(update); window.requestAnimationFrame(update);
} }
window.requestAnimationFrame(update); window.requestAnimationFrame(update);
</script> </script>