completely overhaul dark mode to fix clapper

Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
Naman Sood 2022-05-11 01:02:39 -04:00
parent ea81f7aeef
commit 350809a716
3 changed files with 50 additions and 32 deletions

View file

@ -160,7 +160,10 @@ function Point() {
this.draw = function() {
if(p.progress >= 0) {
// opacity of of dot changes with progress
ctx.fillStyle = 'rgba(0,0,0,' + Math.sqrt(p.progress*0.005) + ')';
const isDarkMode = document.body.classList.contains('dark-mode');
let color = isDarkMode ? 255 : 0;
let multiplier = isDarkMode ? 0.05 : 0.005;
ctx.fillStyle = `rgba(${color}, ${color}, ${color}, ${Math.sqrt(p.progress*multiplier)})`;
ctx.beginPath();
// radius calculation: maps progress from [0, 1] to [0, pi],
// then takes sine of that to get an increase, then decrease