@333eco/brand 1.6.1 → 1.7.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 +14 -4
- 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 +4 -2
- package/qr/bqr.ts +51 -8
package/README.md
CHANGED
|
@@ -107,7 +107,8 @@ what a stylesheet cannot say; `dist/` is generated from both.
|
|
|
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
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
|
|
110
|
+
(*Open B-QR*; both names ruled 2026-10-06, replacing *Green* / *White*), all in one ink — the green `#14532d` by default, or
|
|
111
|
+
its owner's since v1.7.0 (the body palette, below; ⚠️ *one green for every app* is SUPERSEDED as of 2026-10-12). It is a public shorthand (2026-10-04) for a **drawing style**, not a mark:
|
|
111
112
|
an H3QR names whom you thank, and a B-QR is how that code is drawn.
|
|
112
113
|
|
|
113
114
|
- **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**
|
|
@@ -127,7 +128,13 @@ an H3QR names whom you thank, and a B-QR is how that code is drawn.
|
|
|
127
128
|
- **A hue, never a darkness (v1.6.0).** `hue` picks the drawing's color family; `bqrInkFor` draws it at `#14532d`'s
|
|
128
129
|
luminance, keeping the OKLCH hue and giving up only the chroma sRGB cannot hold that dark — so no caller can draw a code
|
|
129
130
|
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
|
|
131
|
+
green, byte for byte. brand.333.eco/qr/ passes the visitor's `--emblem` (`bqr.test.mjs` §emblem-hue).
|
|
132
|
+
- **A code takes its OWNER's color (v1.7.0) — the body palette.** Products pass `owner`, never `hue`: the six `heartbank.{TLD}`
|
|
133
|
+
domains for HeartBank® (its body color is its domain's), and `SW` (orange robe) · `TH` (sky blue) · `F333` (crimson moon) ·
|
|
134
|
+
`MA` (clear sparkle — graphite in print; on screen the glint moves only with the viewer, never by itself). `heartbank.ceo`
|
|
135
|
+
draws the green byte for byte, so Shops moves nothing. ⛔ `"H3"` alone, an unknown owner, or `owner` with `hue` THROWS — a
|
|
136
|
+
product inherits its body's color and cannot pick one. Semantics in `data/bodies.json` (no hexes); sources in `BQR_OWNER_HUES`;
|
|
137
|
+
pre-registered and decoded before it shipped (`bqr.test.mjs` §body-palette). ⚠️ It says BELONGING, never authenticity.
|
|
131
138
|
- **The card's words are PLACED, never aligned (v1.6.1).** `paintQrCard` measures each line, shrinks its size until it fits,
|
|
132
139
|
and draws it from the left at the center minus half its width. Safari on iOS 26 ignores `textAlign = "center"` and the
|
|
133
140
|
`maxWidth` argument for a complex script: a Khmer caption printed starting at the center line. Measured on the Simulator
|
|
@@ -199,9 +206,12 @@ fine: a bare specifier the Tailwind plugin resolves. Verified to reach `dist`.
|
|
|
199
206
|
- **A site's accent is DERIVED**, never picked: take the gem whose media type
|
|
200
207
|
*is* that product's medium. Two values cannot derive — `--accent-ink`, and
|
|
201
208
|
`--accent-soft` on a light ground. Measure and pin them per site.
|
|
202
|
-
- **THERE ARE
|
|
209
|
+
- **THERE ARE FOUR PALETTES AND THEY ARE NOT ONE SYSTEM.** A gem means a
|
|
203
210
|
**medium** (7, `gems.json`); an aura stop means a **rate** (7, `auras.json`);
|
|
204
|
-
a rainbow hue means a **domain** (6, `tlds.json`)
|
|
211
|
+
a rainbow hue means a **domain** (6, `tlds.json`); a body color means a
|
|
212
|
+
**body** (5, `bodies.json`, codes and seals only — v1.7.0, 2026-10-12). They
|
|
213
|
+
meet in exactly one place: HeartBank®'s body color IS its domain's, so the
|
|
214
|
+
rainbow's first carrier is H3's codes. The hues rhyme because a
|
|
205
215
|
colour wheel is small. The two sevens are *different sets* — the aura ramp
|
|
206
216
|
carries indigo and ends at violet, the gems carry no indigo and end at
|
|
207
217
|
diamond.
|
package/brand.lock
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.7.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": "
|
|
14
|
-
"qr/bqr.ts": "
|
|
13
|
+
"qr/bqr-card.ts": "55b4cf3d742bb758f789fd18f91737e8da1169610b6b953ad71e95d8bb713168",
|
|
14
|
+
"qr/bqr.ts": "af1b66b7cffc1683a48f85c9ad4417acfbbedfbaa61e775672399e7c8c0a04d3"
|
|
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.1",
|
|
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.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.
|
|
17
|
+
public static let version = "1.7.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.
|
|
3
|
+
"version": "1.7.1",
|
|
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.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
|
@@ -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
|
/**
|
|
@@ -58,7 +60,7 @@ function placeLine(g: CanvasRenderingContext2D, text: string, y: number, weight:
|
|
|
58
60
|
export async function paintQrCard(g: CanvasRenderingContext2D, c: BqrCard, face: string): Promise<void> {
|
|
59
61
|
const { W, H } = CARD;
|
|
60
62
|
g.fillStyle = "#ffffff"; g.fillRect(0, 0, W, H);
|
|
61
|
-
await drawBqr(g, c.url, { ...CARD.code, accent: c.accent, style: c.style, hue: c.hue });
|
|
63
|
+
await drawBqr(g, c.url, { ...CARD.code, accent: c.accent, style: c.style, hue: c.hue, owner: c.owner });
|
|
62
64
|
g.fillStyle = "#16141c"; g.textAlign = "left"; g.textBaseline = "middle";
|
|
63
65
|
placeLine(g, c.title, CARD.title, 600, 72, face, W - 120);
|
|
64
66
|
placeLine(g, c.caption, CARD.caption, 500, 54, face, W - 120);
|
package/qr/bqr.ts
CHANGED
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
* modules · `outline` — the *Open B-QR*, the lobes left open inside a thick outline, no decoration. (Public names RULED 2026-10-06,
|
|
30
30
|
* replacing *Green B-QR* / *White B-QR*: a color name stops being true once the color can change — see `hue` below.)
|
|
31
31
|
*
|
|
32
|
-
* ⭐ ONE
|
|
33
|
-
*
|
|
32
|
+
* ⭐ ONE INK for the code, its decoration and its outline — `BQR_INK` = #14532d by default; ⚠️ SUPERSEDED 2026-10-12 as a rule for
|
|
33
|
+
* every app: a product's code takes its OWNER's ink (v1.7.0, `BqrOwner` below), and the green stays the default and
|
|
34
|
+
* `heartbank.ceo`'s — ⛔ never a theme's colour (a light theme must not reach the code). The green itself was
|
|
35
|
+
* chosen by a rule written into the test BEFORE its sweep ran: the LIGHTEST candidate that prints at ISO/IEC 15415
|
|
34
36
|
* 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
37
|
* independent decoders. The prediction (#106430) was wrong and the rule's pick was kept — ⛔ never move the rule to a preferred shade.
|
|
36
38
|
* ⭐ DETERMINISTIC: the decoration is seeded from a hash of the text, so the same address always draws the same picture and the preview
|
|
@@ -98,8 +100,9 @@ export const bqrGroundOf = (s: unknown): BqrGround => (BQR_GROUNDS as readonly u
|
|
|
98
100
|
* 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
101
|
* grade A or scans worse than the green: ⭐ the darkness is a PROPERTY of the recipe, not a rule a caller must remember.
|
|
100
102
|
* 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
|
|
102
|
-
*
|
|
103
|
+
* ⭐ No `hue` = `BQR_INK` itself, verbatim, so every drawing that passes none is byte-identical to v1.5.0 (founder 2026-10-06: the
|
|
104
|
+
* brand page's B-QRs follow the selected `--emblem`). ⚠️ SUPERSEDED 2026-10-12: *"the apps pass none and keep the one green"* —
|
|
105
|
+
* products now pass an `owner` (the body palette), never a `hue`.
|
|
103
106
|
* `scripts/bqr.test.mjs` §emblem-hue decodes every gem's derivation before it shipped.
|
|
104
107
|
*/
|
|
105
108
|
const lin8 = (c: number) => { c /= 255; return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4; };
|
|
@@ -147,6 +150,40 @@ export function bqrInkFor(hue: string): string {
|
|
|
147
150
|
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
151
|
return at(lo);
|
|
149
152
|
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* ⭐ v1.7.0 — THE BODY PALETTE (founder 2026-10-12; MA memory `project_brand_identity` §body-palette; roadmap A383). A code's OWNER
|
|
156
|
+
* 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
|
|
157
|
+
* rainbow), and every other body names itself — SW orange robe · TH sky blue · F333 crimson moon · MA clear sparkle. The ink is
|
|
158
|
+
* `bqrInkFor(source)`, so an owner inherits every property `hue` has: never lighter than the green, the hue kept.
|
|
159
|
+
* ⛔ `"H3"` alone is not an owner, and an owner never travels with a `hue`: `paintBqr` throws on either — a product inherits its
|
|
160
|
+
* body's color and cannot pick one (rule 1 as a property). The palette says BELONGING, never authenticity: anyone can print any
|
|
161
|
+
* color; the scan authenticates.
|
|
162
|
+
* ⭐ `heartbank.ceo` IS `BQR_INK`, byte for byte (Shops unchanged). The other domain sources are `data/tlds.json`'s candidate LIGHT
|
|
163
|
+
* values; `scripts/bqr.test.mjs` §body-palette B3 fails if either file moves without the other.
|
|
164
|
+
*/
|
|
165
|
+
export type BqrOwner =
|
|
166
|
+
| "heartbank.us" | "heartbank.me" | "heartbank.org" | "heartbank.ceo" | "heartbank.net" | "heartbank.com"
|
|
167
|
+
| "SW" | "TH" | "F333" | "MA";
|
|
168
|
+
export const BQR_OWNER_HUES: Readonly<Record<BqrOwner, string>> = {
|
|
169
|
+
"heartbank.us": "#c8102e", // red — HeartBank® Storage
|
|
170
|
+
"heartbank.me": "#c95103", // orange — Thank Your Future Kindness℠
|
|
171
|
+
"heartbank.org": "#9a6f0b", // gold — Treasury (prints olive-brown: gold cannot print light)
|
|
172
|
+
"heartbank.ceo": BQR_INK, // green — Shops, the live green, unchanged
|
|
173
|
+
"heartbank.net": "#0f52ba", // blue — the institutional site, /b/
|
|
174
|
+
"heartbank.com": "#935dc9", // purple — Chronicle, the B-Store
|
|
175
|
+
SW: "#f28500", // orange robe — prints deep ochre, the robe's kāsāya
|
|
176
|
+
TH: "#38bdf8", // sky blue
|
|
177
|
+
F333: "#c1121f", // crimson moon
|
|
178
|
+
MA: "#f4f7ff", // clear sparkle — prints graphite; on screen the glint moves only with the viewer, never by itself
|
|
179
|
+
};
|
|
180
|
+
export const BQR_OWNERS = Object.keys(BQR_OWNER_HUES) as readonly BqrOwner[];
|
|
181
|
+
/** The ink a code owned by `owner` is drawn in. ⛔ Throws on anything that is not a `BqrOwner` — `"H3"` included. */
|
|
182
|
+
export function bqrOwnerInk(owner: BqrOwner): string {
|
|
183
|
+
if (!Object.prototype.hasOwnProperty.call(BQR_OWNER_HUES, owner))
|
|
184
|
+
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.`);
|
|
185
|
+
return bqrInkFor(BQR_OWNER_HUES[owner]);
|
|
186
|
+
}
|
|
150
187
|
/** The decorative module's side, as a fraction of a module — a visible gap between neighbours, so no two ever merge. */
|
|
151
188
|
const DOT = 0.84;
|
|
152
189
|
/** Share of decorative cells drawn dark (before the run limit thins them). */
|
|
@@ -174,8 +211,12 @@ export interface BqrOptions {
|
|
|
174
211
|
quiet?: number;
|
|
175
212
|
/** ⛔ TEST ONLY — the code's colour, for the ink sweep that chose `BQR_INK`. ⛔ Never a theme's colour. */
|
|
176
213
|
ink?: string;
|
|
177
|
-
/** ⭐ v1.6.0 — the drawing's color family, drawn at `BQR_INK`'s darkness (`bqrInkFor`). Default: `BQR_INK` itself.
|
|
214
|
+
/** ⭐ v1.6.0 — the drawing's color family, drawn at `BQR_INK`'s darkness (`bqrInkFor`). Default: `BQR_INK` itself.
|
|
215
|
+
* ⛔ Products pass `owner`, never `hue`; `hue` is for the brand page following a visitor's `--emblem`. */
|
|
178
216
|
hue?: string;
|
|
217
|
+
/** ⭐ v1.7.0 — the body (for H3, the domain) that owns this code; its color comes from the body palette (`bqrOwnerInk`).
|
|
218
|
+
* ⛔ Never together with `hue`. */
|
|
219
|
+
owner?: BqrOwner;
|
|
179
220
|
}
|
|
180
221
|
export interface BqrLayout {
|
|
181
222
|
/** Modules across the code. */
|
|
@@ -302,7 +343,9 @@ export function bqrPlacement(size: number, x = 0, y = 0): { k: number; tx: numbe
|
|
|
302
343
|
export function paintBqr(g: CanvasRenderingContext2D, mat: BqrMatrix, seed: string, o: BqrOptions): void {
|
|
303
344
|
// ⭐ §4AA — one green for the whole drawing: the decoration and the outline default to the code's own ink.
|
|
304
345
|
// ⭐ v1.6.0 — `hue` sets the code, the decoration and the outline at once, darkened by `bqrInkFor`; none = `BQR_INK`, verbatim.
|
|
305
|
-
|
|
346
|
+
// ⭐ v1.7.0 — `owner` sets it from the body palette instead; ⛔ both at once throws (a product cannot pick its own color).
|
|
347
|
+
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.");
|
|
348
|
+
const inkOfHue = o.owner !== undefined ? bqrOwnerInk(o.owner) : o.hue ? bqrInkFor(o.hue) : BQR_INK;
|
|
306
349
|
const X = o.x ?? 0, Y = o.y ?? 0, size = o.size, accent = o.accent || inkOfHue;
|
|
307
350
|
const L = bqrLayout(mat, seed, { style: o.style, quiet: o.quiet });
|
|
308
351
|
const { k, tx, ty } = bqrPlacement(size, X, Y);
|
|
@@ -351,11 +394,11 @@ export async function drawBqr(g: CanvasRenderingContext2D, text: string, o: BqrO
|
|
|
351
394
|
}
|
|
352
395
|
|
|
353
396
|
/** 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> {
|
|
397
|
+
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
398
|
const size = o.size ?? 640;
|
|
356
399
|
const canvas = document.createElement("canvas");
|
|
357
400
|
canvas.width = size; canvas.height = size;
|
|
358
401
|
// ⛔ 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 });
|
|
402
|
+
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
403
|
return canvas.toDataURL("image/png");
|
|
361
404
|
}
|