@333eco/brand 1.6.0 → 1.7.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 +16 -3
- package/brand.lock +3 -3
- package/data/bodies.json +26 -0
- package/data/brand.json +1 -1
- package/data/tlds.json +7 -1
- package/dist/Brand.kt +1 -1
- package/dist/Brand.swift +1 -1
- package/dist/tokens.json +8 -2
- package/package.json +1 -1
- package/qr/bqr-card.ts +28 -9
- package/qr/bqr.ts +44 -4
package/README.md
CHANGED
|
@@ -127,7 +127,17 @@ an H3QR names whom you thank, and a B-QR is how that code is drawn.
|
|
|
127
127
|
- **A hue, never a darkness (v1.6.0).** `hue` picks the drawing's color family; `bqrInkFor` draws it at `#14532d`'s
|
|
128
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
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
|
|
130
|
+
green, byte for byte. brand.333.eco/qr/ passes the visitor's `--emblem` (`bqr.test.mjs` §emblem-hue).
|
|
131
|
+
- **A code takes its OWNER's color (v1.7.0) — the body palette.** Products pass `owner`, never `hue`: the six `heartbank.{TLD}`
|
|
132
|
+
domains for HeartBank® (its body color is its domain's), and `SW` (orange robe) · `TH` (sky blue) · `F333` (crimson moon) ·
|
|
133
|
+
`MA` (clear sparkle — graphite in print; on screen the glint moves only with the viewer, never by itself). `heartbank.ceo`
|
|
134
|
+
draws the green byte for byte, so Shops moves nothing. ⛔ `"H3"` alone, an unknown owner, or `owner` with `hue` THROWS — a
|
|
135
|
+
product inherits its body's color and cannot pick one. Semantics in `data/bodies.json` (no hexes); sources in `BQR_OWNER_HUES`;
|
|
136
|
+
pre-registered and decoded before it shipped (`bqr.test.mjs` §body-palette). ⚠️ It says BELONGING, never authenticity.
|
|
137
|
+
- **The card's words are PLACED, never aligned (v1.6.1).** `paintQrCard` measures each line, shrinks its size until it fits,
|
|
138
|
+
and draws it from the left at the center minus half its width. Safari on iOS 26 ignores `textAlign = "center"` and the
|
|
139
|
+
`maxWidth` argument for a complex script: a Khmer caption printed starting at the center line. Measured on the Simulator
|
|
140
|
+
(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`.
|
|
131
141
|
- **Run the matrix** after any change to `qr/`: `npm i && npm run bqr:test` (jsQR + ZXing pinned here; OpenCV optional
|
|
132
142
|
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
143
|
|
|
@@ -195,9 +205,12 @@ fine: a bare specifier the Tailwind plugin resolves. Verified to reach `dist`.
|
|
|
195
205
|
- **A site's accent is DERIVED**, never picked: take the gem whose media type
|
|
196
206
|
*is* that product's medium. Two values cannot derive — `--accent-ink`, and
|
|
197
207
|
`--accent-soft` on a light ground. Measure and pin them per site.
|
|
198
|
-
- **THERE ARE
|
|
208
|
+
- **THERE ARE FOUR PALETTES AND THEY ARE NOT ONE SYSTEM.** A gem means a
|
|
199
209
|
**medium** (7, `gems.json`); an aura stop means a **rate** (7, `auras.json`);
|
|
200
|
-
a rainbow hue means a **domain** (6, `tlds.json`)
|
|
210
|
+
a rainbow hue means a **domain** (6, `tlds.json`); a body color means a
|
|
211
|
+
**body** (5, `bodies.json`, codes and seals only — v1.7.0, 2026-10-12). They
|
|
212
|
+
meet in exactly one place: HeartBank®'s body color IS its domain's, so the
|
|
213
|
+
rainbow's first carrier is H3's codes. The hues rhyme because a
|
|
201
214
|
colour wheel is small. The two sevens are *different sets* — the aura ramp
|
|
202
215
|
carries indigo and ends at violet, the gems carry no indigo and end at
|
|
203
216
|
diamond.
|
package/brand.lock
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.7.0",
|
|
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": "
|
|
14
|
-
"qr/bqr.ts": "
|
|
13
|
+
"qr/bqr-card.ts": "55b4cf3d742bb758f789fd18f91737e8da1169610b6b953ad71e95d8bb713168",
|
|
14
|
+
"qr/bqr.ts": "b980b3187281b8828fe18b019c11615865d1494802ec3ed175f0b0a7e5aba0e5"
|
|
15
15
|
}
|
|
16
16
|
}
|
package/data/bodies.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": [
|
|
3
|
+
"THE BODY PALETTE — the fourth palette (founder 2026-10-12; MA memory project_brand_identity §body-palette).",
|
|
4
|
+
"SEMANTICS ONLY — no hex values live here, as in gems.json. The source hues are in qr/bqr.ts (BQR_OWNER_HUES),",
|
|
5
|
+
"the one place code reads them, and scripts/bqr.test.mjs §body-palette B3 fails if this file and that one disagree.",
|
|
6
|
+
"",
|
|
7
|
+
"⚠️ A color here means a BODY — which of the five owns a code or a seal. Not a medium (gems.json), not a rate",
|
|
8
|
+
"(auras.json), and not a domain (tlds.json) — EXCEPT for H3, the one body organized by domains, whose body color",
|
|
9
|
+
"IS its domain's: an H3 code names its domain, never 'H3'.",
|
|
10
|
+
"",
|
|
11
|
+
"THE CARRIER: CODES AND SEALS ONLY. Never a site accent (that stays gem-derived), never a theme. Pink stays reserved.",
|
|
12
|
+
"KHQR and every bank's code stay plain.",
|
|
13
|
+
"",
|
|
14
|
+
"BELONGING, NEVER AUTHENTICITY. Anyone can print any color; the scan authenticates. Three pairs print alike and",
|
|
15
|
+
"that was accepted (heartbank.us ~ F333, heartbank.me ~ SW, heartbank.org ~ SW): H3's six hues span the wheel.",
|
|
16
|
+
"",
|
|
17
|
+
"Every code prints at the B-QR recipe's darkness (bqrInkFor), so only the hue differs and all bodies scan alike."
|
|
18
|
+
],
|
|
19
|
+
"bodies": [
|
|
20
|
+
{ "body": "H3", "name": "HeartBank®", "color": "rainbow — each code in its DOMAIN's hue", "owners": ["heartbank.us", "heartbank.me", "heartbank.org", "heartbank.ceo", "heartbank.net", "heartbank.com"], "why": "a rainbow is sunlight through water; H3 is the Water body" },
|
|
21
|
+
{ "body": "SW", "name": "Silicon Wat℠", "color": "orange robe", "owners": ["SW"], "prints": "deep ochre", "why": "the robe's kāsāya; SW is the Fire body" },
|
|
22
|
+
{ "body": "TH", "name": "THonly™", "color": "sky blue", "owners": ["TH"], "why": "Mind is the Air body; the sky" },
|
|
23
|
+
{ "body": "F333", "name": "Factory 333™", "color": "crimson moon", "owners": ["F333"], "why": "the workshop on the far side of the Moon; a red moon is lit by Earth's sunrises and sunsets, and F333 is the Earth body" },
|
|
24
|
+
{ "body": "MA", "name": "Miss Aquarius℠", "color": "clear sparkle", "owners": ["MA"], "prints": "graphite", "motion": "on screen the glint moves only when the VIEWER moves (tilt, pointer, scroll) — never by itself; still under reduced motion and in print", "why": "space holds the four colors and has none of its own; the light that crosses it sparkles" }
|
|
25
|
+
]
|
|
26
|
+
}
|
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.
|
|
11
|
+
"version": "1.7.0",
|
|
12
12
|
"wordmark": {
|
|
13
13
|
"$comment": [
|
|
14
14
|
"The composition has an internal short-name as of 2026-09-20: B-Wordmark",
|
package/data/tlds.json
CHANGED
|
@@ -24,7 +24,13 @@
|
|
|
24
24
|
"`cssNamed` below is the CSS keyword that spells the doctrine's word. It is",
|
|
25
25
|
"a RENDERING OF THE NAME, never a pinned value — that is why it is a",
|
|
26
26
|
"keyword and not a hex, and why it is allowed to look untuned beside the",
|
|
27
|
-
"measured gems."
|
|
27
|
+
"measured gems.",
|
|
28
|
+
"",
|
|
29
|
+
"⭐ 2026-10-12 — THE RAINBOW'S FIRST CARRIER: H3's CODES. The founder ruled one color per body on codes and",
|
|
30
|
+
"seals (data/bodies.json), and for H3 the body color is its domain's. The candidate LIGHT values below are",
|
|
31
|
+
"therefore the SOURCE hues of H3's B-QRs (qr/bqr.ts BQR_OWNER_HUES; bqr.test.mjs §body-palette B3 binds the two),",
|
|
32
|
+
"except heartbank.ceo, which keeps the live green #14532d. The B-QR recipe derives each ink, so the light/dark-pair",
|
|
33
|
+
"problem above does not arise for codes. Still NO --color-tld-* tokens: codes are not a theme."
|
|
28
34
|
],
|
|
29
35
|
"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
36
|
"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.",
|
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.
|
|
21
|
+
const val VERSION = "1.7.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.
|
|
17
|
+
public static let version = "1.7.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
|
+
"version": "1.7.0",
|
|
4
4
|
"gems": [
|
|
5
5
|
{
|
|
6
6
|
"name": "ruby",
|
|
@@ -192,7 +192,13 @@
|
|
|
192
192
|
"`cssNamed` below is the CSS keyword that spells the doctrine's word. It is",
|
|
193
193
|
"a RENDERING OF THE NAME, never a pinned value — that is why it is a",
|
|
194
194
|
"keyword and not a hex, and why it is allowed to look untuned beside the",
|
|
195
|
-
"measured gems."
|
|
195
|
+
"measured gems.",
|
|
196
|
+
"",
|
|
197
|
+
"⭐ 2026-10-12 — THE RAINBOW'S FIRST CARRIER: H3's CODES. The founder ruled one color per body on codes and",
|
|
198
|
+
"seals (data/bodies.json), and for H3 the body color is its domain's. The candidate LIGHT values below are",
|
|
199
|
+
"therefore the SOURCE hues of H3's B-QRs (qr/bqr.ts BQR_OWNER_HUES; bqr.test.mjs §body-palette B3 binds the two),",
|
|
200
|
+
"except heartbank.ceo, which keeps the live green #14532d. The B-QR recipe derives each ink, so the light/dark-pair",
|
|
201
|
+
"problem above does not arise for codes. Still NO --color-tld-* tokens: codes are not a theme."
|
|
196
202
|
],
|
|
197
203
|
"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.",
|
|
198
204
|
"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.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@333eco/brand",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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",
|
package/qr/bqr-card.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { drawBqr, type BqrStyle } from "./bqr";
|
|
1
|
+
import { drawBqr, type BqrStyle, type BqrOwner } from "./bqr";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
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
|
|
@@ -27,6 +27,8 @@ export interface BqrCard {
|
|
|
27
27
|
style?: BqrStyle;
|
|
28
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
29
|
hue?: string;
|
|
30
|
+
/** ⭐ v1.7.0 — the owner (`BqrOwner`): the body, or for H3 the domain, whose color the card takes. ⛔ Never with `hue`. ⭐ Pass the SAME as the preview. */
|
|
31
|
+
owner?: BqrOwner;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -35,16 +37,33 @@ export interface BqrCard {
|
|
|
35
37
|
*/
|
|
36
38
|
export const CARD = { W: 1200, H: 1560, title: 140, code: { x: 80, y: 205, size: 1040 }, caption: 1318, foot: 1416 } as const;
|
|
37
39
|
|
|
40
|
+
/**
|
|
41
|
+
* ⭐ v1.6.1 (2026-10-11) — ONE LINE OF WORDS, PLACED, NEVER ALIGNED: measured, its size reduced until it fits `maxW`, and drawn from
|
|
42
|
+
* its left edge at the center minus half its width.
|
|
43
|
+
* ⛔⛔ Never `textAlign = "center"`, never the `maxWidth` argument of `fillText`: Safari on iOS 26 ignores BOTH for a line it shapes
|
|
44
|
+
* as a complex script. A Khmer caption started AT the center line (a shop owner's print, 2026-10-11) — measured on the Simulator,
|
|
45
|
+
* 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`
|
|
46
|
+
* 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.
|
|
47
|
+
* So the placement is computed from `measureText`, which was right everywhere, and the fit is the font size, which every engine honors.
|
|
48
|
+
*/
|
|
49
|
+
function placeLine(g: CanvasRenderingContext2D, text: string, y: number, weight: number, size: number, face: string, maxW: number): void {
|
|
50
|
+
g.font = `${weight} ${size}px ${face}`;
|
|
51
|
+
let w = g.measureText(text).width;
|
|
52
|
+
if (w > maxW) {
|
|
53
|
+
g.font = `${weight} ${Math.max(1, Math.floor((size * maxW) / w))}px ${face}`;
|
|
54
|
+
w = g.measureText(text).width;
|
|
55
|
+
}
|
|
56
|
+
g.fillText(text, (CARD.W - w) / 2, y);
|
|
57
|
+
}
|
|
58
|
+
|
|
38
59
|
/** Paint the card into any 2D context. `face` is the font family the words are set in (the page's own, Khmer included). */
|
|
39
60
|
export async function paintQrCard(g: CanvasRenderingContext2D, c: BqrCard, face: string): Promise<void> {
|
|
40
61
|
const { W, H } = CARD;
|
|
41
62
|
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 = "
|
|
44
|
-
g.
|
|
45
|
-
g
|
|
46
|
-
g.
|
|
47
|
-
g
|
|
48
|
-
g.fillStyle = "#6b6878"; g.font = `400 30px ${face}`;
|
|
49
|
-
g.fillText(c.foot, W / 2, CARD.foot, W - 120);
|
|
63
|
+
await drawBqr(g, c.url, { ...CARD.code, accent: c.accent, style: c.style, hue: c.hue, owner: c.owner });
|
|
64
|
+
g.fillStyle = "#16141c"; g.textAlign = "left"; g.textBaseline = "middle";
|
|
65
|
+
placeLine(g, c.title, CARD.title, 600, 72, face, W - 120);
|
|
66
|
+
placeLine(g, c.caption, CARD.caption, 500, 54, face, W - 120);
|
|
67
|
+
g.fillStyle = "#6b6878";
|
|
68
|
+
placeLine(g, c.foot, CARD.foot, 400, 30, face, W - 120);
|
|
50
69
|
}
|
package/qr/bqr.ts
CHANGED
|
@@ -147,6 +147,40 @@ export function bqrInkFor(hue: string): string {
|
|
|
147
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
148
|
return at(lo);
|
|
149
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* ⭐ v1.7.0 — THE BODY PALETTE (founder 2026-10-12; MA memory `project_brand_identity` §body-palette; roadmap A383). A code's OWNER
|
|
153
|
+
* picks its color family, one per body, on codes and seals only: H3 names a DOMAIN (its body color is its domain's, the six-TLD
|
|
154
|
+
* rainbow), and every other body names itself — SW orange robe · TH sky blue · F333 crimson moon · MA clear sparkle. The ink is
|
|
155
|
+
* `bqrInkFor(source)`, so an owner inherits every property `hue` has: never lighter than the green, the hue kept.
|
|
156
|
+
* ⛔ `"H3"` alone is not an owner, and an owner never travels with a `hue`: `paintBqr` throws on either — a product inherits its
|
|
157
|
+
* body's color and cannot pick one (rule 1 as a property). The palette says BELONGING, never authenticity: anyone can print any
|
|
158
|
+
* color; the scan authenticates.
|
|
159
|
+
* ⭐ `heartbank.ceo` IS `BQR_INK`, byte for byte (Shops unchanged). The other domain sources are `data/tlds.json`'s candidate LIGHT
|
|
160
|
+
* values; `scripts/bqr.test.mjs` §body-palette B3 fails if either file moves without the other.
|
|
161
|
+
*/
|
|
162
|
+
export type BqrOwner =
|
|
163
|
+
| "heartbank.us" | "heartbank.me" | "heartbank.org" | "heartbank.ceo" | "heartbank.net" | "heartbank.com"
|
|
164
|
+
| "SW" | "TH" | "F333" | "MA";
|
|
165
|
+
export const BQR_OWNER_HUES: Readonly<Record<BqrOwner, string>> = {
|
|
166
|
+
"heartbank.us": "#c8102e", // red — HeartBank® Storage
|
|
167
|
+
"heartbank.me": "#c95103", // orange — Thank Your Future Kindness℠
|
|
168
|
+
"heartbank.org": "#9a6f0b", // gold — Treasury (prints olive-brown: gold cannot print light)
|
|
169
|
+
"heartbank.ceo": BQR_INK, // green — Shops, the live green, unchanged
|
|
170
|
+
"heartbank.net": "#0f52ba", // blue — the institutional site, /b/
|
|
171
|
+
"heartbank.com": "#935dc9", // purple — Chronicle, the B-Store
|
|
172
|
+
SW: "#f28500", // orange robe — prints deep ochre, the robe's kāsāya
|
|
173
|
+
TH: "#38bdf8", // sky blue
|
|
174
|
+
F333: "#c1121f", // crimson moon
|
|
175
|
+
MA: "#f4f7ff", // clear sparkle — prints graphite; on screen the glint moves only with the viewer, never by itself
|
|
176
|
+
};
|
|
177
|
+
export const BQR_OWNERS = Object.keys(BQR_OWNER_HUES) as readonly BqrOwner[];
|
|
178
|
+
/** The ink a code owned by `owner` is drawn in. ⛔ Throws on anything that is not a `BqrOwner` — `"H3"` included. */
|
|
179
|
+
export function bqrOwnerInk(owner: BqrOwner): string {
|
|
180
|
+
if (!Object.prototype.hasOwnProperty.call(BQR_OWNER_HUES, owner))
|
|
181
|
+
throw new Error(`B-QR: "${String(owner)}" is not an owner. H3 codes name their domain (heartbank.org, heartbank.ceo, …); the other bodies are SW, TH, F333, MA.`);
|
|
182
|
+
return bqrInkFor(BQR_OWNER_HUES[owner]);
|
|
183
|
+
}
|
|
150
184
|
/** The decorative module's side, as a fraction of a module — a visible gap between neighbours, so no two ever merge. */
|
|
151
185
|
const DOT = 0.84;
|
|
152
186
|
/** Share of decorative cells drawn dark (before the run limit thins them). */
|
|
@@ -174,8 +208,12 @@ export interface BqrOptions {
|
|
|
174
208
|
quiet?: number;
|
|
175
209
|
/** ⛔ TEST ONLY — the code's colour, for the ink sweep that chose `BQR_INK`. ⛔ Never a theme's colour. */
|
|
176
210
|
ink?: string;
|
|
177
|
-
/** ⭐ v1.6.0 — the drawing's color family, drawn at `BQR_INK`'s darkness (`bqrInkFor`). Default: `BQR_INK` itself.
|
|
211
|
+
/** ⭐ v1.6.0 — the drawing's color family, drawn at `BQR_INK`'s darkness (`bqrInkFor`). Default: `BQR_INK` itself.
|
|
212
|
+
* ⛔ Products pass `owner`, never `hue`; `hue` is for the brand page following a visitor's `--emblem`. */
|
|
178
213
|
hue?: string;
|
|
214
|
+
/** ⭐ v1.7.0 — the body (for H3, the domain) that owns this code; its color comes from the body palette (`bqrOwnerInk`).
|
|
215
|
+
* ⛔ Never together with `hue`. */
|
|
216
|
+
owner?: BqrOwner;
|
|
179
217
|
}
|
|
180
218
|
export interface BqrLayout {
|
|
181
219
|
/** Modules across the code. */
|
|
@@ -302,7 +340,9 @@ export function bqrPlacement(size: number, x = 0, y = 0): { k: number; tx: numbe
|
|
|
302
340
|
export function paintBqr(g: CanvasRenderingContext2D, mat: BqrMatrix, seed: string, o: BqrOptions): void {
|
|
303
341
|
// ⭐ §4AA — one green for the whole drawing: the decoration and the outline default to the code's own ink.
|
|
304
342
|
// ⭐ v1.6.0 — `hue` sets the code, the decoration and the outline at once, darkened by `bqrInkFor`; none = `BQR_INK`, verbatim.
|
|
305
|
-
|
|
343
|
+
// ⭐ v1.7.0 — `owner` sets it from the body palette instead; ⛔ both at once throws (a product cannot pick its own color).
|
|
344
|
+
if (o.owner !== undefined && o.hue !== undefined) throw new Error("B-QR: pass `owner` or `hue`, never both — a product's code takes its body's color.");
|
|
345
|
+
const inkOfHue = o.owner !== undefined ? bqrOwnerInk(o.owner) : o.hue ? bqrInkFor(o.hue) : BQR_INK;
|
|
306
346
|
const X = o.x ?? 0, Y = o.y ?? 0, size = o.size, accent = o.accent || inkOfHue;
|
|
307
347
|
const L = bqrLayout(mat, seed, { style: o.style, quiet: o.quiet });
|
|
308
348
|
const { k, tx, ty } = bqrPlacement(size, X, Y);
|
|
@@ -351,11 +391,11 @@ export async function drawBqr(g: CanvasRenderingContext2D, text: string, o: BqrO
|
|
|
351
391
|
}
|
|
352
392
|
|
|
353
393
|
/** 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> {
|
|
394
|
+
export async function bqrDataUrl(text: string, o: { size?: number; accent?: string; ecc?: "L" | "M" | "Q" | "H"; style?: BqrStyle; ground?: BqrGround; hue?: string; owner?: BqrOwner } = {}): Promise<string> {
|
|
355
395
|
const size = o.size ?? 640;
|
|
356
396
|
const canvas = document.createElement("canvas");
|
|
357
397
|
canvas.width = size; canvas.height = size;
|
|
358
398
|
// ⛔ 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 });
|
|
399
|
+
await drawBqr(canvas.getContext("2d")!, text, { size, accent: o.accent, ecc: o.ecc, style: o.style, ground: o.ground, hue: o.hue, owner: o.owner });
|
|
360
400
|
return canvas.toDataURL("image/png");
|
|
361
401
|
}
|