From a0015b535b78ae49e39af1c76bf53b70c14d20b4 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 9 Nov 2019 10:47:37 -0500 Subject: * --- editor/scripts/benchmark.js | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 editor/scripts/benchmark.js (limited to 'editor/scripts/benchmark.js') 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: ${id} ${bc}\n` + } else if (rating < 1.5) { + html += `Low contrast(${rating.toFixed(2)}): ${id} ${bc}\n` + } + + return html + } +} -- cgit v1.2.3