# shield-legibility: result ## What was wrong `buildArms` coloured the ordinary and the charge with the same metal. Where the charge lay on the ordinary, the two were the same colour. I measured the old pairing directly. The contrast between the charge and the ordinary under it was only 1.21–1.31:1 for every ordinary/charge pairing in both metals, so the charge could not be seen there. ## The tincture rule I chose - The field and the secondary are still colours, and the ordinary is still the seed's metal. Those draws are unchanged. - The charge now gets its own colour. It comes from a separate seed draw labelled `tincture/charge`, among the colours that are neither the field nor the secondary. So the charge is dark paint on the metal ordinary. It is recorded as `choices.tincture.charge = { name, hex }`, next to `field`, `secondary` and `metal`. - The charge also gets a thin painted rim (fimbriation) in the same metal, about 4.5 px at banner size. Outside the rim is a thin keyline in night umber `#14100D`, about 2 px. Where the charge runs off the ordinary onto the field, the light rim still outlines it against the colour field. Where it sits on the ordinary, the dark body reads against the metal and the keyline marks the outline. - The shield edge is a 2 px night-umber keyline on the outline, with a thin metal fillet (about 2.5 px) just inside it. A field the same colour as its cloth, such as gules on the oxblood standard, now has a visible edge. - Every tincture comes from the style guide palette: the four colours, the two metals and night umber, which is a derived value in style-guide.md §3. ## Unchanged - `buildArms(seedBytes, {root})` still returns a 240×288 image, `choices` and `usedLayers`, with a path and sha256 for each layer. - All existing choice names and draw labels are the same, so a given seed still gives the same field, secondary, metal, division, ordinary and charge as before. - Parts are still full-canvas 2048×2560 RGBA value maps registered at (1500,340). - No layer carries varnish, craquelure or shadow. ## Files changed or added - `src/heraldry/index.cjs` (changed): - adds the charge-tincture draw, `choices.tincture.charge` and `KEYLINE_HEX`; - adds `planArms(choices)`, `paintParts(parts,{root})` and `paintArms(choices,{root})`, which `buildArms` now uses; - paint order is field/division, ordinary, charge keyline, charge rim, charge, shield keyline, shield fillet; - adds a cache of decoded parts, keyed by each file's sha256 and cropped to the shield box. I checked in `test/scratch` that its output is byte-identical to the old full-canvas compositing path, and it makes repeated builds about 20× faster. - `src/heraldry/paint-edge-parts.cjs` (new): the deterministic generator for the new parts. It takes bands of distance from the existing charge and field shapes, with a directional brush texture lit from the upper left. Running it twice gave identical bytes for all 8 files. - New parts: - `layers/heraldry/charges/estoile-fimbriation.png`, `estoile-keyline.png` - `layers/heraldry/charges/trefoil-fimbriation.png`, `trefoil-keyline.png` - `layers/heraldry/charges/tower-fimbriation.png`, `tower-keyline.png` - `layers/heraldry/fields/edge-keyline.png`, `edge-fillet.png` - `test/heraldry/legibility-measure.cjs` (new): the contrast measure. It takes the WCAG luminance contrast between a region of the finished arms and the same region with the charge parts removed. It does this at 240×288 and again after reducing to 100×120 with the repository's own `composite`. - `test/heraldry/legibility.test.cjs` (new): 4 tests. - No existing file was renamed or removed. `test/heraldry/arms.test.cjs` is unchanged and still passes. ## How I checked it - **Looking at the shields:** I rendered all 18 division × ordinary × charge pairings with six sets of tinctures (both metals, every charge colour), at 240×288 and reduced to 100×120. I put them on dark and on gules cloth in `test/scratch` and looked at the sheets. - The estoile, trefoil and tower are clear at both sizes, on the cross and on the bend. - The tower, which is narrow, is still recognisable at rail size. - **Measuring contrast:** I measured all 144 combinations (18 pairings × 2 metals × 4 charge colours, with the field and secondary rotating). The test requires at least 3:1 at both sizes for two regions: the charge body on the ordinary, and the charge rim against the field. | Ordinary / charge | Charge on ordinary, 240 / 100 (worst) | Rim against field, 240 / 100 (worst) | Reads at both sizes | |---|---|---|---| | cross / estoile | 3.29 / 3.27 | 3.52 / 3.29 | yes | | cross / trefoil | 3.30 / 3.29 | 3.89 / 3.69 | yes | | cross / tower | 3.14 / 3.12 | 4.08 / 3.85 | yes | | bend / estoile | 3.22 / 3.20 | 3.73 / 3.51 | yes | | bend / trefoil | 3.23 / 3.22 | 3.92 / 3.68 | yes | | bend / tower | 3.18 / 3.16 | 4.04 / 3.91 | yes | - **Shield edge on cloth of the field's own colour:** I measured the edge band against flat cloth of the field's colour. | Field | Edge contrast, 240 / 100 | Without the new edge, 240 / 100 | |---|---|---| | vert | 5.4 / 4.7 | 1.66 / 1.68 | | gules | 4.7 / 4.1 | 1.56 / 1.59 | | azure | 4.1 / 3.6 | 1.47 / 1.49 | | sable | 6.8 / 5.9 | 1.88 / 1.92 | The two metals give the same values to within 0.1. The edge reads in every case. - **Tests:** I ran `node --test test/heraldry/*.test.cjs`. All 13 heraldry tests pass, 0 fail: the 9 existing ones in `arms.test.cjs` and the 4 new ones in `legibility.test.cjs`. The run takes about 8 s. Plain `node --test test/heraldry/` fails on Node 24 because a directory is not accepted as a test path, so the glob is needed. - **Same seed, same bytes:** two builds from one seed were byte-identical (image sha256 `67645f5d…`), with equal `choices` and `usedLayers`. Both the existing test and the new one check this. - I did not run the full renderer, as the brief said it cannot run on this checkout yet. ## Still weak - No pairing falls below 3:1. The weakest is an azure charge on an argent ordinary: about 3.1–3.3:1, lowest on the tower at rail size (3.12). It reads, but less strongly than the others. - Where the charge body lies on the bare field, it is colour on colour (about 1.0–1.1:1). That is expected under this rule: the metal rim and keyline carry the silhouette there, and they measure at least 3.29:1. The test reports this region but does not require a minimum. - The rendered portraits will change. Every shield now has the rim, the keyline and the edge, so any existing sample PNGs and manifest hashes that include arms need regenerating once the renderer runs again.