diff options
| author | neauoire <aliceffekt@gmail.com> | 2019-11-09 10:47:37 -0500 |
|---|---|---|
| committer | neauoire <aliceffekt@gmail.com> | 2019-11-09 10:47:37 -0500 |
| commit | a0015b535b78ae49e39af1c76bf53b70c14d20b4 (patch) | |
| tree | d8b282ddcb7d2d94c374e4e41de4605197833b52 /editor/scripts/benchmark.js | |
| parent | 3226de0b193d505ebe0504f263f59cd64e24597c (diff) | |
*
Diffstat (limited to 'editor/scripts/benchmark.js')
| -rw-r--r-- | editor/scripts/benchmark.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/editor/scripts/benchmark.js b/editor/scripts/benchmark.js new file mode 100644 index 0000000..84c6d1b --- /dev/null +++ b/editor/scripts/benchmark.js @@ -0,0 +1,47 @@ +'use strict' + +function Benchmark () { + this.matches = function () { + var a = [{ id: 'b_inv_f_inv', fc: theme.active.f_inv, bc: theme.active.b_inv }] + for (const fid in theme.active) { + if (fid.substr(0, 1) != 'f' || fid.indexOf('_inv') > -1) { continue } + const fc = theme.active[fid] + for (const bid in theme.active) { + if (bid.substr(0, 1) != 'b' || bid.indexOf('_inv') > -1) { continue } + const bc = theme.active[bid] + a.push({ id: `${bid}_${fid}`, fc: fc, bc: bc }) + } + } + return a + } + + this.refresh = function () { + const el = document.getElementById('print') + const html = '' + const count = 0 + const matches = bench.matches() + + console.log(matches) + for (const match of matches) { + const cell = document.getElementById(match.id) + console.log(cell, match.id) + // cell.textContent = '0.0' + } + + el.innerHTML = html + } + + this.log = function (id, fc, bc) { + let html = '' + + const 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 + } +} |
