From 0f9327b07d8a0b6608981e688b9a62a1ea0a5a5e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 24 Apr 2017 21:30:43 -0400 Subject: fix colors --- client/index.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'client/index.js') diff --git a/client/index.js b/client/index.js index 73ace90..728fd60 100644 --- a/client/index.js +++ b/client/index.js @@ -25,19 +25,35 @@ function add (x, y) { const i = x + 1 const j = y + 1 const div = document.createElement('div') + let add = 0 + let frac = Math.log2(i/j) % 1 div.style.left = (x * s) + 'px' div.style.top = (y * s) + 'px' - div.style.backgroundColor = color(i/j, add_off, mul_off) - div.style.opacity = Math.min(j/i * Math.sqrt(3), 1) div.innerHTML = `
${i}<\/div>
\/
${j}<\/div>` + if (frac < 0) { + frac += 1 + console.log(frac) + } + if (i < j) { + add = -Math.log(j/i) / 3.5 + } + else { + add = Math.log(i/j) / 6 + } + if ( frac === 0) { + div.style.fontWeight = '900' + div.style.left = (x * s) + 'px' + div.style.top = (y * s) + 'px' + } + div.style.backgroundColor = color(frac, add_off + add, mul_off) div.addEventListener('mouseenter', function(){ - div.style.backgroundColor = color(i/j, add_on, mul_on) + div.style.backgroundColor = color(frac, add + add_on, mul_on) if (dragging) { kalimba.play( root * i/j ) } }) div.addEventListener('mouseleave', function(){ - div.style.backgroundColor = color(i/j, add_off, mul_off) + div.style.backgroundColor = color(frac, add + add_off, mul_off) }) div.addEventListener('click', function(){ kalimba.play( root * i/j ) -- cgit v1.2.3-70-g09d2