Refactor: lay the repo out by section (core, collection, analysis, planner, site) (#8)
Moves only; no behaviour changes. Every file now lives under the part of the project it belongs to, each section has a README, and docs/PRIVACY.md collects the rules all parts follow. core/ engine.js, graph.js, solver.js, python/clean.py collection/ sources/ (form, register, PDF check, daily update), bot/ (importer) analysis/ stats/ (Python statistics), network/ (build-graph.js), reports/ (POLICY.md) planner/ build-policy.js, policy-report.js site/ atlas/ (the page), build.js, qa/ tests/ core/ (unit), parity/ (JS vs Python), fixtures/ Checked against the previous layout: tests pass; coded runs, test outputs, graph.json and policy.json are byte-identical; the built site differs only in comments that name file paths. The published file names Ken's bot downloads (solver.js, graph.js, data/policy.json) are unchanged. Also removes the undefined/ folder of QA screenshots committed by mistake (the QA scripts now default to a temp folder) and test.txt, and drops the unused npm workspaces. Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dcd5117373
commit
432e04c2c7
@@ -0,0 +1,42 @@
|
||||
"""check_colours.py: are the dragon colours (valley.js INK, index.html --dr-*) still distinguishable?
|
||||
|
||||
python site/qa/check_colours.py
|
||||
"""
|
||||
"""Pairwise CIEDE2000 between dragon colours, normal vision and simulated colour-vision deficiencies (Machado 2009, severity 1),
|
||||
plus contrast against the backgrounds they sit on."""
|
||||
import itertools, sys
|
||||
import numpy as np
|
||||
from skimage.color import rgb2lab, deltaE_ciede2000
|
||||
|
||||
MAP = {"Red": "#cc3346", "Orange": "#e08a2a", "Brown": "#4e3020", "Green": "#2f8f6f", "Blue": "#2a58b8", "Black": "#22182a"}
|
||||
UI = {"Red": "#e8435e", "Orange": "#ff9533", "Brown": "#d1a47a", "Green": "#3fc0a8", "Blue": "#7ea6ff", "Black": "#e0d8ea"}
|
||||
if len(sys.argv) > 1: # candidate palettes passed as name=hex,...
|
||||
for arg in sys.argv[1:]:
|
||||
k, v = arg.split(":", 1)
|
||||
d = dict(x.split("=") for x in v.split(","))
|
||||
(MAP if k == "map" else UI).update(d)
|
||||
BG = {"map paper": "#e9c88f", "map canopy": "#6c6b40", "ui dark": "#210f19"}
|
||||
M = { # Machado et al. 2009, severity 1.0, applied in linear RGB
|
||||
"protan": [[0.152286, 1.052583, -0.204868], [0.114503, 0.786281, 0.099216], [-0.003882, -0.048116, 1.051998]],
|
||||
"deutan": [[0.367322, 0.860646, -0.227968], [0.280085, 0.672501, 0.047413], [-0.011820, 0.042940, 0.968881]],
|
||||
"tritan": [[1.255528, -0.076749, -0.178779], [-0.078411, 0.930809, 0.147602], [0.004733, 0.691367, 0.303900]],
|
||||
}
|
||||
def rgb(h): h = h.lstrip("#"); return np.array([int(h[i:i + 2], 16) for i in (0, 2, 4)]) / 255
|
||||
def lin(c): return np.where(c <= 0.04045, c / 12.92, ((c + 0.055) / 1.055) ** 2.4)
|
||||
def unlin(c): c = np.clip(c, 0, 1); return np.where(c <= 0.0031308, c * 12.92, 1.055 * c ** (1 / 2.4) - 0.055)
|
||||
def sim(c, kind): return c if kind == "normal" else unlin(np.array(M[kind]) @ lin(c))
|
||||
def lab(c): return rgb2lab(c.reshape(1, 1, 3)).reshape(3)
|
||||
def de(a, b): return float(deltaE_ciede2000(lab(a), lab(b)))
|
||||
def lum(c): l = lin(c); return 0.2126 * l[0] + 0.7152 * l[1] + 0.0722 * l[2]
|
||||
def contrast(a, b): x, y = sorted([lum(a), lum(b)], reverse=True); return (x + 0.05) / (y + 0.05)
|
||||
for name, P in [("MAP (on paper)", MAP), ("UI (on dark)", UI)]:
|
||||
print(f"\n== {name}: pairs with CIEDE2000 < 20 under any vision (flag), worst first")
|
||||
rows = []
|
||||
for a, b in itertools.combinations(P, 2):
|
||||
ds = {k: de(sim(rgb(P[a]), k), sim(rgb(P[b]), k)) for k in ["normal", "protan", "deutan", "tritan"]}
|
||||
rows.append((min(ds.values()), a, b, ds))
|
||||
for m, a, b, ds in sorted(rows):
|
||||
if m < 20: print(f" {a:6} vs {b:6} " + " ".join(f"{k} {v:5.1f}" for k, v in ds.items()))
|
||||
print(" contrast vs backgrounds:")
|
||||
for c in P:
|
||||
print(f" {c:6} " + " ".join(f"{bg} {contrast(rgb(P[c]), rgb(h)):.1f}" for bg, h in BG.items() if (bg.startswith('map') if P is MAP else bg.startswith('ui'))))
|
||||
Reference in New Issue
Block a user