@333eco/brand 1.8.0 → 1.10.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 +11 -0
- package/brand.lock +2 -2
- package/data/bodies.json +1 -1
- package/data/brand.json +1 -1
- package/dist/Brand.kt +1 -1
- package/dist/Brand.swift +1 -1
- package/dist/tokens.json +1 -1
- package/package.json +1 -1
- package/qr/bqr.ts +130 -7
package/README.md
CHANGED
|
@@ -135,6 +135,17 @@ an H3QR names whom you thank, and a B-QR is how that code is drawn.
|
|
|
135
135
|
draws the green byte for byte, so Shops moves nothing. ⛔ `"H3"` alone, an unknown owner, or `owner` with `hue` THROWS — a
|
|
136
136
|
product inherits its body's color and cannot pick one. Semantics in `data/bodies.json` (no hexes); sources in `BQR_OWNER_HUES`;
|
|
137
137
|
pre-registered and decoded before it shipped (`bqr.test.mjs` §body-palette). ⚠️ It says BELONGING, never authenticity.
|
|
138
|
+
- **Turned, with a small ™ (v1.9.0, founder 2026-11-24).** The code is drawn turned a quarter counterclockwise, so its middle position
|
|
139
|
+
marker stands at the heart's point and its three markers mirror about the heart's own line (`bqrTurned`; always, no option). It
|
|
140
|
+
shipped by the founder's override of a failed scan gate, kept on the record in `scripts/bqr.test.mjs` §turn. A small ™ stands in the
|
|
141
|
+
bottom lobe: it names the **B-Emblem™**, never *B-QR* (unmarked), and shows which way is up. `lobe: "none"` or `autograph` (a person's own
|
|
142
|
+
strokes, *Open* only, ⛔ throws in *Full*) are for a person's own picture. The other three positions mean nothing yet, so ⛔ nothing is
|
|
143
|
+
drawn in one, and the top lobe keeps its dots. Codes printed before keep working.
|
|
144
|
+
- **Centered, and a coded top lobe (v1.10.0, founder 2026-11-24).** The ™, and an autograph in its place, stand at the bottom lobe's center, each
|
|
145
|
+
version's own (`BQR_LOBE_CENTER`, solved from the silhouette by the test). An autograph is FITTED to its box: its own shape kept, wherever on
|
|
146
|
+
the pad it was drawn. `coded` puts 96 bits in the TOP lobe (Open only, ⛔ throws in Full): for a mark in a person's picture, where its caller
|
|
147
|
+
writes a short fingerprint of that picture, so a heart pasted on another is caught with no network. ⛔ Never a person, a serial, a claim or a
|
|
148
|
+
key; nothing about it is secret. Our own codes keep their dots.
|
|
138
149
|
- **The card's words are PLACED, never aligned (v1.6.1).** `paintQrCard` measures each line, shrinks its size until it fits,
|
|
139
150
|
and draws it from the left at the center minus half its width. Safari on iOS 26 ignores `textAlign = "center"` and the
|
|
140
151
|
`maxWidth` argument for a complex script: a Khmer caption printed starting at the center line. Measured on the Simulator
|
package/brand.lock
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.10.0",
|
|
3
3
|
"files": {
|
|
4
4
|
"css/metta.css": "9bfe986c46c303bf9a48be85322d68e3d626571a424ef3a8aa81faaf5c866692",
|
|
5
5
|
"css/motion.css": "9bfbe39c0de6a9dfaf9fdc2c61e327b3c8e70221c34dff9befd85da448b9e0c2",
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"emblem/emblem.svg": "368f520ad2d2f9db50d83ca9cd7aee9475948dc8e38c61b7afa13f7717fef903",
|
|
12
12
|
"emblem/emblem.ts": "6e150389eed576c392ff6231c0b38b8fea5d4c11f7a5b21936bb25afab069890",
|
|
13
13
|
"qr/bqr-card.ts": "55b4cf3d742bb758f789fd18f91737e8da1169610b6b953ad71e95d8bb713168",
|
|
14
|
-
"qr/bqr.ts": "
|
|
14
|
+
"qr/bqr.ts": "076a838d8268da318e59c85e9ceed7ad58b8b0c7cd9c15f7882c6ece361a5846"
|
|
15
15
|
}
|
|
16
16
|
}
|
package/data/bodies.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"bodies": [
|
|
20
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" },
|
|
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
22
|
{ "body": "TH", "name": "THonly™", "color": "sky blue", "owners": ["TH"], "why": "Mind is the Air body; the sky" },
|
|
23
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
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" }
|
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.10.0",
|
|
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.
|
|
21
|
+
const val VERSION = "1.10.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.10.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.10.0",
|
|
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.
|
|
3
|
+
"version": "1.10.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.ts
CHANGED
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
* chosen by a rule written into the test BEFORE its sweep ran: the LIGHTEST candidate that prints at ISO/IEC 15415
|
|
36
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
|
|
37
37
|
* independent decoders. The prediction (#106430) was wrong and the rule's pick was kept — ⛔ never move the rule to a preferred shade.
|
|
38
|
+
* ⭐ ONE MIRROR LINE (v1.9.0, founder 2026-11-23): the code is drawn turned a quarter counterclockwise (`bqrTurned`), so its middle
|
|
39
|
+
* position marker stands at the heart's point and its three markers mirror about the heart's own line. Measured in §turn; nothing
|
|
40
|
+
* printed before is reprinted (a code reads at any angle).
|
|
38
41
|
* ⭐ DETERMINISTIC: the decoration is seeded from a hash of the text, so the same address always draws the same picture and the preview
|
|
39
42
|
* a person sees is the card they download.
|
|
40
43
|
*
|
|
@@ -55,6 +58,40 @@ export const BQR_BODY = { x: 4.0588, y: 8.5913, s: 11.35 } as const;
|
|
|
55
58
|
export const BQR_QUIET = 4;
|
|
56
59
|
/** ⭐ §4Z — `pixels`: clear modules left between the code and the decoration. ⛔ Never 0 (the measured failure). */
|
|
57
60
|
export const BQR_FILL_RING = 1;
|
|
61
|
+
/**
|
|
62
|
+
* ⭐ v1.9.0 (founder 2026-11-24) — the BOTTOM LOBE. Every B-QR of ours carries a small ™ there: it names the B-Emblem™, this drawing (⛔ never
|
|
63
|
+
* "B-QR", which stays unmarked), and shows which way is up. `none` leaves the lobe as it was; `autograph` (below) draws a person's own
|
|
64
|
+
* hand instead. Both are for a person's OWN picture, where a ™ would read as a claim on their work. The TOP lobe keeps its dots.
|
|
65
|
+
*/
|
|
66
|
+
export type BqrLobe = "tm" | "none";
|
|
67
|
+
export const BQR_LOBE_DEFAULT: BqrLobe = "tm";
|
|
68
|
+
/**
|
|
69
|
+
* ⭐ v1.10.0 (founder 2026-11-24: *"horizontally and vertically center the ™ and the [autograph] within the bottom lobe"*) — the lobe's CENTER,
|
|
70
|
+
* each version's own: midway between the code's last column and the outline's inner edge on its row, and midway between the outline's
|
|
71
|
+
* inner edges on its column. Solved from the silhouette; `scripts/bqr.test.mjs` §center solves it again and holds these.
|
|
72
|
+
*/
|
|
73
|
+
export const BQR_LOBE_CENTER = { pixels: { x: 17.86, y: 14.15 }, outline: { x: 17.62, y: 14.16 } } as const;
|
|
74
|
+
/** The ™: its cap height and the quiet space around it, in viewBox units. Drawn as bars, so it needs no font. */
|
|
75
|
+
export const BQR_TM = { h: 1.05, pad: 0.5 } as const;
|
|
76
|
+
const TM = { t: 0.2, w: 0.84, gap: 0.13, m: 1.06 } as const; // stroke · T's width · the gap · M's width, as parts of the cap height
|
|
77
|
+
export const bqrTmBox = (style: keyof typeof BQR_LOBE_CENTER = "pixels") => { const w = BQR_TM.h * (TM.w + TM.gap + TM.m), c = BQR_LOBE_CENTER[style]; return { x: c.x - w / 2, y: c.y - BQR_TM.h / 2, w, h: BQR_TM.h }; };
|
|
78
|
+
/** The autograph's box, 5 : 3, centered in the Open version's bottom lobe. Its width is the largest that loses no reading (§center C3). */
|
|
79
|
+
const AUTOGRAPH_W = 4.27;
|
|
80
|
+
export const BQR_AUTOGRAPH = { x: BQR_LOBE_CENTER.outline.x - AUTOGRAPH_W / 2, y: BQR_LOBE_CENTER.outline.y - AUTOGRAPH_W * 0.3, w: AUTOGRAPH_W, h: AUTOGRAPH_W * 0.6 } as const;
|
|
81
|
+
/** A person's B-Autograph℠, as points on a 100 × 60 pad: numbers only, ⛔ never a path's text (nothing here is ever parsed or injected). */
|
|
82
|
+
export interface BqrAutograph { strokes: readonly (readonly (readonly [number, number])[])[] }
|
|
83
|
+
export const BQR_PAD_W = 100, BQR_PAD_H = 60, BQR_AUTOGRAPH_PEN = 3, BQR_AUTOGRAPH_POINTS = 4000;
|
|
84
|
+
/** True for something that can be drawn as an autograph. */
|
|
85
|
+
export function isAutograph(a: unknown): a is BqrAutograph {
|
|
86
|
+
const s = (a as BqrAutograph | null)?.strokes;
|
|
87
|
+
if (!Array.isArray(s) || !s.length || s.length > 200) return false;
|
|
88
|
+
let n = 0;
|
|
89
|
+
for (const k of s) {
|
|
90
|
+
if (!Array.isArray(k) || !k.length) return false;
|
|
91
|
+
for (const p of k) { if (!Array.isArray(p) || p.length !== 2 || !Number.isFinite(p[0]) || !Number.isFinite(p[1]) || ++n > BQR_AUTOGRAPH_POINTS) return false; }
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
58
95
|
|
|
59
96
|
/** ⭐ §4Z — the two versions, by internal name. ⛔ Neither name is ever shown: a person sees two pictures and two plain words. */
|
|
60
97
|
export type BqrStyle = "pixels" | "outline";
|
|
@@ -211,6 +248,16 @@ export interface BqrOptions {
|
|
|
211
248
|
quiet?: number;
|
|
212
249
|
/** ⛔ TEST ONLY — the code's colour, for the ink sweep that chose `BQR_INK`. ⛔ Never a theme's colour. */
|
|
213
250
|
ink?: string;
|
|
251
|
+
/** ⭐ v1.9.0 — the bottom lobe: the ™ (default), or nothing in a person's own picture. */
|
|
252
|
+
lobe?: BqrLobe;
|
|
253
|
+
/** ⭐ v1.9.0 — a person's autograph in the bottom lobe, in the `outline` version only (⛔ throws in `pixels`); it replaces the ™. */
|
|
254
|
+
autograph?: BqrAutograph;
|
|
255
|
+
/** ⛔ TEST ONLY — `false` draws an autograph where it was drawn on the pad, not fitted and centered, for the checks that must see it. */
|
|
256
|
+
fitAutograph?: boolean;
|
|
257
|
+
/** ⭐ v1.10.0 — 96 bits in the TOP lobe, for a mark in a person's picture, in the `outline` version only (⛔ throws in `pixels`). */
|
|
258
|
+
coded?: readonly number[];
|
|
259
|
+
/** ⛔ TEST ONLY — `false` draws the code upright, the drawing before v1.9.0 (`scripts/bqr.test.mjs` §turn, the baseline). */
|
|
260
|
+
turn?: boolean;
|
|
214
261
|
/** ⭐ v1.6.0 — the drawing's color family, drawn at `BQR_INK`'s darkness (`bqrInkFor`). Default: `BQR_INK` itself.
|
|
215
262
|
* ⛔ Products pass `owner`, never `hue`; `hue` is for the brand page following a visitor's `--emblem`. */
|
|
216
263
|
hue?: string;
|
|
@@ -298,12 +345,58 @@ function stream(seed: string): () => number {
|
|
|
298
345
|
};
|
|
299
346
|
}
|
|
300
347
|
|
|
348
|
+
/** Does a cell (its top left, its side) touch the sign's rounded quiet space? */
|
|
349
|
+
function touchesSign(x: number, y: number, m: number, style: BqrStyle): boolean {
|
|
350
|
+
const b = bqrTmBox(style), c = BQR_LOBE_CENTER[style], rx = b.w / 2 + BQR_TM.pad, ry = b.h / 2 + BQR_TM.pad;
|
|
351
|
+
const nx = Math.max(x, Math.min(c.x, x + m)) - c.x, ny = Math.max(y, Math.min(c.y, y + m)) - c.y;
|
|
352
|
+
return (nx / rx) ** 2 + (ny / ry) ** 2 < 1;
|
|
353
|
+
}
|
|
354
|
+
/** The ™ as bars, in viewBox units. */
|
|
355
|
+
function drawTm(g: CanvasRenderingContext2D, style: BqrStyle): void {
|
|
356
|
+
const b = bqrTmBox(style), h = b.h, t = TM.t * h, w = TM.w * h, x1 = b.x + w + TM.gap * h, mw = TM.m * h, y = b.y;
|
|
357
|
+
g.fillRect(b.x, y, w, t); g.fillRect(b.x + w / 2 - t / 2, y, t, h);
|
|
358
|
+
g.beginPath(); g.moveTo(x1, y + h); g.lineTo(x1, y); g.lineTo(x1 + t * 1.05, y); g.lineTo(x1 + mw / 2, y + h * 0.56); g.lineTo(x1 + mw - t * 1.05, y); g.lineTo(x1 + mw, y);
|
|
359
|
+
g.lineTo(x1 + mw, y + h); g.lineTo(x1 + mw - t, y + h); g.lineTo(x1 + mw - t, y + h * 0.42); g.lineTo(x1 + mw / 2, y + h * 0.86); g.lineTo(x1 + t, y + h * 0.42); g.lineTo(x1 + t, y + h);
|
|
360
|
+
g.closePath(); g.fill();
|
|
361
|
+
}
|
|
362
|
+
/** A person's autograph in its box: each stroke through the middles of its points, so a finger's corners come out round. */
|
|
363
|
+
/** ⭐ v1.10.0 — FITTED: the drawing keeps its own shape, grows to fill its box (at most twice the pad's own scale) and stands at the lobe's center,
|
|
364
|
+
* wherever on the pad it was drawn. It cannot leave its box, so it can never reach the code. */
|
|
365
|
+
function drawAutograph(g: CanvasRenderingContext2D, a: BqrAutograph, ink: string, fit: boolean): void {
|
|
366
|
+
const B = BQR_AUTOGRAPH, pad = B.w / BQR_PAD_W, pen = BQR_AUTOGRAPH_PEN * pad;
|
|
367
|
+
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
368
|
+
for (const s of a.strokes) for (const [x, y] of s) { x0 = Math.min(x0, x); x1 = Math.max(x1, x); y0 = Math.min(y0, y); y1 = Math.max(y1, y); }
|
|
369
|
+
const k = fit ? Math.min(2 * pad, (B.w - pen) / Math.max(x1 - x0, 1e-6), (B.h - pen) / Math.max(y1 - y0, 1e-6)) : pad;
|
|
370
|
+
g.save();
|
|
371
|
+
if (fit) { g.translate(B.x + B.w / 2, B.y + B.h / 2); g.scale(k, k); g.translate(-(x0 + x1) / 2, -(y0 + y1) / 2); }
|
|
372
|
+
else { g.translate(B.x, B.y); g.scale(k, k); }
|
|
373
|
+
g.strokeStyle = ink; g.fillStyle = ink; g.lineWidth = pen / k; g.lineCap = "round"; g.lineJoin = "round";
|
|
374
|
+
for (const s of a.strokes) {
|
|
375
|
+
if (s.length === 1) { g.beginPath(); g.arc(s[0][0], s[0][1], pen / k / 2, 0, Math.PI * 2); g.fill(); continue; }
|
|
376
|
+
g.beginPath(); g.moveTo(s[0][0], s[0][1]);
|
|
377
|
+
for (let i = 1; i < s.length - 1; i++) g.quadraticCurveTo(s[i][0], s[i][1], (s[i][0] + s[i + 1][0]) / 2, (s[i][1] + s[i + 1][1]) / 2);
|
|
378
|
+
g.lineTo(s[s.length - 1][0], s[s.length - 1][1]); g.stroke();
|
|
379
|
+
}
|
|
380
|
+
g.restore();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* ⭐ v1.9.0 (founder 2026-11-23) — the code turned a quarter COUNTERCLOCKWISE, so its middle position marker stands at the heart's point.
|
|
385
|
+
* The emblem mirrors about one line, point to notch; a code's three markers mirror about one line too, through the middle one. Upright
|
|
386
|
+
* the two lines cross; turned, they are the same line. Decoders read a code at any angle, so nothing printed before stops working.
|
|
387
|
+
*/
|
|
388
|
+
export function bqrTurned(mat: BqrMatrix): BqrMatrix {
|
|
389
|
+
const n = mat.size, data = new Uint8Array(n * n);
|
|
390
|
+
for (let r = 0; r < n; r++) for (let c = 0; c < n; c++) data[r * n + c] = mat.data[c * n + (n - 1 - r)] ? 1 : 0;
|
|
391
|
+
return { size: n, data };
|
|
392
|
+
}
|
|
393
|
+
|
|
301
394
|
/**
|
|
302
395
|
* Where everything goes, in viewBox units. The module grid is the code's own, extended over the whole emblem; a decorative cell
|
|
303
396
|
* 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
|
|
304
397
|
* that would make a third dark cell in a row or a column.
|
|
305
398
|
*/
|
|
306
|
-
export function bqrLayout(mat: BqrMatrix, seed: string, o: { style?: BqrStyle; quiet?: number } = {}): BqrLayout {
|
|
399
|
+
export function bqrLayout(mat: BqrMatrix, seed: string, o: { style?: BqrStyle; quiet?: number; lobe?: BqrLobe } = {}): BqrLayout {
|
|
307
400
|
const style = bqrStyleOf(o.style), G = BQR_GEOMETRY[style];
|
|
308
401
|
const quiet = o.quiet ?? G.ring;
|
|
309
402
|
const n = mat.size;
|
|
@@ -315,7 +408,7 @@ export function bqrLayout(mat: BqrMatrix, seed: string, o: { style?: BqrStyle; q
|
|
|
315
408
|
const c0 = Math.floor((EMBLEM_BOX.x - ox) / m) - 1, c1 = Math.ceil((EMBLEM_BOX.x + EMBLEM_BOX.w - ox) / m) + 1;
|
|
316
409
|
const r0 = Math.floor((EMBLEM_BOX.y - oy) / m) - 1, r1 = Math.ceil((EMBLEM_BOX.y + EMBLEM_BOX.h - oy) / m) + 1;
|
|
317
410
|
const clear = (DOT / 2) * m * Math.SQRT2 + G.outline / 2 + 0.15 * m;
|
|
318
|
-
const rand = stream(seed);
|
|
411
|
+
const rand = stream(seed), sign = (o.lobe ?? BQR_LOBE_DEFAULT) === "tm";
|
|
319
412
|
const dark = new Set<string>();
|
|
320
413
|
const deco: [number, number][] = [];
|
|
321
414
|
const on = (c: number, r: number) => dark.has(`${c},${r}`);
|
|
@@ -326,11 +419,31 @@ export function bqrLayout(mat: BqrMatrix, seed: string, o: { style?: BqrStyle; q
|
|
|
326
419
|
if (!insideEmblem(cx, cy) || edgeDistance(cx, cy) < clear) continue;
|
|
327
420
|
if (p >= DENSITY) continue;
|
|
328
421
|
if ((on(c - 1, r) && on(c - 2, r)) || (on(c, r - 1) && on(c, r - 2))) continue; // ⛔ never three in a run
|
|
329
|
-
dark.add(`${c},${r}`);
|
|
422
|
+
dark.add(`${c},${r}`);
|
|
423
|
+
// ⭐ A whole dot or none: the sign never cuts one. It is dropped AFTER it counted for the run rule, so no other dot moves (§tm S3).
|
|
424
|
+
if (sign && touchesSign(ox + c * m, oy + r * m, m, style)) continue;
|
|
425
|
+
deco.push([c, r]);
|
|
330
426
|
}
|
|
331
427
|
return { n, m, ox, oy, deco, style, outline: G.outline };
|
|
332
428
|
}
|
|
333
429
|
|
|
430
|
+
/** ⭐ v1.10.0 — the top lobe's coded cells, as [column, row] on the DRAWN (turned) code's grid, nearest the code first; bit i is in cells i and
|
|
431
|
+
* i + 96. A checkerboard, so no two stand side by side. ⛔ Throws when a code is too coarse for them (a mark's 12 characters never is). */
|
|
432
|
+
export const BQR_CODED_BITS = 96;
|
|
433
|
+
export function bqrLobeCells(mat: BqrMatrix, o: { style?: BqrStyle } = {}): [number, number][] {
|
|
434
|
+
const L = bqrLayout(mat, "", { style: o.style ?? "outline", lobe: "none" }), clear = (DOT / 2) * L.m * Math.SQRT2 + L.outline / 2 + 0.15 * L.m, out: [number, number][] = [];
|
|
435
|
+
const r0 = Math.floor((EMBLEM_BOX.y - L.oy) / L.m) - 1, c0 = Math.floor((EMBLEM_BOX.x - L.ox) / L.m) - 1, c1 = Math.ceil((EMBLEM_BOX.x + EMBLEM_BOX.w - L.ox) / L.m) + 1;
|
|
436
|
+
for (let r = -BQR_QUIET - 1; r >= r0; r--) for (let c = c0; c <= c1; c++) {
|
|
437
|
+
if ((c + r) & 1) continue;
|
|
438
|
+
const cx = L.ox + (c + 0.5) * L.m, cy = L.oy + (r + 0.5) * L.m;
|
|
439
|
+
if (insideEmblem(cx, cy) && edgeDistance(cx, cy) >= clear) out.push([c, r]);
|
|
440
|
+
}
|
|
441
|
+
if (out.length < 2 * BQR_CODED_BITS) throw new Error("B-QR: this code is too coarse for coded modules.");
|
|
442
|
+
return out.slice(0, 2 * BQR_CODED_BITS);
|
|
443
|
+
}
|
|
444
|
+
/** A drawn cell as the DECODER sees it (the code's own upright grid), for reading coded modules back from a photo of the drawing. */
|
|
445
|
+
export const bqrUpright = (n: number, [c, r]: readonly [number, number]): [number, number] => [n - 1 - r, c];
|
|
446
|
+
|
|
334
447
|
// ---- drawing ------------------------------------------------------------------------------------------------------------------------
|
|
335
448
|
|
|
336
449
|
/** Where the emblem lands in a `size` square at (x, y): canvas px = t + k · viewBox units. ⭐ Centres the PAINTED bbox, never the viewBox. */
|
|
@@ -340,14 +453,19 @@ export function bqrPlacement(size: number, x = 0, y = 0): { k: number; tx: numbe
|
|
|
340
453
|
}
|
|
341
454
|
|
|
342
455
|
/** Paint a B-QR from a module matrix into a 2D context. Synchronous; `drawBqr` makes the matrix. */
|
|
343
|
-
export function paintBqr(g: CanvasRenderingContext2D,
|
|
456
|
+
export function paintBqr(g: CanvasRenderingContext2D, upright: BqrMatrix, seed: string, o: BqrOptions): void {
|
|
457
|
+
// ⭐ v1.9.0 — always turned: one drawing, whoever asks. The layout is the grid's, so the decoration and the outline do not move.
|
|
458
|
+
const mat = o.turn === false ? upright : bqrTurned(upright);
|
|
344
459
|
// ⭐ §4AA — one green for the whole drawing: the decoration and the outline default to the code's own ink.
|
|
345
460
|
// ⭐ v1.6.0 — `hue` sets the code, the decoration and the outline at once, darkened by `bqrInkFor`; none = `BQR_INK`, verbatim.
|
|
346
461
|
// ⭐ v1.7.0 — `owner` sets it from the body palette instead; ⛔ both at once throws (a product cannot pick its own color).
|
|
347
462
|
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
463
|
const inkOfHue = o.owner !== undefined ? bqrOwnerInk(o.owner) : o.hue ? bqrInkFor(o.hue) : BQR_INK;
|
|
349
464
|
const X = o.x ?? 0, Y = o.y ?? 0, size = o.size, accent = o.accent || inkOfHue;
|
|
350
|
-
|
|
465
|
+
if (o.autograph !== undefined && (bqrStyleOf(o.style) !== "outline" || !isAutograph(o.autograph))) throw new Error("B-QR: an autograph is drawn in the `outline` version (the Open B-QR) only, from a person's own strokes.");
|
|
466
|
+
if (o.coded !== undefined && (bqrStyleOf(o.style) !== "outline" || o.coded.length !== BQR_CODED_BITS || !o.coded.every((b) => b === 0 || b === 1))) throw new Error("B-QR: coded modules are 96 bits in the `outline` version (the Open B-QR) only.");
|
|
467
|
+
const lobe: BqrLobe = o.autograph ? "none" : o.lobe ?? BQR_LOBE_DEFAULT;
|
|
468
|
+
const L = bqrLayout(mat, seed, { style: o.style, quiet: o.quiet, lobe });
|
|
351
469
|
const { k, tx, ty } = bqrPlacement(size, X, Y);
|
|
352
470
|
const path = new Path2D(EMBLEM_D);
|
|
353
471
|
const ground = bqrGroundOf(o.ground);
|
|
@@ -367,6 +485,11 @@ export function paintBqr(g: CanvasRenderingContext2D, mat: BqrMatrix, seed: stri
|
|
|
367
485
|
// The outline.
|
|
368
486
|
// ⭐ §4Z — `outline` (Version 2) draws this wider, over a heart left white (§4AA: six times as wide).
|
|
369
487
|
g.strokeStyle = accent; g.lineWidth = L.outline; g.lineJoin = "round"; g.stroke(path);
|
|
488
|
+
// ⭐ v1.10.0 — the top lobe's coded modules, each bit twice, dots as the decoration's own.
|
|
489
|
+
if (o.coded) { g.fillStyle = accent; bqrLobeCells(mat, { style: "outline" }).forEach(([c, r], i) => { if (o.coded![i % BQR_CODED_BITS]) g.fillRect(L.ox + c * L.m + inset, L.oy + r * L.m + inset, d, d); }); }
|
|
490
|
+
// ⭐ v1.9.0 — the bottom lobe, in the code's own ink.
|
|
491
|
+
if (o.autograph) drawAutograph(g, o.autograph, accent, o.fitAutograph !== false);
|
|
492
|
+
else if (lobe === "tm") { g.fillStyle = accent; drawTm(g, bqrStyleOf(o.style)); }
|
|
370
493
|
g.restore();
|
|
371
494
|
|
|
372
495
|
// ⭐ The code, in DEVICE pixels with every edge rounded, one rect per run — scaled sub-pixel rects leave hairline seams
|
|
@@ -394,11 +517,11 @@ export async function drawBqr(g: CanvasRenderingContext2D, text: string, o: BqrO
|
|
|
394
517
|
}
|
|
395
518
|
|
|
396
519
|
/** 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. */
|
|
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> {
|
|
520
|
+
export async function bqrDataUrl(text: string, o: { size?: number; accent?: string; ecc?: "L" | "M" | "Q" | "H"; style?: BqrStyle; ground?: BqrGround; hue?: string; owner?: BqrOwner; lobe?: BqrLobe; autograph?: BqrAutograph } = {}): Promise<string> {
|
|
398
521
|
const size = o.size ?? 640;
|
|
399
522
|
const canvas = document.createElement("canvas");
|
|
400
523
|
canvas.width = size; canvas.height = size;
|
|
401
524
|
// ⛔ v1.5.0 — `ground: "heart"` only for a picture that stays on screen; a URL handed to a download takes the default `paper`.
|
|
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 });
|
|
525
|
+
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, lobe: o.lobe, autograph: o.autograph });
|
|
403
526
|
return canvas.toDataURL("image/png");
|
|
404
527
|
}
|