@333eco/brand 1.4.0 → 1.6.1

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
@@ -73,7 +73,7 @@ scripts/
73
73
  bqr.test.mjs the B-QR decode matrix (`npm run bqr:test`) — three decoders, pre-registered
74
74
  site/ the guidelines pages -> brand.333.eco (an installable PWA)
75
75
  src/partials/ header, footer, head — resolved at BUILD time, not by the
76
- client, so six documents share ONE copy of the chrome
76
+ client, so seven documents share ONE copy of the chrome
77
77
  src/*/index.html one directory per page; vite.config.ts's NAV array is the
78
78
  single source for BOTH rollupOptions.input and the menu
79
79
  brand.lock every package file -> sha256, plus a version
@@ -106,8 +106,8 @@ what a stylesheet cannot say; `dist/` is generated from both.
106
106
  ## B-QR — the drawing every code of ours shares (v1.4.0)
107
107
 
108
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 (*Green B-QR*) or left white inside a thick outline
110
- (*White B-QR*), all in one green, `#14532d`. It is a public shorthand (2026-10-04) for a **drawing style**, not a mark:
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
111
  an H3QR names whom you thank, and a B-QR is how that code is drawn.
112
112
 
113
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**
@@ -118,6 +118,20 @@ an H3QR names whom you thank, and a B-QR is how that code is drawn.
118
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
119
  sweep ran (lightest green at ISO/IEC 15415 grade A that decodes within 2/90 of near-black on two decoders); the
120
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
+ - **The card's words are PLACED, never aligned (v1.6.1).** `paintQrCard` measures each line, shrinks its size until it fits,
132
+ and draws it from the left at the center minus half its width. Safari on iOS 26 ignores `textAlign = "center"` and the
133
+ `maxWidth` argument for a complex script: a Khmer caption printed starting at the center line. Measured on the Simulator
134
+ (ink 602–902 of 1200 in iOS 26.5, 447–748 in 17.0 and 18.x; `measureText` 309 in all). ⛔ Never go back to `textAlign`.
121
135
  - **Run the matrix** after any change to `qr/`: `npm i && npm run bqr:test` (jsQR + ZXing pinned here; OpenCV optional
122
136
  via `BQR_PYTHON`). It must also be seen to FAIL — break the path or the ring on purpose once and watch it catch it.
123
137
 
@@ -265,7 +279,8 @@ node scripts/generate.mjs # rewrite dist/
265
279
  node scripts/generate.mjs --check # prove dist/ is current (CI)
266
280
  node scripts/check-brand.mjs # prove brand.lock matches css/ + emblem/
267
281
  node scripts/check-brand.mjs --write # rewrite brand.lock after a change
268
- cd site && npm run dev # the guidelines page, localhost:57890
282
+ cd site && npm run dev # the guidelines page, localhost:57890 (hot reload)
283
+ cd site && npm run build && npm run preview # the production build, localhost:57891 — its OWN port: the build registers a service worker
269
284
  ```
270
285
 
271
286
  **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.4.0",
2
+ "version": "1.6.1",
3
3
  "files": {
4
4
  "css/metta.css": "9bfe986c46c303bf9a48be85322d68e3d626571a424ef3a8aa81faaf5c866692",
5
5
  "css/motion.css": "9bfbe39c0de6a9dfaf9fdc2c61e327b3c8e70221c34dff9befd85da448b9e0c2",
@@ -10,7 +10,7 @@
10
10
  "emblem/emblem.path.txt": "8377c7bc7f9ab629058b6ee1d9ec058eedb5f473328bf5017bba056f214c2707",
11
11
  "emblem/emblem.svg": "368f520ad2d2f9db50d83ca9cd7aee9475948dc8e38c61b7afa13f7717fef903",
12
12
  "emblem/emblem.ts": "6e150389eed576c392ff6231c0b38b8fea5d4c11f7a5b21936bb25afab069890",
13
- "qr/bqr-card.ts": "e6699d59008fa18d388168fa65e84a851682dd16e47657624c965c7173d5557b",
14
- "qr/bqr.ts": "ce54842fa96b70eed69f67a68c9cb1fd378e16846208fee37b6a459e6a92bf0b"
13
+ "qr/bqr-card.ts": "a62e4ef6de80f353265b7b5839bc4d049d3516c20d775ed788b77da7c84342ca",
14
+ "qr/bqr.ts": "f9e5df6a22fbca5483d3a6e1d91cd70cd0941f51e173c557fcc72836ecfab8bf"
15
15
  }
16
16
  }
package/data/brand.json CHANGED
@@ -8,7 +8,7 @@
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.4.0",
11
+ "version": "1.6.1",
12
12
  "wordmark": {
13
13
  "$comment": [
14
14
  "The composition has an internal short-name as of 2026-09-20: B-Wordmark",
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.4.0"
21
+ const val VERSION = "1.6.1"
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.4.0"
17
+ public static let version = "1.6.1"
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.4.0",
3
+ "version": "1.6.1",
4
4
  "gems": [
5
5
  {
6
6
  "name": "ruby",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@333eco/brand",
3
- "version": "1.4.0",
3
+ "version": "1.6.1",
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",
package/qr/bqr-card.ts CHANGED
@@ -25,6 +25,8 @@ export interface BqrCard {
25
25
  accent?: string;
26
26
  /** Which of the two versions. ⭐ Pass the SAME as the preview. */
27
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;
28
30
  }
29
31
 
30
32
  /**
@@ -33,16 +35,33 @@ export interface BqrCard {
33
35
  */
34
36
  export const CARD = { W: 1200, H: 1560, title: 140, code: { x: 80, y: 205, size: 1040 }, caption: 1318, foot: 1416 } as const;
35
37
 
38
+ /**
39
+ * ⭐ v1.6.1 (2026-10-11) — ONE LINE OF WORDS, PLACED, NEVER ALIGNED: measured, its size reduced until it fits `maxW`, and drawn from
40
+ * its left edge at the center minus half its width.
41
+ * ⛔⛔ Never `textAlign = "center"`, never the `maxWidth` argument of `fillText`: Safari on iOS 26 ignores BOTH for a line it shapes
42
+ * as a complex script. A Khmer caption started AT the center line (a shop owner's print, 2026-10-11) — measured on the Simulator,
43
+ * the same call drew its ink at 602–902 on a 1200 card in iOS 26.5 and at 447–748 in iOS 17.0, 18.0 and 18.2, while `measureText`
44
+ * gave 309 in every one; a Latin line was centered in all of them, and a Khmer line wider than `maxWidth` ran off the card in 26.5.
45
+ * So the placement is computed from `measureText`, which was right everywhere, and the fit is the font size, which every engine honors.
46
+ */
47
+ function placeLine(g: CanvasRenderingContext2D, text: string, y: number, weight: number, size: number, face: string, maxW: number): void {
48
+ g.font = `${weight} ${size}px ${face}`;
49
+ let w = g.measureText(text).width;
50
+ if (w > maxW) {
51
+ g.font = `${weight} ${Math.max(1, Math.floor((size * maxW) / w))}px ${face}`;
52
+ w = g.measureText(text).width;
53
+ }
54
+ g.fillText(text, (CARD.W - w) / 2, y);
55
+ }
56
+
36
57
  /** Paint the card into any 2D context. `face` is the font family the words are set in (the page's own, Khmer included). */
37
58
  export async function paintQrCard(g: CanvasRenderingContext2D, c: BqrCard, face: string): Promise<void> {
38
59
  const { W, H } = CARD;
39
60
  g.fillStyle = "#ffffff"; g.fillRect(0, 0, W, H);
40
- await drawBqr(g, c.url, { ...CARD.code, accent: c.accent, style: c.style });
41
- g.fillStyle = "#16141c"; g.textAlign = "center"; g.textBaseline = "middle";
42
- g.font = `600 72px ${face}`;
43
- g.fillText(c.title, W / 2, CARD.title, W - 120);
44
- g.font = `500 54px ${face}`;
45
- g.fillText(c.caption, W / 2, CARD.caption, W - 120);
46
- g.fillStyle = "#6b6878"; g.font = `400 30px ${face}`;
47
- g.fillText(c.foot, W / 2, CARD.foot, W - 120);
61
+ await drawBqr(g, c.url, { ...CARD.code, accent: c.accent, style: c.style, hue: c.hue });
62
+ g.fillStyle = "#16141c"; g.textAlign = "left"; g.textBaseline = "middle";
63
+ placeLine(g, c.title, CARD.title, 600, 72, face, W - 120);
64
+ placeLine(g, c.caption, CARD.caption, 500, 54, face, W - 120);
65
+ g.fillStyle = "#6b6878";
66
+ placeLine(g, c.foot, CARD.foot, 400, 30, face, W - 120);
48
67
  }
package/qr/bqr.ts CHANGED
@@ -25,8 +25,9 @@
25
25
  * module (measured: one decodes on par with four; zero — decoration touching the finders — halves one decoder), and no decorative
26
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
27
  *
28
- * TWO VERSIONS, the person chooses (a fact about their phone, kept by the app): `pixels` — the *Green B-QR*, the padding filled with
29
- * green modules · `outline` — the *White B-QR*, a white heart with a thick green outline and no decoration.
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.)
30
31
  *
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
32
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
@@ -74,6 +75,78 @@ 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. */
75
76
  export const BQR_INK = "#14532d";
76
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
+ }
77
150
  /** The decorative module's side, as a fraction of a module — a visible gap between neighbours, so no two ever merge. */
78
151
  const DOT = 0.84;
79
152
  /** Share of decorative cells drawn dark (before the run limit thins them). */
@@ -95,10 +168,14 @@ export interface BqrOptions {
95
168
  ecc?: "L" | "M" | "Q" | "H";
96
169
  /** ⭐ §4Z — which of the two versions. Default `BQR_STYLE_DEFAULT`. */
97
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;
98
173
  /** ⛔ TEST ONLY — clear modules between code and decoration (`pixels`). 0 is the broken control `scripts/bqr.test.mjs` must catch. */
99
174
  quiet?: number;
100
175
  /** ⛔ TEST ONLY — the code's colour, for the ink sweep that chose `BQR_INK`. ⛔ Never a theme's colour. */
101
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;
102
179
  }
103
180
  export interface BqrLayout {
104
181
  /** Modules across the code. */
@@ -224,14 +301,21 @@ export function bqrPlacement(size: number, x = 0, y = 0): { k: number; tx: numbe
224
301
  /** Paint a B-QR from a module matrix into a 2D context. Synchronous; `drawBqr` makes the matrix. */
225
302
  export function paintBqr(g: CanvasRenderingContext2D, mat: BqrMatrix, seed: string, o: BqrOptions): void {
226
303
  // ⭐ §4AA — one green for the whole drawing: the decoration and the outline default to the code's own ink.
227
- const X = o.x ?? 0, Y = o.y ?? 0, size = o.size, accent = o.accent || BQR_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;
228
307
  const L = bqrLayout(mat, seed, { style: o.style, quiet: o.quiet });
229
308
  const { k, tx, ty } = bqrPlacement(size, X, Y);
230
309
  const path = new Path2D(EMBLEM_D);
310
+ const ground = bqrGroundOf(o.ground);
231
311
 
232
312
  g.save();
233
- g.fillStyle = PAPER; g.fillRect(X, Y, size, size);
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); }
234
317
  g.translate(tx, ty); g.scale(k, k);
318
+ if (ground === "heart") { g.fillStyle = PAPER; g.fill(path); }
235
319
  // The decoration, clipped to the silhouette.
236
320
  g.save(); g.clip(path); g.fillStyle = accent;
237
321
  const d = DOT * L.m, inset = (L.m - d) / 2;
@@ -244,7 +328,7 @@ export function paintBqr(g: CanvasRenderingContext2D, mat: BqrMatrix, seed: stri
244
328
 
245
329
  // ⭐ The code, in DEVICE pixels with every edge rounded, one rect per run — scaled sub-pixel rects leave hairline seams
246
330
  // between modules, and a seam inside a finder is the last thing a camera should see.
247
- g.save(); g.fillStyle = o.ink || BQR_INK;
331
+ g.save(); g.fillStyle = o.ink || inkOfHue;
248
332
  const px = (u: number) => Math.round(tx + u * k), py = (v: number) => Math.round(ty + v * k);
249
333
  for (let r = 0; r < L.n; r++) {
250
334
  const top = py(L.oy + r * L.m), bottom = py(L.oy + (r + 1) * L.m);
@@ -267,10 +351,11 @@ export async function drawBqr(g: CanvasRenderingContext2D, text: string, o: BqrO
267
351
  }
268
352
 
269
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. */
270
- export async function bqrDataUrl(text: string, o: { size?: number; accent?: string; ecc?: "L" | "M" | "Q" | "H"; style?: BqrStyle } = {}): Promise<string> {
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> {
271
355
  const size = o.size ?? 640;
272
356
  const canvas = document.createElement("canvas");
273
357
  canvas.width = size; canvas.height = size;
274
- await drawBqr(canvas.getContext("2d")!, text, { size, accent: o.accent, ecc: o.ecc, style: o.style });
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 });
275
360
  return canvas.toDataURL("image/png");
276
361
  }