diff options
| author | Devine Lu Linvega <aliceffekt@gmail.com> | 2018-09-15 15:21:47 +1200 |
|---|---|---|
| committer | Devine Lu Linvega <aliceffekt@gmail.com> | 2018-09-15 15:21:47 +1200 |
| commit | 7335ff6311d33327ee27507c9bec6ad9480cbf07 (patch) | |
| tree | 895177d0749fa6dc9a8a79b7ec5cec23843657ab /benchmark/scripts/benchmark.js | |
| parent | d9ad5fb9769dfb24a21e40e7c24e27ee0a92b9a4 (diff) | |
Organized this a bit
Diffstat (limited to 'benchmark/scripts/benchmark.js')
| -rw-r--r-- | benchmark/scripts/benchmark.js | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/benchmark/scripts/benchmark.js b/benchmark/scripts/benchmark.js index 826d462..654f23b 100644 --- a/benchmark/scripts/benchmark.js +++ b/benchmark/scripts/benchmark.js @@ -1,26 +1,47 @@ function Benchmark() { - this.refresh = function(theme = this) + this.matches = function() { - let el = document.getElementById("print") - let html = "" - let count = 0 + var a = [{id:`f_inv:b_inv`,fc:theme.active.f_inv,bc:theme.active.b_inv}] for(let fid in theme.active){ if(fid.substr(0,1) != "f" || fid.indexOf("_inv") > -1){ continue; } let fc = theme.active[fid] for(let bid in theme.active){ if(bid.substr(0,1) != "b" || bid.indexOf("_inv") > -1){ continue; } let bc = theme.active[bid] - let rating = new Color(fc).contrast(new Color(bc)); - if(rating == 1){ - html += `Overlap: <b>${fid}</b> ${bid} <i>${bc}</i>\n` - } - else if(rating < 1.5){ - html += `Low contrast(${rating.toFixed(2)}): <b>${fid}</b> ${bid} <i>${bc}</i>\n` - } - count += 1 + a.push({id:`${fid}:${bid}`,fc:fc,bc:bc}) } } - el.innerHTML = count > 0 ? `${html}\n<i>${count} conflicts</i>\n\n` : "" + return a; + } + + this.refresh = function() + { + let el = document.getElementById("print") + let html = "" + let count = 0 + let matches = bench.matches(); + + for(let id in matches){ + html += bench.log(matches[id].id,matches[id].fc,matches[id].bc) + } + + el.innerHTML = html + } + + this.log = function(id,fc,bc) + { + let html = "" + + let rating = new Color(fc).contrast(new Color(bc)); + + if(rating == 1){ + html += `Overlap: <b>${id}</b> <i>${bc}</i>\n` + } + else if(rating < 1.5){ + html += `Low contrast(${rating.toFixed(2)}): <b>${id}</b> <i>${bc}</i>\n` + } + + return html } } |
