diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-04-24 21:30:43 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-04-24 21:30:43 -0400 |
| commit | 0f9327b07d8a0b6608981e688b9a62a1ea0a5a5e (patch) | |
| tree | 26bbb511716065cc2e14dbf8a34e5ba05cc50aa2 /client/index.js | |
| parent | f50f17345facda8e1b5da36c35f89a8a974f3eb7 (diff) | |
fix colors
Diffstat (limited to 'client/index.js')
| -rw-r--r-- | client/index.js | 24 |
1 files changed, 20 insertions, 4 deletions
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 = `<div>${i}<\/div><div>\/</div><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 ) |
