@333eco/brand 1.3.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -58,6 +58,9 @@ emblem/
58
58
  emblem.svg reference copy + the home of the rotation warning
59
59
  emblem.ts Lit template function
60
60
  emblem.path.txt the path `d` string, alone, for generators
61
+ qr/ (v1.4.0) the B-QR recipe — one of OUR codes drawn inside the B-Emblem
62
+ bqr.ts the measured drawing: layout (pure), paint (any 2D context), draw (loads `qrcode`)
63
+ bqr-card.ts the printable card: title, the B-QR, a caption, the address in words
61
64
  data/
62
65
  gems.json gem semantics (MEDIUM). NO hex — those live in tokens.css
63
66
  auras.json aura-ramp semantics (RATE). NO hex — same rule
@@ -67,7 +70,12 @@ dist/ GENERATED, committed: tokens.json · Brand.swift · Brand.
67
70
  scripts/
68
71
  generate.mjs css/ + data/ -> dist/
69
72
  check-brand.mjs the drift guard; copied verbatim into every consumer
70
- site/ the guidelines page -> brand.333.eco (an installable PWA)
73
+ bqr.test.mjs the B-QR decode matrix (`npm run bqr:test`) — three decoders, pre-registered
74
+ site/ the guidelines pages -> brand.333.eco (an installable PWA)
75
+ src/partials/ header, footer, head — resolved at BUILD time, not by the
76
+ client, so seven documents share ONE copy of the chrome
77
+ src/*/index.html one directory per page; vite.config.ts's NAV array is the
78
+ single source for BOTH rollupOptions.input and the menu
71
79
  brand.lock every package file -> sha256, plus a version
72
80
  ```
73
81
 
@@ -95,6 +103,36 @@ DIAMOND"*. This page's own accent stays a site value and does not move.
95
103
  **No value is typed twice.** `css/tokens.css` is canonical; the JSON holds only
96
104
  what a stylesheet cannot say; `dist/` is generated from both.
97
105
 
106
+ ## B-QR — the drawing every code of ours shares (v1.4.0)
107
+
108
+ A **B-QR** is a QR code drawn inside the B-Emblem™: the real code in the emblem's square body with its quiet zone clear,
109
+ the two lobes filled with decorative modules on the same grid (*Full B-QR*) or left open inside a thick outline
110
+ (*Open B-QR*; both names ruled 2026-10-06, replacing *Green* / *White*), all in one green, `#14532d`. It is a public shorthand (2026-10-04) for a **drawing style**, not a mark:
111
+ an H3QR names whom you thank, and a B-QR is how that code is drawn.
112
+
113
+ - **Ours only.** A link to one of our pages is drawn as a B-QR. A bank's code — KHQR, any EMVCo payload — is **never**
114
+ a B-QR: it is the bank's rail under its own design standard, and a bank app's scan-from-gallery is the payment.
115
+ - **Measured, not eyeballed.** The body square is the largest square inside the silhouette less the outline's inner
116
+ half; the painted bounding box (not the viewBox) is centred. `scripts/bqr.test.mjs` re-measures both on every run.
117
+ - **Scanning outranks beauty.** The code keeps one clear module at least; the decoration never draws three dark modules
118
+ in a row, so it cannot imitate a finder pattern. The green was chosen by a rule written into the test **before** the
119
+ sweep ran (lightest green at ISO/IEC 15415 grade A that decodes within 2/90 of near-black on two decoders); the
120
+ prediction was wrong and the rule's pick was kept.
121
+ - **Two grounds (v1.5.0).** `ground: "paper"` (the default) paints the whole square white, as every B-QR before it.
122
+ `ground: "heart"` paints only the silhouette white and leaves the square around it transparent, so on a dark screen the
123
+ B-QR reads as a white heart instead of a white tile. The code is identical on both — dark on white inside the body, quiet
124
+ zone included. **Never inverted** (light modules on dark): many phone scanners never try an inverted code. **`heart` is
125
+ for the screen only** — a download, a print and the card stay `paper`, because a transparent PNG handed to another app may
126
+ be flattened onto black. Pre-registered and decoded on `#0a0a0f` before it shipped (`bqr.test.mjs` §dark-ground).
127
+ - **A hue, never a darkness (v1.6.0).** `hue` picks the drawing's color family; `bqrInkFor` draws it at `#14532d`'s
128
+ luminance, keeping the OKLCH hue and giving up only the chroma sRGB cannot hold that dark — so no caller can draw a code
129
+ that prints lighter than the green. Light hues come out deep (citrine olive-brown, diamond graphite). No `hue` is the
130
+ green, byte for byte; the apps pass none. brand.333.eco/qr/ passes the visitor's `--emblem` (`bqr.test.mjs` §emblem-hue).
131
+ - **Run the matrix** after any change to `qr/`: `npm i && npm run bqr:test` (jsQR + ZXing pinned here; OpenCV optional
132
+ via `BQR_PYTHON`). It must also be seen to FAIL — break the path or the ring on purpose once and watch it catch it.
133
+
134
+ `drawBqr` and `bqrDataUrl` load the `qrcode` package on demand, so a consumer that vendors `qr/` brings `qrcode` itself.
135
+
98
136
  ## Consuming it
99
137
 
100
138
  There is nothing to install and nothing to fetch at build time.
@@ -107,6 +145,11 @@ npm run brand:sync -- --from ../../333.eco/brand.333.eco
107
145
  npm run check:brand
108
146
  ```
109
147
 
148
+ **`qr/` consumers, as of 2026-10-04:** `thank.heartbank.ceo` (HeartBank® Shops) and `thank.heartbank.org`
149
+ (the Treasury app). **Consumers, as of 2026-09-20:** `heartbank.ceo` (the first `heartbank.{TLD}`,
150
+ and the second repo after `333.eco` to vendor a non-CSS file — `emblem.ts`),
151
+ `333.eco`, `seysays`, `sayyourname`, `playsey`.
152
+
110
153
  A consumer holds three files from this repo:
111
154
 
112
155
  | File | Differs per repo? |
@@ -159,10 +202,13 @@ fine: a bare specifier the Tailwind plugin resolves. Verified to reach `dist`.
159
202
  carries indigo and ends at violet, the gems carry no indigo and end at
160
203
  diamond.
161
204
  - **The six-TLD rainbow has NO pinned values, anywhere.** The corpus fixes six
162
- colour *words*; no file fixes a hex. Do not add six tokens to tidy that up —
163
- none of the four consumers is a `heartbank.{TLD}`, so they would ship dead
164
- into all four behind the lock. Pin them when the first one needs them, and
165
- measure contrast then.
205
+ colour *words*; no file fixes a hex. ⚠️ **The reason not to pin them has now
206
+ half-expired:** `heartbank.ceo` became a consumer on 2026-09-20 — the first
207
+ `heartbank.{TLD}` to vendor this layer — so the tokens would no longer ship
208
+ dead into every consumer. What still holds is the harder half: the six hues
209
+ need LIGHT/DARK PAIRS, because three of the six gems fail contrast on one
210
+ ground or the other, and pinning six single values would bake in three
211
+ failures. Measure per theme, then pin.
166
212
  - **The Metta Light chain lives on `.metta`, never on `:root`.** Custom
167
213
  properties inherit their *computed* value, so a chain on `:root` resolves once
168
214
  against root's `--t` and every descendant inherits the finished colour — the
@@ -229,7 +275,8 @@ node scripts/generate.mjs # rewrite dist/
229
275
  node scripts/generate.mjs --check # prove dist/ is current (CI)
230
276
  node scripts/check-brand.mjs # prove brand.lock matches css/ + emblem/
231
277
  node scripts/check-brand.mjs --write # rewrite brand.lock after a change
232
- cd site && npm run dev # the guidelines page, localhost:57890
278
+ cd site && npm run dev # the guidelines page, localhost:57890 (hot reload)
279
+ cd site && npm run build && npm run preview # the production build, localhost:57891 — its OWN port: the build registers a service worker
233
280
  ```
234
281
 
235
282
  **Bump `version` in `data/brand.json`** with any change to `css/` or `emblem/`,
package/brand.lock CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.0",
2
+ "version": "1.6.0",
3
3
  "files": {
4
4
  "css/metta.css": "9bfe986c46c303bf9a48be85322d68e3d626571a424ef3a8aa81faaf5c866692",
5
5
  "css/motion.css": "9bfbe39c0de6a9dfaf9fdc2c61e327b3c8e70221c34dff9befd85da448b9e0c2",
@@ -9,6 +9,8 @@
9
9
  "css/tokens.css": "b0072fc2fa652ad01521d0e5ba3bbd75f47a8161f10395e3d674db3f5d87deb8",
10
10
  "emblem/emblem.path.txt": "8377c7bc7f9ab629058b6ee1d9ec058eedb5f473328bf5017bba056f214c2707",
11
11
  "emblem/emblem.svg": "368f520ad2d2f9db50d83ca9cd7aee9475948dc8e38c61b7afa13f7717fef903",
12
- "emblem/emblem.ts": "6e150389eed576c392ff6231c0b38b8fea5d4c11f7a5b21936bb25afab069890"
12
+ "emblem/emblem.ts": "6e150389eed576c392ff6231c0b38b8fea5d4c11f7a5b21936bb25afab069890",
13
+ "qr/bqr-card.ts": "74655bfee3307d87204d232f188e53bf20d71bdd2766930e9042d09ee8784fed",
14
+ "qr/bqr.ts": "f9e5df6a22fbca5483d3a6e1d91cd70cd0941f51e173c557fcc72836ecfab8bf"
13
15
  }
14
16
  }
package/data/auras.json CHANGED
@@ -25,6 +25,33 @@
25
25
  "meaning": "Circulation velocity, computed as crossings per month over a rolling window and bucketed server-side.",
26
26
  "source": "thank.heartbank.org/functions/src/auras/compute.ts — COLOR_BUCKETS is canonical for the thresholds; this file is canonical for the colours.",
27
27
  "twoRings": "A person carries TWO auras at once — one for Kiitos (gratitude shown) and one for Kiitti (kindness given). Same ramp, two independent positions.",
28
+ "geometry": {
29
+ "$comment": [
30
+ "HOW THE RAMP IS WORN. Extracted from thank.heartbank.org's",
31
+ "aura-avatar component, which stays canonical for the",
32
+ "IMPLEMENTATION; this block is canonical for the INVARIANT.",
33
+ "",
34
+ "No values here either — the reference size and base ring width",
35
+ "belong to the consumer. What is pinned here is the shape and the",
36
+ "one property that must not be lost when a second surface renders",
37
+ "an aura."
38
+ ],
39
+ "innerRing": "Kiitos — gratitude shown. A border on the photo circle.",
40
+ "outerRing": "Kiitti — kindness given. Outside the border. A FAMILY avatar carries the outer ring ONLY; a person carries both.",
41
+ "diameterParity": "⭐ THE INVARIANT, and it is what stops an aura becoming a rank: an avatar's visible total is ALWAYS its declared size plus two base ring widths, whatever the amplitude. A wider ring shrinks the PHOTO; it never grows the avatar. Two people rendered at the same size occupy the same space, so no reading of the geometry makes one of them larger. This is a PROPERTY — remove the enforcer and it still holds, because the arithmetic has nowhere to put the extra width.",
42
+ "amplitudeIsOptIn": "Ring WIDTH carries amplitude only where a surface opts in. The default is width from size alone, so intensity is carried by COLOUR ONLY. Where amplitude is on, each ring is capped as a fraction of size so the photo stays the dominant element.",
43
+ "honestLimit": "⚠️ Parity bounds the FOOTPRINT, not the comparison. With amplitude shown, two rings side by side still differ visibly in width, and width is still legible as more-or-less. The Zero-Point Game's amplitude seam is NARROWED by this, not closed — that seam remains open and is held by the anti-ranking rules, which are rules and not properties."
44
+ },
45
+ "noReading": {
46
+ "$comment": [
47
+ "NOT AN EIGHTH STOP. This is the absence of a position, and it",
48
+ "must not be reachable by bucketing — nothing computes it."
49
+ ],
50
+ "rule": "⛔ A person with no computed aura — never active yet, or a read that FAILED — must NOT be painted at the ramp's floor. Red means measured-and-slow; absence means nothing was measured. Collapsing the two makes the surface assert a fact no computation produced, and it renders the person at their floor to do it.",
51
+ "whyItMatters": "The compute side already honours this on the way IN: a hover at zero counts only while the participant is ACTIVE, because the measure is meant to say 'I keep passing on what I receive' and never 'I hold nothing and do nothing'. A client that paints absence as the floor hands that back.",
52
+ "treatment": "A neutral, NON-CHROMATIC ring that keeps its geometry, so diameter parity is preserved and nothing is painted. Grey — never black or white: each of those goes loud in one theme and vanishes in the other, so the same absence would read as emphatic on a light ground and absent on a dark one. White additionally collides with the diamond gem, a deliberate cool near-white that already means a medium.",
53
+ "values": "Held by the consumer, per this file's no-hex rule. The reference implementation reuses the greys its avatar already uses for the anonymous state, so the vocabulary for 'we are not telling you about this person' is reused rather than invented."
54
+ },
28
55
  "buckets": [
29
56
  { "name": "red", "token": "--color-aura-red", "under": 0.5 },
30
57
  { "name": "orange", "token": "--color-aura-orange", "under": 1.5 },
package/data/brand.json CHANGED
@@ -8,12 +8,26 @@
8
8
  "into brand.lock, which is vendored byte-identical into every consumer,",
9
9
  "so 'which sites are on which brand version' is answerable by grep."
10
10
  ],
11
- "version": "1.3.0",
11
+ "version": "1.6.0",
12
12
  "wordmark": {
13
+ "$comment": [
14
+ "The composition has an internal short-name as of 2026-09-20: B-Wordmark",
15
+ "for the mark-in-word, B-Slogan for the sentence. Internal only — the",
16
+ "® rides on HeartBank and neither short-name carries a mark of its own.",
17
+ "",
18
+ "There is NO wordmark asset and there must not be one. The moment this",
19
+ "ships as an SVG a consumer takes the SVG, and the colour stops",
20
+ "inheriting — the same defect <img src> causes for the mark itself.",
21
+ "It is a COMPOSITION of files a consumer already holds: emblem.ts for",
22
+ "the glyph, tokens.css for --emblem, motion.css for .beating, and the",
23
+ "site's own i18n for the words. brand.333.eco/wordmark/ renders it."
24
+ ],
13
25
  "line": "circulation, not accumulation",
14
26
  "division": "Bank = what accumulates is the RECORD of appreciation. Heart = what circulates is the VALUE.",
15
27
  "slogan": "Thank with HeartBank®",
16
- "substitution": "Wherever possible the B in 'Bank' is replaced by the B-Emblem — 'Thank with Heart♥ank®'. Only the B in Bank, never the T in Thank. Monochrome and plain-text fall back to a literal B."
28
+ "substitution": "Wherever possible the B in 'Bank' is replaced by the B-Emblem — 'Thank with Heart3ank®'. Only the B in Bank, never the T in Thank.",
29
+ "plainText": "Heart3ank®. The stand-in is a 3, NOT a heart character: the mark is bistable as a heart AND a capital B, and ♥ keeps only the half that does not carry the letter. (It is also why the estate's shorthand for HeartBank® is H3.) A literal B remains correct where a 3 would read as a digit — a legal instrument, a form field, anything parsed by machine.",
30
+ "registrationSymbol": "Drawn at full cap height by every typeface: correct at body size, too heavy at display size, where it competes with the mark it defers to. Scale it optically in display settings only; a call site at ~1rem needs no special treatment."
17
31
  },
18
32
  "mark": {
19
33
  "name": "B-Emblem™",
@@ -24,6 +38,18 @@
24
38
  "fill=\"currentColor\"; the page sets --emblem.",
25
39
  "`.beating` goes on CHROME and never beside a person's name."
26
40
  ],
41
+ "geometry": {
42
+ "$comment": "MEASURED with getBBox() on 2026-09-20, not assumed. Two separate facts, and every call site in the estate had inherited both.",
43
+ "pathFillsViewBox": 0.7534,
44
+ "insets": { "top": 0.09312, "right": 0.09312, "bottom": 0.15333, "left": 0.15343 },
45
+ "notFilled": "The path's bounding box is 18.0828 x 18.0851 inside the 24 x 24 viewBox, so the mark paints across 75.34% of its own square. An <svg> sized 1em therefore paints a 0.753em mark, and the heartbeat's 1.3 peak lands at 0.979em \u2014 the box almost exactly. That is why the beat READ AS GROWING TO FIT its slot rather than growing beyond it, and why the rest state looked like the shrunken one.",
46
+ "notCentred": "\u26a0 The bbox origin is (3.6824, 2.2349), so the mark sits HIGH and RIGHT in its viewBox and the four insets above are four different numbers. Symmetric margins cannot square it up, and a hand-tuned vertical-align cannot land it: while the svg box is taller than the text, the mark DRIVES THE LINE BOX, so moving it moves the baseline with it (measured slope -0.39 per px, not -1).",
47
+ "fix": "One move: pull the MARGIN box in to the painted mark on all four sides by its own four insets. Then (a) the inline footprint IS the mark, so no phantom padding; (b) the line box sees the mark's height rather than the larger svg box; and (c) an <svg>'s baseline is its bottom margin edge, which is now the mark's own bottom \u2014 so plain `vertical-align: baseline` lands it on the text baseline with no fudge factor. Measured after: 0.00px, footprint/mark ratio 1.0000, beat overflowing by exactly 30%.",
48
+ "neverTransform": "\u26d4 Do it with the BOX, never with transform: scale(). A CSS animation on `transform` overrides a non-animated one, so `.beating` would silently eat the correction \u2014 the same trap the 45-degree rotation is baked into the path coordinates to avoid.",
49
+ "opticalSize": "\u2b50 Separate from the fix and a free choice, because 'fills its footprint' and 'sits on the baseline' both hold at ANY size \u2014 every margin is derived. Express it as a RATIO TO CAP HEIGHT, never in em: the em box includes ascender and descender room no capital beside the mark ever uses. 1.04 reads as optically LEVEL with the H, because a round/pointed shape needs ~4% overshoot just to look the same size as a flat-topped capital. brand.333.eco ships 1.10 \u2014 the mark stands out a little and is still a letter in a word. 1.18 reads as a logo dropped into a word; 1.38 swamps the letters and the \u00ae with them. \u26a0 Cap height is a property of the display typeface (0.723em for Public Sans 700, measured); a different face changes the number, not the ratio.",
50
+ "opticalNudge": "\u2b50 A small horizontal nudge AFTER the four insets have squared the mark up. The rotated heart carries its visual mass low-left, so it reads a touch close to the letter before it; brand.333.eco moves it 1px right. \u26a0 Spend it through the MARGINS (+x left, \u2212x right) so the total footprint is unchanged \u2014 the mark moves and the letters do not \u2014 and never through `transform`, for the reason above. It is absolute rather than proportional because it corrects how the eye reads the shape, not a fraction of its size; at small sizes check whether it is still wanted.",
51
+ "flexIsDifferent": "\u2b50 This is the BASELINE composition \u2014 the mark inside a word. A chrome lockup that sets the mark beside a label in `display: inline-flex` with `align-items: center` is a DIFFERENT and also-correct convention: it centres the mark on the text's cap band rather than seating it on the baseline, and needs none of the margin work. brand.333.eco's own header does this and measures within 0.8px. \u26a0 Do not 'fix' one to look like the other, and do not probe a flex lockup with an inline-block \u2014 it becomes a flex item and reports a position that is not the baseline."
52
+ },
27
53
  "states": {
28
54
  "static": "Proof of Coordinate ℠ — a meaningful state, not a degradation.",
29
55
  "beating": "Proof of Humanity ℠ — but only where the beat can be verified. Ambient institutional beating claims 'humans run this', not 'this person is human'."
@@ -65,6 +91,6 @@
65
91
  "mono": "IBM Plex Mono — one mono across the estate is a system, two is a coincidence.",
66
92
  "khmer": "Noto Sans Khmer — present on every site in the tree."
67
93
  },
68
- "perSite": "The display face is the only genuine per-site variable. A site that picks an expanded face owns the type-scale consequence."
94
+ "perSite": "The display typeface is the only genuine per-site variable. A site that picks an expanded face owns the type-scale consequence."
69
95
  }
70
96
  }
package/data/tlds.json CHANGED
@@ -29,6 +29,85 @@
29
29
  "order": "Spectrum order, red through violet. The assignments were made per-domain, one at a time, by heart-idiom — that they compose a complete rainbow was found afterwards, and showing them out of spectrum order would hide the only property that makes the allusion earned.",
30
30
  "scope": "HeartBank® — one body of five. This palette is body-scoped in a way the gems and the aura ramp are not; it is documented here because the brand layer is where the three palettes are told apart, not because the institution's colour system is one body's domain map.",
31
31
  "pinned": false,
32
+ "candidateValues": {
33
+ "$comment": [
34
+ "⚠️ CANDIDATES, NOT TOKENS. `pinned` above is still false and these",
35
+ "are deliberately NOT in css/tokens.css — the gate in the top",
36
+ "comment is not met: no heartbank.{TLD} surface vendors this layer",
37
+ "yet (roadmap A187), so twelve tokens would still ship dead into",
38
+ "all four consumers behind brand.lock. This is the working-document",
39
+ "stage the gem palette went through, named in the comment above.",
40
+ "",
41
+ "⭐⭐ THE MEASUREMENT CHANGED THE SHAPE, and that is the finding: a",
42
+ "SINGLE value per TLD CANNOT WORK. Measured against the two grounds",
43
+ "the mark actually sits on, three of the six gem hues fail one side",
44
+ "— ruby 2.50:1 on dark, citrine 1.86:1 on white, sapphire 2.05:1 on",
45
+ "dark — and so does what ships today (gold 1.40:1 on white, aqua",
46
+ "1.25:1, darkorchid 2.57:1 on dark). Pinning six values would have",
47
+ "baked in three failures. The six-TLD rainbow needs LIGHT/DARK",
48
+ "PAIRS, exactly as Tier B already does for every other ground-",
49
+ "dependent value, and for the same reason --accent-ink records: no",
50
+ "formula picks correctly, so measure and pin per theme.",
51
+ "",
52
+ "⛔ THE PAIRS ARE NOT INTERCHANGEABLE. Every light value fails on",
53
+ "the dark ground and every dark value fails on white (all land",
54
+ "1.86-3.26:1). That is what makes the pair structural rather than",
55
+ "decorative — using one value for both themes is the defect.",
56
+ "",
57
+ "Hues are the six saturated gems, per the note above; three pairs",
58
+ "keep the gem hex unchanged on one side, so these are minimal",
59
+ "deviations and not a new palette. ⛔ Same hue, different object,",
60
+ "still no fusion: a gem means a MEDIUM, this means a DOMAIN.",
61
+ "",
62
+ "RATIFYING THEM means: move to css/tokens.css as --l-tld-<hue> and",
63
+ "--d-tld-<hue>, resolve to --tld-<hue> in BOTH theme files, flip",
64
+ "`pinned` to true, and UPDATE THE README TRIPWIRE, which currently",
65
+ "asserts `grep -o -- '--color-tld' css/tokens.css` must be 0."
66
+ ],
67
+ "method": "WCAG 2.x relative luminance. Target 4.5:1 — the mark substitutes for a letter inside a word, so it is read as a letterform and not as a decorative logotype, and the letter-grade threshold is the honest one. (A logotype is formally exempt from contrast requirements; the substitution is what removes the exemption in practice.)",
68
+ "grounds": {
69
+ "light": "#ffffff — the footer and menu ground on every H3 site",
70
+ "dark": "#1f2937 — Tailwind gray-800, the WORST CASE: it is lighter than the brand layer's own --d-bg (#0a0a0f) and --d-surface (#17171d), so a value that clears it clears those too"
71
+ },
72
+ "pairs": {
73
+ "red": {
74
+ "light": "#c8102e",
75
+ "lightRatio": "5.88:1 on #ffffff",
76
+ "dark": "#f25972",
77
+ "darkRatio": "4.51:1 on #1f2937"
78
+ },
79
+ "orange": {
80
+ "light": "#c95103",
81
+ "lightRatio": "4.5:1 on #ffffff",
82
+ "dark": "#f16104",
83
+ "darkRatio": "4.51:1 on #1f2937"
84
+ },
85
+ "gold": {
86
+ "light": "#9a6f0b",
87
+ "lightRatio": "4.51:1 on #ffffff",
88
+ "dark": "#f0b429",
89
+ "darkRatio": "7.87:1 on #1f2937"
90
+ },
91
+ "green": {
92
+ "light": "#00875a",
93
+ "lightRatio": "4.55:1 on #ffffff",
94
+ "dark": "#00a36c",
95
+ "darkRatio": "4.51:1 on #1f2937"
96
+ },
97
+ "blue": {
98
+ "light": "#0f52ba",
99
+ "lightRatio": "7.15:1 on #ffffff",
100
+ "dark": "#4e8ef1",
101
+ "darkRatio": "4.52:1 on #1f2937"
102
+ },
103
+ "purple": {
104
+ "light": "#935dc9",
105
+ "lightRatio": "4.52:1 on #ffffff",
106
+ "dark": "#a87cd3",
107
+ "darkRatio": "4.54:1 on #1f2937"
108
+ }
109
+ }
110
+ },
32
111
  "tlds": [
33
112
  {
34
113
  "tld": "heartbank.us",
package/dist/Brand.kt CHANGED
@@ -18,7 +18,7 @@ import androidx.compose.ui.graphics.lerp
18
18
  import androidx.compose.ui.unit.dp
19
19
 
20
20
  object Brand {
21
- const val VERSION = "1.3.0"
21
+ const val VERSION = "1.6.0"
22
22
 
23
23
  /** The B-Gem media-type palette. A colour here MEANS a medium.
24
24
  * Not a site palette, and not the six-TLD rainbow. */
package/dist/Brand.swift CHANGED
@@ -14,7 +14,7 @@
14
14
  import SwiftUI
15
15
 
16
16
  public enum Brand {
17
- public static let version = "1.3.0"
17
+ public static let version = "1.6.0"
18
18
 
19
19
  /// The B-Gem media-type palette. A colour here MEANS a medium.
20
20
  /// ⚠️ Not a site palette, and not the six-TLD rainbow. Using a gem as an
package/dist/tokens.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$comment": "GENERATED by scripts/generate.mjs. Do not edit. Values are parsed from css/tokens.css, which is canonical; semantics come from data/. Run `node scripts/generate.mjs --check` to prove this file is current.",
3
- "version": "1.3.0",
3
+ "version": "1.6.0",
4
4
  "gems": [
5
5
  {
6
6
  "name": "ruby",
@@ -85,6 +85,33 @@
85
85
  "meaning": "Circulation velocity, computed as crossings per month over a rolling window and bucketed server-side.",
86
86
  "source": "thank.heartbank.org/functions/src/auras/compute.ts — COLOR_BUCKETS is canonical for the thresholds; this file is canonical for the colours.",
87
87
  "twoRings": "A person carries TWO auras at once — one for Kiitos (gratitude shown) and one for Kiitti (kindness given). Same ramp, two independent positions.",
88
+ "geometry": {
89
+ "$comment": [
90
+ "HOW THE RAMP IS WORN. Extracted from thank.heartbank.org's",
91
+ "aura-avatar component, which stays canonical for the",
92
+ "IMPLEMENTATION; this block is canonical for the INVARIANT.",
93
+ "",
94
+ "No values here either — the reference size and base ring width",
95
+ "belong to the consumer. What is pinned here is the shape and the",
96
+ "one property that must not be lost when a second surface renders",
97
+ "an aura."
98
+ ],
99
+ "innerRing": "Kiitos — gratitude shown. A border on the photo circle.",
100
+ "outerRing": "Kiitti — kindness given. Outside the border. A FAMILY avatar carries the outer ring ONLY; a person carries both.",
101
+ "diameterParity": "⭐ THE INVARIANT, and it is what stops an aura becoming a rank: an avatar's visible total is ALWAYS its declared size plus two base ring widths, whatever the amplitude. A wider ring shrinks the PHOTO; it never grows the avatar. Two people rendered at the same size occupy the same space, so no reading of the geometry makes one of them larger. This is a PROPERTY — remove the enforcer and it still holds, because the arithmetic has nowhere to put the extra width.",
102
+ "amplitudeIsOptIn": "Ring WIDTH carries amplitude only where a surface opts in. The default is width from size alone, so intensity is carried by COLOUR ONLY. Where amplitude is on, each ring is capped as a fraction of size so the photo stays the dominant element.",
103
+ "honestLimit": "⚠️ Parity bounds the FOOTPRINT, not the comparison. With amplitude shown, two rings side by side still differ visibly in width, and width is still legible as more-or-less. The Zero-Point Game's amplitude seam is NARROWED by this, not closed — that seam remains open and is held by the anti-ranking rules, which are rules and not properties."
104
+ },
105
+ "noReading": {
106
+ "$comment": [
107
+ "NOT AN EIGHTH STOP. This is the absence of a position, and it",
108
+ "must not be reachable by bucketing — nothing computes it."
109
+ ],
110
+ "rule": "⛔ A person with no computed aura — never active yet, or a read that FAILED — must NOT be painted at the ramp's floor. Red means measured-and-slow; absence means nothing was measured. Collapsing the two makes the surface assert a fact no computation produced, and it renders the person at their floor to do it.",
111
+ "whyItMatters": "The compute side already honours this on the way IN: a hover at zero counts only while the participant is ACTIVE, because the measure is meant to say 'I keep passing on what I receive' and never 'I hold nothing and do nothing'. A client that paints absence as the floor hands that back.",
112
+ "treatment": "A neutral, NON-CHROMATIC ring that keeps its geometry, so diameter parity is preserved and nothing is painted. Grey — never black or white: each of those goes loud in one theme and vanishes in the other, so the same absence would read as emphatic on a light ground and absent on a dark one. White additionally collides with the diamond gem, a deliberate cool near-white that already means a medium.",
113
+ "values": "Held by the consumer, per this file's no-hex rule. The reference implementation reuses the greys its avatar already uses for the anonymous state, so the vocabulary for 'we are not telling you about this person' is reused rather than invented."
114
+ },
88
115
  "buckets": [
89
116
  {
90
117
  "name": "red",
@@ -170,6 +197,85 @@
170
197
  "order": "Spectrum order, red through violet. The assignments were made per-domain, one at a time, by heart-idiom — that they compose a complete rainbow was found afterwards, and showing them out of spectrum order would hide the only property that makes the allusion earned.",
171
198
  "scope": "HeartBank® — one body of five. This palette is body-scoped in a way the gems and the aura ramp are not; it is documented here because the brand layer is where the three palettes are told apart, not because the institution's colour system is one body's domain map.",
172
199
  "pinned": false,
200
+ "candidateValues": {
201
+ "$comment": [
202
+ "⚠️ CANDIDATES, NOT TOKENS. `pinned` above is still false and these",
203
+ "are deliberately NOT in css/tokens.css — the gate in the top",
204
+ "comment is not met: no heartbank.{TLD} surface vendors this layer",
205
+ "yet (roadmap A187), so twelve tokens would still ship dead into",
206
+ "all four consumers behind brand.lock. This is the working-document",
207
+ "stage the gem palette went through, named in the comment above.",
208
+ "",
209
+ "⭐⭐ THE MEASUREMENT CHANGED THE SHAPE, and that is the finding: a",
210
+ "SINGLE value per TLD CANNOT WORK. Measured against the two grounds",
211
+ "the mark actually sits on, three of the six gem hues fail one side",
212
+ "— ruby 2.50:1 on dark, citrine 1.86:1 on white, sapphire 2.05:1 on",
213
+ "dark — and so does what ships today (gold 1.40:1 on white, aqua",
214
+ "1.25:1, darkorchid 2.57:1 on dark). Pinning six values would have",
215
+ "baked in three failures. The six-TLD rainbow needs LIGHT/DARK",
216
+ "PAIRS, exactly as Tier B already does for every other ground-",
217
+ "dependent value, and for the same reason --accent-ink records: no",
218
+ "formula picks correctly, so measure and pin per theme.",
219
+ "",
220
+ "⛔ THE PAIRS ARE NOT INTERCHANGEABLE. Every light value fails on",
221
+ "the dark ground and every dark value fails on white (all land",
222
+ "1.86-3.26:1). That is what makes the pair structural rather than",
223
+ "decorative — using one value for both themes is the defect.",
224
+ "",
225
+ "Hues are the six saturated gems, per the note above; three pairs",
226
+ "keep the gem hex unchanged on one side, so these are minimal",
227
+ "deviations and not a new palette. ⛔ Same hue, different object,",
228
+ "still no fusion: a gem means a MEDIUM, this means a DOMAIN.",
229
+ "",
230
+ "RATIFYING THEM means: move to css/tokens.css as --l-tld-<hue> and",
231
+ "--d-tld-<hue>, resolve to --tld-<hue> in BOTH theme files, flip",
232
+ "`pinned` to true, and UPDATE THE README TRIPWIRE, which currently",
233
+ "asserts `grep -o -- '--color-tld' css/tokens.css` must be 0."
234
+ ],
235
+ "method": "WCAG 2.x relative luminance. Target 4.5:1 — the mark substitutes for a letter inside a word, so it is read as a letterform and not as a decorative logotype, and the letter-grade threshold is the honest one. (A logotype is formally exempt from contrast requirements; the substitution is what removes the exemption in practice.)",
236
+ "grounds": {
237
+ "light": "#ffffff — the footer and menu ground on every H3 site",
238
+ "dark": "#1f2937 — Tailwind gray-800, the WORST CASE: it is lighter than the brand layer's own --d-bg (#0a0a0f) and --d-surface (#17171d), so a value that clears it clears those too"
239
+ },
240
+ "pairs": {
241
+ "red": {
242
+ "light": "#c8102e",
243
+ "lightRatio": "5.88:1 on #ffffff",
244
+ "dark": "#f25972",
245
+ "darkRatio": "4.51:1 on #1f2937"
246
+ },
247
+ "orange": {
248
+ "light": "#c95103",
249
+ "lightRatio": "4.5:1 on #ffffff",
250
+ "dark": "#f16104",
251
+ "darkRatio": "4.51:1 on #1f2937"
252
+ },
253
+ "gold": {
254
+ "light": "#9a6f0b",
255
+ "lightRatio": "4.51:1 on #ffffff",
256
+ "dark": "#f0b429",
257
+ "darkRatio": "7.87:1 on #1f2937"
258
+ },
259
+ "green": {
260
+ "light": "#00875a",
261
+ "lightRatio": "4.55:1 on #ffffff",
262
+ "dark": "#00a36c",
263
+ "darkRatio": "4.51:1 on #1f2937"
264
+ },
265
+ "blue": {
266
+ "light": "#0f52ba",
267
+ "lightRatio": "7.15:1 on #ffffff",
268
+ "dark": "#4e8ef1",
269
+ "darkRatio": "4.52:1 on #1f2937"
270
+ },
271
+ "purple": {
272
+ "light": "#935dc9",
273
+ "lightRatio": "4.52:1 on #ffffff",
274
+ "dark": "#a87cd3",
275
+ "darkRatio": "4.54:1 on #1f2937"
276
+ }
277
+ }
278
+ },
173
279
  "tlds": [
174
280
  {
175
281
  "tld": "heartbank.us",
@@ -546,6 +652,23 @@
546
652
  "fill=\"currentColor\"; the page sets --emblem.",
547
653
  "`.beating` goes on CHROME and never beside a person's name."
548
654
  ],
655
+ "geometry": {
656
+ "$comment": "MEASURED with getBBox() on 2026-09-20, not assumed. Two separate facts, and every call site in the estate had inherited both.",
657
+ "pathFillsViewBox": 0.7534,
658
+ "insets": {
659
+ "top": 0.09312,
660
+ "right": 0.09312,
661
+ "bottom": 0.15333,
662
+ "left": 0.15343
663
+ },
664
+ "notFilled": "The path's bounding box is 18.0828 x 18.0851 inside the 24 x 24 viewBox, so the mark paints across 75.34% of its own square. An <svg> sized 1em therefore paints a 0.753em mark, and the heartbeat's 1.3 peak lands at 0.979em — the box almost exactly. That is why the beat READ AS GROWING TO FIT its slot rather than growing beyond it, and why the rest state looked like the shrunken one.",
665
+ "notCentred": "⚠ The bbox origin is (3.6824, 2.2349), so the mark sits HIGH and RIGHT in its viewBox and the four insets above are four different numbers. Symmetric margins cannot square it up, and a hand-tuned vertical-align cannot land it: while the svg box is taller than the text, the mark DRIVES THE LINE BOX, so moving it moves the baseline with it (measured slope -0.39 per px, not -1).",
666
+ "fix": "One move: pull the MARGIN box in to the painted mark on all four sides by its own four insets. Then (a) the inline footprint IS the mark, so no phantom padding; (b) the line box sees the mark's height rather than the larger svg box; and (c) an <svg>'s baseline is its bottom margin edge, which is now the mark's own bottom — so plain `vertical-align: baseline` lands it on the text baseline with no fudge factor. Measured after: 0.00px, footprint/mark ratio 1.0000, beat overflowing by exactly 30%.",
667
+ "neverTransform": "⛔ Do it with the BOX, never with transform: scale(). A CSS animation on `transform` overrides a non-animated one, so `.beating` would silently eat the correction — the same trap the 45-degree rotation is baked into the path coordinates to avoid.",
668
+ "opticalSize": "⭐ Separate from the fix and a free choice, because 'fills its footprint' and 'sits on the baseline' both hold at ANY size — every margin is derived. Express it as a RATIO TO CAP HEIGHT, never in em: the em box includes ascender and descender room no capital beside the mark ever uses. 1.04 reads as optically LEVEL with the H, because a round/pointed shape needs ~4% overshoot just to look the same size as a flat-topped capital. brand.333.eco ships 1.10 — the mark stands out a little and is still a letter in a word. 1.18 reads as a logo dropped into a word; 1.38 swamps the letters and the ® with them. ⚠ Cap height is a property of the display typeface (0.723em for Public Sans 700, measured); a different face changes the number, not the ratio.",
669
+ "opticalNudge": "⭐ A small horizontal nudge AFTER the four insets have squared the mark up. The rotated heart carries its visual mass low-left, so it reads a touch close to the letter before it; brand.333.eco moves it 1px right. ⚠ Spend it through the MARGINS (+x left, −x right) so the total footprint is unchanged — the mark moves and the letters do not — and never through `transform`, for the reason above. It is absolute rather than proportional because it corrects how the eye reads the shape, not a fraction of its size; at small sizes check whether it is still wanted.",
670
+ "flexIsDifferent": "⭐ This is the BASELINE composition — the mark inside a word. A chrome lockup that sets the mark beside a label in `display: inline-flex` with `align-items: center` is a DIFFERENT and also-correct convention: it centres the mark on the text's cap band rather than seating it on the baseline, and needs none of the margin work. brand.333.eco's own header does this and measures within 0.8px. ⚠ Do not 'fix' one to look like the other, and do not probe a flex lockup with an inline-block — it becomes a flex item and reports a position that is not the baseline."
671
+ },
549
672
  "states": {
550
673
  "static": "Proof of Coordinate ℠ — a meaningful state, not a degradation.",
551
674
  "beating": "Proof of Humanity ℠ — but only where the beat can be verified. Ambient institutional beating claims 'humans run this', not 'this person is human'."
@@ -553,9 +676,23 @@
553
676
  },
554
677
  "emblemPath": "M3.9743 20.0257L3.8824 18.0670C3.5430 11.1232 3.3167 6.5411 5.9896 3.8683C8.1675 1.6904 11.5899 1.6904 13.7678 3.8683C14.9981 5.0986 15.6062 6.8523 15.4719 8.5281C17.1477 8.3938 18.9014 9.0019 20.1317 10.2322C22.3096 12.4101 22.3096 15.8325 20.1317 18.0104C17.4589 20.6833 12.8768 20.4570 5.9260 20.1247L3.9743 20.0257Z",
555
678
  "wordmark": {
679
+ "$comment": [
680
+ "The composition has an internal short-name as of 2026-09-20: B-Wordmark",
681
+ "for the mark-in-word, B-Slogan for the sentence. Internal only — the",
682
+ "® rides on HeartBank and neither short-name carries a mark of its own.",
683
+ "",
684
+ "There is NO wordmark asset and there must not be one. The moment this",
685
+ "ships as an SVG a consumer takes the SVG, and the colour stops",
686
+ "inheriting — the same defect <img src> causes for the mark itself.",
687
+ "It is a COMPOSITION of files a consumer already holds: emblem.ts for",
688
+ "the glyph, tokens.css for --emblem, motion.css for .beating, and the",
689
+ "site's own i18n for the words. brand.333.eco/wordmark/ renders it."
690
+ ],
556
691
  "line": "circulation, not accumulation",
557
692
  "division": "Bank = what accumulates is the RECORD of appreciation. Heart = what circulates is the VALUE.",
558
693
  "slogan": "Thank with HeartBank®",
559
- "substitution": "Wherever possible the B in 'Bank' is replaced by the B-Emblem — 'Thank with Heart♥ank®'. Only the B in Bank, never the T in Thank. Monochrome and plain-text fall back to a literal B."
694
+ "substitution": "Wherever possible the B in 'Bank' is replaced by the B-Emblem — 'Thank with Heart3ank®'. Only the B in Bank, never the T in Thank.",
695
+ "plainText": "Heart3ank®. The stand-in is a 3, NOT a heart character: the mark is bistable as a heart AND a capital B, and ♥ keeps only the half that does not carry the letter. (It is also why the estate's shorthand for HeartBank® is H3.) A literal B remains correct where a 3 would read as a digit — a legal instrument, a form field, anything parsed by machine.",
696
+ "registrationSymbol": "Drawn at full cap height by every typeface: correct at body size, too heavy at display size, where it competes with the mark it defers to. Scale it optically in display settings only; a call site at ~1rem needs no special treatment."
560
697
  }
561
698
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@333eco/brand",
3
- "version": "1.3.0",
3
+ "version": "1.6.0",
4
4
  "description": "The canonical brand layer for the institution — design tokens, themes, motion, and the B-Emblem. A READ-ONLY MIRROR; institution repos vendor this layer, they do not install it.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Thon Ly",
@@ -18,12 +18,14 @@
18
18
  "css",
19
19
  "tailwind",
20
20
  "theme",
21
- "dark-mode"
21
+ "dark-mode",
22
+ "qr-code"
22
23
  ],
23
24
  "type": "module",
24
25
  "exports": {
25
26
  "./css/*": "./css/*",
26
27
  "./emblem/*": "./emblem/*",
28
+ "./qr/*": "./qr/*",
27
29
  "./data/*": "./data/*",
28
30
  "./tokens.json": "./dist/tokens.json",
29
31
  "./Brand.swift": "./dist/Brand.swift",
@@ -34,6 +36,7 @@
34
36
  "files": [
35
37
  "css",
36
38
  "emblem",
39
+ "qr",
37
40
  "data",
38
41
  "dist",
39
42
  "brand.lock"
@@ -41,9 +44,17 @@
41
44
  "scripts": {
42
45
  "check": "node scripts/check-brand.mjs",
43
46
  "check:publish": "node scripts/check-publish.mjs",
44
- "generate": "node scripts/generate.mjs"
47
+ "generate": "node scripts/generate.mjs",
48
+ "bqr:test": "node scripts/bqr.test.mjs"
45
49
  },
46
50
  "publishConfig": {
47
51
  "access": "public"
52
+ },
53
+ "devDependencies": {
54
+ "@napi-rs/canvas": "1.0.10",
55
+ "jsqr": "1.4.0",
56
+ "qrcode": "1.5.4",
57
+ "typescript": "6.0.3",
58
+ "zxing-wasm": "3.1.4"
48
59
  }
49
60
  }
package/qr/bqr-card.ts ADDED
@@ -0,0 +1,50 @@
1
+ import { drawBqr, type BqrStyle } from "./bqr";
2
+
3
+ /**
4
+ * ⭐ A PRINTABLE B-QR CARD — one layout for every code of ours a person may want on paper or in a chat: the title on top (a shop's
5
+ * name, a family's), the code large (drawn fresh at print size, never a screen image stretched), one line saying what it is for,
6
+ * and the address in words underneath, small.
7
+ * ⭐ The code is a B-QR (`./bqr.ts`) — the same drawing as the on-screen preview, so what a person sees is what they print.
8
+ * ⛔ Never a bank's code (KHQR): that stays plain, and is never laid out on this card.
9
+ * ⛔ PURE DRAWING: no DOM, no network. The consumer supplies the canvas, the face and the save; nothing here uploads or counts.
10
+ *
11
+ * Born as `paintQrCard` in the HeartBank® Shops app (2026-10-03); moved here with the recipe on 2026-10-04, so `scripts/bqr.test.mjs`
12
+ * decodes the card exactly as every consumer lays it out.
13
+ * ⛔ VENDORED, NEVER EDITED IN A CONSUMER: `brand.lock` hashes this file.
14
+ */
15
+ export interface BqrCard {
16
+ /** What the code opens. */
17
+ url: string;
18
+ /** Large, at the top. */
19
+ title: string;
20
+ /** One line under the code — what it is for. */
21
+ caption: string;
22
+ /** Small, at the foot — the address in words (and a code a person could type). */
23
+ foot: string;
24
+ /** The decoration and outline colour; absent = `BQR_INK`, one green for the whole drawing. ⭐ Pass the SAME as the preview. */
25
+ accent?: string;
26
+ /** Which of the two versions. ⭐ Pass the SAME as the preview. */
27
+ style?: BqrStyle;
28
+ /** ⭐ v1.6.0 — the drawing's color family, at the green's darkness (`bqrInkFor`). Absent = `BQR_INK`. ⭐ Pass the SAME as the preview. */
29
+ hue?: string;
30
+ }
31
+
32
+ /**
33
+ * The card's layout, in pixels. ⭐ The emblem's square is wider than a plain code would be (900) because the code fills only the
34
+ * emblem's body; the painted bbox is centred inside `code` by `drawBqr`.
35
+ */
36
+ export const CARD = { W: 1200, H: 1560, title: 140, code: { x: 80, y: 205, size: 1040 }, caption: 1318, foot: 1416 } as const;
37
+
38
+ /** Paint the card into any 2D context. `face` is the font family the words are set in (the page's own, Khmer included). */
39
+ export async function paintQrCard(g: CanvasRenderingContext2D, c: BqrCard, face: string): Promise<void> {
40
+ const { W, H } = CARD;
41
+ g.fillStyle = "#ffffff"; g.fillRect(0, 0, W, H);
42
+ await drawBqr(g, c.url, { ...CARD.code, accent: c.accent, style: c.style, hue: c.hue });
43
+ g.fillStyle = "#16141c"; g.textAlign = "center"; g.textBaseline = "middle";
44
+ g.font = `600 72px ${face}`;
45
+ g.fillText(c.title, W / 2, CARD.title, W - 120);
46
+ g.font = `500 54px ${face}`;
47
+ g.fillText(c.caption, W / 2, CARD.caption, W - 120);
48
+ g.fillStyle = "#6b6878"; g.font = `400 30px ${face}`;
49
+ g.fillText(c.foot, W / 2, CARD.foot, W - 120);
50
+ }
package/qr/bqr.ts ADDED
@@ -0,0 +1,361 @@
1
+ /**
2
+ * ⭐ B-QR — one of OUR codes drawn INSIDE the B-Emblem™. A public shorthand since 2026-10-04 (it was internal for a day); born in the
3
+ * HeartBank® Shops app on 2026-10-03 and promoted here on 2026-10-04 so that every surface that prints a code of ours draws the SAME
4
+ * one — a copy in each app would drift, and this drawing is measured, not eyeballed.
5
+ *
6
+ * WHAT IS A B-QR, AND WHAT IS NOT.
7
+ * · ⭐ A B-QR is a DRAWING STYLE for a code that opens one of OUR pages: a shop's *Order here*, a check-in, a referral, and every
8
+ * H3QR that is shown or downloaded (the public H3QR names WHOM YOU THANK; a B-QR is how that code is drawn).
9
+ * · ⛔ A BANK'S CODE IS NEVER A B-QR — KHQR and every EMVCo code stay plain. They are the bank's rail under the bank's own design
10
+ * standard, and a bank app's scan-from-gallery IS the payment.
11
+ *
12
+ * THE DRAWING. The emblem is a heart rotated 45° clockwise, the rotation BAKED into the coordinates (⛔ never a transform): its point
13
+ * bottom-left, a square body, one lobe on top and one on the right. The real code — finder patterns, data and its own clear quiet zone —
14
+ * fills the square body; in the `pixels` version the two lobes are filled with DECORATIVE modules on the same module grid, clipped to the
15
+ * silhouette; an outline draws the silhouette, because the body's own edge is the white quiet zone and would otherwise vanish.
16
+ *
17
+ * ⭐ THE GEOMETRY IS MEASURED, NEVER EYEBALLED (`scripts/bqr.test.mjs` re-measures it on every run, and fails if it moves):
18
+ * · painted bbox 18.0828 × 18.0851 at (3.6824, 2.2349) — `data/brand.json` `mark.geometry`; it fills 75.34% of the viewBox and sits
19
+ * high and right, so ⭐ the PAINTED bbox is centred, never the viewBox;
20
+ * · the body = the largest axis-aligned square inside the silhouette ERODED by the outline's inner half, rasterised at 400 px/unit,
21
+ * shrunk by 0.0125 and centred in it — `pixels` (outline 0.16): 11.35 at (4.0588, 8.5913); `outline` (measured for a 0.48 stroke):
22
+ * 11.085 at (4.2112, 8.7062), now stroked at 0.96 around that SAME body, so the stroke's inner half reaches ≤ 0.24 units into the
23
+ * body's white margin (the test holds a 2-module clear ring around the code).
24
+ * ⭐ SCANNING OUTRANKS BEAUTY: the code is sized for the standard 4-module quiet zone; `pixels` lets its decoration in to ONE clear
25
+ * module (measured: one decodes on par with four; zero — decoration touching the finders — halves one decoder), and no decorative
26
+ * row or column ever holds three dark modules in a run, so the decoration cannot contain a finder's 1:1:3:1:1 at module scale.
27
+ *
28
+ * TWO VERSIONS, the person chooses (a fact about their phone, kept by the app): `pixels` — the *Full B-QR*, the lobes full of
29
+ * modules · `outline` — the *Open B-QR*, the lobes left open inside a thick outline, no decoration. (Public names RULED 2026-10-06,
30
+ * replacing *Green B-QR* / *White B-QR*: a color name stops being true once the color can change — see `hue` below.)
31
+ *
32
+ * ⭐ ONE GREEN, `BQR_INK` = #14532d, for the code, its decoration and its outline — ⛔ never a theme's colour (a light theme must not
33
+ * reach the code). Chosen by a rule written into the test BEFORE its sweep ran: the LIGHTEST candidate that prints at ISO/IEC 15415
34
+ * symbol-contrast grade A (Rpaper 0.85 − Rink ≥ 0.70) and decodes no worse than the old near-black by more than 2 of 90 cases on two
35
+ * independent decoders. The prediction (#106430) was wrong and the rule's pick was kept — ⛔ never move the rule to a preferred shade.
36
+ * ⭐ DETERMINISTIC: the decoration is seeded from a hash of the text, so the same address always draws the same picture and the preview
37
+ * a person sees is the card they download.
38
+ *
39
+ * DEPENDENCIES: `drawBqr` / `bqrDataUrl` load `qrcode` (npm) on demand — the consumer provides it; `paintBqr` needs only a 2D context
40
+ * with `Path2D`; the layout functions are pure. `bqr-card.ts` beside this file lays a B-QR out as a printable card.
41
+ * ⛔ VENDORED, NEVER EDITED IN A CONSUMER: `brand.lock` hashes this file. Change it here, bump `data/brand.json`, re-sync each consumer.
42
+ */
43
+ /** The B-Emblem™ path (viewBox `0 0 24 24`), verbatim from `emblem/emblem.path.txt` (the test asserts it). */
44
+ export const EMBLEM_D = "M3.9743 20.0257L3.8824 18.0670C3.5430 11.1232 3.3167 6.5411 5.9896 3.8683C8.1675 1.6904 11.5899 1.6904 13.7678 3.8683C14.9981 5.0986 15.6062 6.8523 15.4719 8.5281C17.1477 8.3938 18.9014 9.0019 20.1317 10.2322C22.3096 12.4101 22.3096 15.8325 20.1317 18.0104C17.4589 20.6833 12.8768 20.4570 5.9260 20.1247L3.9743 20.0257Z";
45
+ /** The painted bounding box, in viewBox units (brand.json `mark.geometry`). */
46
+ export const EMBLEM_BOX = { x: 3.6824, y: 2.2349, w: 18.0828, h: 18.0851 } as const;
47
+ /** The accent outline's width, in viewBox units. */
48
+ export const BQR_OUTLINE = 0.16;
49
+ /** The square body that holds the code AND its quiet zone, in viewBox units — inside the silhouette less half the outline. */
50
+ export const BQR_BODY = { x: 4.0588, y: 8.5913, s: 11.35 } as const;
51
+ /** Clear modules the CODE IS SIZED FOR inside its body — the standard 4. ⭐ `outline` keeps all four white; `pixels` keeps the code
52
+ * the same size and lets the decoration in to `BQR_FILL_RING` (§4Z, measured — see the header). */
53
+ export const BQR_QUIET = 4;
54
+ /** ⭐ §4Z — `pixels`: clear modules left between the code and the decoration. ⛔ Never 0 (the measured failure). */
55
+ export const BQR_FILL_RING = 1;
56
+
57
+ /** ⭐ §4Z — the two versions, by internal name. ⛔ Neither name is ever shown: a person sees two pictures and two plain words. */
58
+ export type BqrStyle = "pixels" | "outline";
59
+ export const BQR_STYLES: readonly BqrStyle[] = ["pixels", "outline"];
60
+ /** Version 1 first, as the founder listed them. */
61
+ export const BQR_STYLE_DEFAULT: BqrStyle = "pixels";
62
+ /** Each version's outline, body and decoration, in viewBox units — measured (header), re-measured by `scripts/bqr.test.mjs`. */
63
+ export const BQR_GEOMETRY: Record<BqrStyle, { outline: number; body: { x: number; y: number; s: number }; ring: number; decorate: boolean }> = {
64
+ pixels: { outline: BQR_OUTLINE, body: BQR_BODY, ring: BQR_FILL_RING, decorate: true },
65
+ // ⭐ §4AA — the outline doubled (§4Z's 3 × → 6 ×), the body §4Z measured for the 3 × stroke KEPT (the founder's *same size*).
66
+ outline: { outline: BQR_OUTLINE * 6, body: { x: 4.2112, y: 8.7062, s: 11.085 }, ring: BQR_QUIET, decorate: false }
67
+ };
68
+ export const bqrStyleOf = (s: unknown): BqrStyle => (BQR_STYLES as readonly unknown[]).includes(s) ? s as BqrStyle : BQR_STYLE_DEFAULT;
69
+ /** Error correction. ⭐ 'M': the decoration never touches the code (the quiet zone keeps it out), so ECC has only print and
70
+ * camera noise to absorb, and a higher level costs a version — SMALLER modules in the same body. Measured 2026-10-03
71
+ * (`bqr.test.mjs` ECC sweep, bare card at 300/200/150 px × 6 distortions × 5 payloads, decoded of 90, jsQR/ZXing/OpenCV):
72
+ * L 68/82/42 · M 76/83/48 · Q 76/81/49 · H 66/76/44 — M best or tied on every decoder but OpenCV, where Q is one ahead. */
73
+ export const BQR_ECC = "M" as const;
74
+
75
+ /** ⭐ §4AA — the code's modules: the green the pre-registered rule in `scripts/bqr.test.mjs` picked (header above). ⛔ Never a theme's. */
76
+ export const BQR_INK = "#14532d";
77
+ const PAPER = "#ffffff";
78
+
79
+ /**
80
+ * ⭐ v1.5.0 (2026-10-06) — WHERE THE PAPER IS. `paper` (the default): the whole square is white, as every B-QR was drawn before.
81
+ * `heart`: only the silhouette is white and the square around it is left transparent, so on a dark ground the B-QR reads as a
82
+ * white heart instead of a white tile.
83
+ * ⭐ THE CODE DOES NOT CHANGE BETWEEN THE TWO: it stays dark-on-white inside the body, quiet zone included, which is all a camera
84
+ * reads. Only what lies outside the silhouette changes. `scripts/bqr.test.mjs` §dark-ground decodes `heart` on the dark ground.
85
+ * ⛔ NEVER INVERTED (light modules on a dark ground). Many phone scanners never try an inverted code, and this matrix runs jsQR with
86
+ * inversion off for exactly that reason. A dark ground is why `heart` exists; it is never a reason to invert the code.
87
+ * ⛔ ON SCREEN ONLY. A download, a print and the card (`bqr-card.ts`) stay `paper`: a transparent PNG handed to another app may be
88
+ * flattened onto black, and the picture a person saves must be the one they will see wherever they send it.
89
+ */
90
+ export type BqrGround = "paper" | "heart";
91
+ export const BQR_GROUNDS: readonly BqrGround[] = ["paper", "heart"];
92
+ export const BQR_GROUND_DEFAULT: BqrGround = "paper";
93
+ export const bqrGroundOf = (s: unknown): BqrGround => (BQR_GROUNDS as readonly unknown[]).includes(s) ? s as BqrGround : BQR_GROUND_DEFAULT;
94
+
95
+ /**
96
+ * ⭐ v1.6.0 (2026-10-06) — A HUE, NEVER A DARKNESS. `hue` lets a caller choose the drawing's color FAMILY; the recipe draws it at
97
+ * `BQR_INK`'s relative luminance (the darkness the pre-registered ink rule chose), keeping the hue and giving up only the chroma
98
+ * sRGB cannot hold that dark. So a caller can pick ruby, citrine or even diamond and still never draw a code that prints below
99
+ * grade A or scans worse than the green: ⭐ the darkness is a PROPERTY of the recipe, not a rule a caller must remember.
100
+ * Light hues come out deep — citrine as an olive-brown, diamond as a graphite — and that is the honest result, not a defect.
101
+ * ⭐ No `hue` = `BQR_INK` itself, verbatim, so every drawing that passes none is byte-identical to v1.5.0 — the apps pass none and
102
+ * keep the one green (founder 2026-10-06: the brand page's B-QRs follow the selected `--emblem`; the apps were not ruled).
103
+ * `scripts/bqr.test.mjs` §emblem-hue decodes every gem's derivation before it shipped.
104
+ */
105
+ const lin8 = (c: number) => { c /= 255; return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4; };
106
+ const gam = (c: number) => (c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055);
107
+ /** Relative luminance of an 8-bit sRGB triple (WCAG). */
108
+ const luminance = ([r, g, b]: readonly number[]) => 0.2126 * lin8(r) + 0.7152 * lin8(g) + 0.0722 * lin8(b);
109
+ /** `#rrggbb` or `rgb(…)` / `rgba(…)` (what `getComputedStyle` returns) → an 8-bit triple, or null. */
110
+ function rgbOf(color: string): [number, number, number] | null {
111
+ const h = /^#([0-9a-f]{6})$/i.exec(color.trim());
112
+ if (h) { const n = parseInt(h[1], 16); return [n >> 16, (n >> 8) & 255, n & 255]; }
113
+ const f = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(color.trim());
114
+ return f ? [Number(f[1]), Number(f[2]), Number(f[3])].map((v) => Math.max(0, Math.min(255, Math.round(v)))) as [number, number, number] : null;
115
+ }
116
+ /** OKLab ⇄ linear sRGB (Björn Ottosson's published matrices). */
117
+ function oklab([r, g, b]: readonly number[]): [number, number, number] {
118
+ const [R, G, B2] = [r, g, b].map(lin8);
119
+ const l = Math.cbrt(0.4122214708 * R + 0.5363325363 * G + 0.0514459929 * B2);
120
+ const m = Math.cbrt(0.2119034982 * R + 0.6806995451 * G + 0.1073969566 * B2);
121
+ const s = Math.cbrt(0.0883024619 * R + 0.2817188376 * G + 0.6299787005 * B2);
122
+ return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s];
123
+ }
124
+ function linearOf(L: number, a: number, b: number): [number, number, number] {
125
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3, m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3, s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
126
+ return [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s];
127
+ }
128
+ const inGamut = (v: readonly number[]) => v.every((c) => c >= -1e-6 && c <= 1 + 1e-6);
129
+ const hex8 = (v: readonly number[]) => "#" + v.map((c) => Math.round(Math.max(0, Math.min(1, gam(c))) * 255).toString(16).padStart(2, "0")).join("");
130
+ const INK_LUM = luminance(rgbOf(BQR_INK)!);
131
+
132
+ /** ⭐ v1.6.0 — the color a B-QR is drawn in for `hue`: the same OKLCH hue, at the most chroma sRGB holds, at the largest OKLab
133
+ * lightness whose 8-bit result is NO LIGHTER than `BQR_INK` (so it never prints lighter than the green). Unparseable → `BQR_INK`. */
134
+ export function bqrInkFor(hue: string): string {
135
+ if (hue.trim().toLowerCase() === BQR_INK) return BQR_INK;
136
+ const rgb = rgbOf(hue);
137
+ if (!rgb) return BQR_INK;
138
+ const [, a0, b0] = oklab(rgb), C0 = Math.hypot(a0, b0), H = Math.atan2(b0, a0);
139
+ const at = (L: number) => {
140
+ let lo = 0, hi = C0; // the most chroma, up to the hue's own, that sRGB holds at L
141
+ if (!inGamut(linearOf(L, hi * Math.cos(H), hi * Math.sin(H))))
142
+ for (let i = 0; i < 24; i++) { const c = (lo + hi) / 2; if (inGamut(linearOf(L, c * Math.cos(H), c * Math.sin(H)))) lo = c; else hi = c; }
143
+ else lo = hi;
144
+ return hex8(linearOf(L, lo * Math.cos(H), lo * Math.sin(H)));
145
+ };
146
+ let lo = 0, hi = 1; // ⭐ invariant: at(lo) is never lighter than BQR_INK (black, at 0)
147
+ for (let i = 0; i < 32; i++) { const L = (lo + hi) / 2; if (luminance(rgbOf(at(L))!) > INK_LUM) hi = L; else lo = L; }
148
+ return at(lo);
149
+ }
150
+ /** The decorative module's side, as a fraction of a module — a visible gap between neighbours, so no two ever merge. */
151
+ const DOT = 0.84;
152
+ /** Share of decorative cells drawn dark (before the run limit thins them). */
153
+ const DENSITY = 0.6;
154
+ /** Margin around the painted bbox, as a fraction of the drawing's side (the outline is never cut by the edge). */
155
+ export const BQR_PAD = 0.03;
156
+
157
+ /** The module matrix, row-major — `QRCode.create(...).modules` is one. */
158
+ export interface BqrMatrix { size: number; data: ArrayLike<number | boolean> }
159
+ export interface BqrOptions {
160
+ /** Top-left of the square the drawing occupies, in canvas pixels. */
161
+ x?: number;
162
+ y?: number;
163
+ /** The square's side, in canvas pixels. */
164
+ size: number;
165
+ /** The decoration and outline colour. Default (§4AA): `BQR_INK`, so the whole drawing is one green. ⚠️ No caller passes one. */
166
+ accent?: string;
167
+ /** Error correction level. Default `BQR_ECC`. */
168
+ ecc?: "L" | "M" | "Q" | "H";
169
+ /** ⭐ §4Z — which of the two versions. Default `BQR_STYLE_DEFAULT`. */
170
+ style?: BqrStyle;
171
+ /** ⭐ v1.5.0 — where the paper is (`BqrGround`, above). Default `paper`. ⛔ `heart` is for the screen, never a download or print. */
172
+ ground?: BqrGround;
173
+ /** ⛔ TEST ONLY — clear modules between code and decoration (`pixels`). 0 is the broken control `scripts/bqr.test.mjs` must catch. */
174
+ quiet?: number;
175
+ /** ⛔ TEST ONLY — the code's colour, for the ink sweep that chose `BQR_INK`. ⛔ Never a theme's colour. */
176
+ ink?: string;
177
+ /** ⭐ v1.6.0 — the drawing's color family, drawn at `BQR_INK`'s darkness (`bqrInkFor`). Default: `BQR_INK` itself. */
178
+ hue?: string;
179
+ }
180
+ export interface BqrLayout {
181
+ /** Modules across the code. */
182
+ n: number;
183
+ /** One module, in viewBox units. */
184
+ m: number;
185
+ /** The code's top-left module, in viewBox units. */
186
+ ox: number;
187
+ oy: number;
188
+ /** Dark decorative cells, as [column, row] on the code's grid (negative = left of / above the code). Empty for `outline`. */
189
+ deco: [number, number][];
190
+ /** ⭐ §4Z — the version this layout is for, and its outline width (viewBox units). */
191
+ style: BqrStyle;
192
+ outline: number;
193
+ }
194
+
195
+ // ---- the silhouette as a polygon (pure — no canvas, so the test can check it) ---------------------------------------------------
196
+
197
+ type Pt = [number, number];
198
+ let POLY: Pt[] | null = null;
199
+ /** Flatten the path (absolute M / L / C / Z only — all this path uses) into a closed polygon. */
200
+ function silhouette(): Pt[] {
201
+ if (POLY) return POLY;
202
+ const tok = EMBLEM_D.match(/[MLCZ]|-?\d*\.?\d+/g) ?? [];
203
+ const out: Pt[] = [];
204
+ let i = 0, cmd = "", cur: Pt = [0, 0];
205
+ const num = () => Number(tok[i++]);
206
+ while (i < tok.length) {
207
+ if (/[MLCZ]/.test(tok[i])) cmd = tok[i++];
208
+ if (cmd === "M" || cmd === "L") { cur = [num(), num()]; out.push(cur); }
209
+ else if (cmd === "C") {
210
+ const p1: Pt = [num(), num()], p2: Pt = [num(), num()], p3: Pt = [num(), num()], p0 = cur;
211
+ for (let k = 1; k <= 32; k++) {
212
+ const t = k / 32, u = 1 - t;
213
+ out.push([u * u * u * p0[0] + 3 * u * u * t * p1[0] + 3 * u * t * t * p2[0] + t * t * t * p3[0],
214
+ u * u * u * p0[1] + 3 * u * u * t * p1[1] + 3 * u * t * t * p2[1] + t * t * t * p3[1]]);
215
+ }
216
+ cur = p3;
217
+ } else if (cmd === "Z") break;
218
+ }
219
+ return (POLY = out);
220
+ }
221
+ /** Even-odd point-in-polygon. */
222
+ export function insideEmblem(x: number, y: number): boolean {
223
+ const P = silhouette();
224
+ let hit = false;
225
+ for (let a = 0, b = P.length - 1; a < P.length; b = a++) {
226
+ const [xa, ya] = P[a], [xb, yb] = P[b];
227
+ if ((ya > y) !== (yb > y) && x < ((xb - xa) * (y - ya)) / (yb - ya) + xa) hit = !hit;
228
+ }
229
+ return hit;
230
+ }
231
+ /** Distance from a point to the silhouette's edge. */
232
+ function edgeDistance(x: number, y: number): number {
233
+ const P = silhouette();
234
+ let best = Infinity;
235
+ for (let a = 0, b = P.length - 1; a < P.length; b = a++) {
236
+ const [xa, ya] = P[b], [xb, yb] = P[a];
237
+ const dx = xb - xa, dy = yb - ya, L = dx * dx + dy * dy;
238
+ const t = L ? Math.max(0, Math.min(1, ((x - xa) * dx + (y - ya) * dy) / L)) : 0;
239
+ best = Math.min(best, Math.hypot(x - (xa + t * dx), y - (ya + t * dy)));
240
+ }
241
+ return best;
242
+ }
243
+
244
+ // ---- the layout (pure) ------------------------------------------------------------------------------------------------------------
245
+
246
+ /** FNV-1a, then mulberry32: a fixed stream of numbers from the text — ⛔ never `Math.random` at draw time. */
247
+ function stream(seed: string): () => number {
248
+ let h = 0x811c9dc5;
249
+ for (let i = 0; i < seed.length; i++) { h ^= seed.charCodeAt(i); h = Math.imul(h, 0x01000193); }
250
+ let s = h >>> 0;
251
+ return () => {
252
+ s = (s + 0x6d2b79f5) >>> 0;
253
+ let t = s;
254
+ t = Math.imul(t ^ (t >>> 15), t | 1);
255
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
256
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
257
+ };
258
+ }
259
+
260
+ /**
261
+ * Where everything goes, in viewBox units. The module grid is the code's own, extended over the whole emblem; a decorative cell
262
+ * is a candidate when it lies outside the code's quiet box AND its dot clears the outline; it is dark by the seeded stream unless
263
+ * that would make a third dark cell in a row or a column.
264
+ */
265
+ export function bqrLayout(mat: BqrMatrix, seed: string, o: { style?: BqrStyle; quiet?: number } = {}): BqrLayout {
266
+ const style = bqrStyleOf(o.style), G = BQR_GEOMETRY[style];
267
+ const quiet = o.quiet ?? G.ring;
268
+ const n = mat.size;
269
+ const m = G.body.s / (n + 2 * BQR_QUIET);
270
+ // ⭐ The code is centred in the body; the ring only says how close the decoration may come (§4Z: 1 for `pixels`; the
271
+ // broken control's 0 lets it touch), never moves the code.
272
+ const ox = G.body.x + BQR_QUIET * m, oy = G.body.y + BQR_QUIET * m;
273
+ if (!G.decorate) return { n, m, ox, oy, deco: [], style, outline: G.outline };
274
+ const c0 = Math.floor((EMBLEM_BOX.x - ox) / m) - 1, c1 = Math.ceil((EMBLEM_BOX.x + EMBLEM_BOX.w - ox) / m) + 1;
275
+ const r0 = Math.floor((EMBLEM_BOX.y - oy) / m) - 1, r1 = Math.ceil((EMBLEM_BOX.y + EMBLEM_BOX.h - oy) / m) + 1;
276
+ const clear = (DOT / 2) * m * Math.SQRT2 + G.outline / 2 + 0.15 * m;
277
+ const rand = stream(seed);
278
+ const dark = new Set<string>();
279
+ const deco: [number, number][] = [];
280
+ const on = (c: number, r: number) => dark.has(`${c},${r}`);
281
+ for (let r = r0; r <= r1; r++) for (let c = c0; c <= c1; c++) {
282
+ const p = rand(); // ⭐ drawn for EVERY cell, so the stream never depends on the outline
283
+ if (c >= -quiet && c < n + quiet && r >= -quiet && r < n + quiet) continue;
284
+ const cx = ox + (c + 0.5) * m, cy = oy + (r + 0.5) * m;
285
+ if (!insideEmblem(cx, cy) || edgeDistance(cx, cy) < clear) continue;
286
+ if (p >= DENSITY) continue;
287
+ if ((on(c - 1, r) && on(c - 2, r)) || (on(c, r - 1) && on(c, r - 2))) continue; // ⛔ never three in a run
288
+ dark.add(`${c},${r}`); deco.push([c, r]);
289
+ }
290
+ return { n, m, ox, oy, deco, style, outline: G.outline };
291
+ }
292
+
293
+ // ---- drawing ------------------------------------------------------------------------------------------------------------------------
294
+
295
+ /** Where the emblem lands in a `size` square at (x, y): canvas px = t + k · viewBox units. ⭐ Centres the PAINTED bbox, never the viewBox. */
296
+ export function bqrPlacement(size: number, x = 0, y = 0): { k: number; tx: number; ty: number } {
297
+ const k = (size * (1 - 2 * BQR_PAD)) / Math.max(EMBLEM_BOX.w, EMBLEM_BOX.h);
298
+ return { k, tx: x + (size - EMBLEM_BOX.w * k) / 2 - EMBLEM_BOX.x * k, ty: y + (size - EMBLEM_BOX.h * k) / 2 - EMBLEM_BOX.y * k };
299
+ }
300
+
301
+ /** Paint a B-QR from a module matrix into a 2D context. Synchronous; `drawBqr` makes the matrix. */
302
+ export function paintBqr(g: CanvasRenderingContext2D, mat: BqrMatrix, seed: string, o: BqrOptions): void {
303
+ // ⭐ §4AA — one green for the whole drawing: the decoration and the outline default to the code's own ink.
304
+ // ⭐ v1.6.0 — `hue` sets the code, the decoration and the outline at once, darkened by `bqrInkFor`; none = `BQR_INK`, verbatim.
305
+ const inkOfHue = o.hue ? bqrInkFor(o.hue) : BQR_INK;
306
+ const X = o.x ?? 0, Y = o.y ?? 0, size = o.size, accent = o.accent || inkOfHue;
307
+ const L = bqrLayout(mat, seed, { style: o.style, quiet: o.quiet });
308
+ const { k, tx, ty } = bqrPlacement(size, X, Y);
309
+ const path = new Path2D(EMBLEM_D);
310
+ const ground = bqrGroundOf(o.ground);
311
+
312
+ g.save();
313
+ // ⭐ v1.5.0 — the drawing owns its square either way: `heart` CLEARS it (a reused canvas keeps nothing from the last drawing),
314
+ // then lays the paper down inside the silhouette only. The decoration, the outline and the code are drawn the same on both.
315
+ if (ground === "heart") g.clearRect(X, Y, size, size);
316
+ else { g.fillStyle = PAPER; g.fillRect(X, Y, size, size); }
317
+ g.translate(tx, ty); g.scale(k, k);
318
+ if (ground === "heart") { g.fillStyle = PAPER; g.fill(path); }
319
+ // The decoration, clipped to the silhouette.
320
+ g.save(); g.clip(path); g.fillStyle = accent;
321
+ const d = DOT * L.m, inset = (L.m - d) / 2;
322
+ for (const [c, r] of L.deco) g.fillRect(L.ox + c * L.m + inset, L.oy + r * L.m + inset, d, d);
323
+ g.restore();
324
+ // The outline.
325
+ // ⭐ §4Z — `outline` (Version 2) draws this wider, over a heart left white (§4AA: six times as wide).
326
+ g.strokeStyle = accent; g.lineWidth = L.outline; g.lineJoin = "round"; g.stroke(path);
327
+ g.restore();
328
+
329
+ // ⭐ The code, in DEVICE pixels with every edge rounded, one rect per run — scaled sub-pixel rects leave hairline seams
330
+ // between modules, and a seam inside a finder is the last thing a camera should see.
331
+ g.save(); g.fillStyle = o.ink || inkOfHue;
332
+ const px = (u: number) => Math.round(tx + u * k), py = (v: number) => Math.round(ty + v * k);
333
+ for (let r = 0; r < L.n; r++) {
334
+ const top = py(L.oy + r * L.m), bottom = py(L.oy + (r + 1) * L.m);
335
+ for (let c = 0; c < L.n; c++) {
336
+ if (!mat.data[r * L.n + c]) continue;
337
+ let e = c; while (e + 1 < L.n && mat.data[r * L.n + e + 1]) e++;
338
+ const left = px(L.ox + c * L.m);
339
+ g.fillRect(left, top, px(L.ox + (e + 1) * L.m) - left, bottom - top);
340
+ c = e;
341
+ }
342
+ }
343
+ g.restore();
344
+ }
345
+
346
+ /** Make the code for `text` and paint it as a B-QR. ⭐ The renderer is loaded when needed, as everywhere else. */
347
+ export async function drawBqr(g: CanvasRenderingContext2D, text: string, o: BqrOptions): Promise<void> {
348
+ const QRCode = (await import("qrcode")).default;
349
+ const q = QRCode.create(text, { errorCorrectionLevel: o.ecc ?? BQR_ECC });
350
+ paintBqr(g, q.modules, text, o);
351
+ }
352
+
353
+ /** A B-QR as a PNG data URL — the on-screen preview of a code a person may also download, so what they see is what they print. */
354
+ export async function bqrDataUrl(text: string, o: { size?: number; accent?: string; ecc?: "L" | "M" | "Q" | "H"; style?: BqrStyle; ground?: BqrGround; hue?: string } = {}): Promise<string> {
355
+ const size = o.size ?? 640;
356
+ const canvas = document.createElement("canvas");
357
+ canvas.width = size; canvas.height = size;
358
+ // ⛔ v1.5.0 — `ground: "heart"` only for a picture that stays on screen; a URL handed to a download takes the default `paper`.
359
+ await drawBqr(canvas.getContext("2d")!, text, { size, accent: o.accent, ecc: o.ecc, style: o.style, ground: o.ground, hue: o.hue });
360
+ return canvas.toDataURL("image/png");
361
+ }