qrdx 0.0.46 → 0.0.48
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/LICENSE +21 -0
- package/README.md +358 -300
- package/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -7
- package/dist/index.mjs.map +1 -1
- package/dist/qr-code-canvas.js +12 -0
- package/dist/qr-code-canvas.js.map +1 -0
- package/dist/qr-code-canvas.mjs +12 -0
- package/dist/qr-code-canvas.mjs.map +1 -0
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/art-trace.d.ts +46 -0
- package/dist/src/art-trace.d.ts.map +1 -0
- package/dist/src/art.d.ts +138 -0
- package/dist/src/art.d.ts.map +1 -0
- package/dist/src/body-patterns.d.ts +34 -0
- package/dist/src/body-patterns.d.ts.map +1 -0
- package/dist/src/codegen.d.ts +5 -5
- package/dist/src/codegen.d.ts.map +1 -1
- package/dist/src/codeword-map.d.ts +40 -0
- package/dist/src/codeword-map.d.ts.map +1 -0
- package/dist/src/constants.d.ts +4 -7
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/corner-dot.d.ts +3 -1
- package/dist/src/corner-dot.d.ts.map +1 -1
- package/dist/src/corner-eye.d.ts +5 -2
- package/dist/src/corner-eye.d.ts.map +1 -1
- package/dist/src/detection.d.ts.map +1 -1
- package/dist/src/download.d.ts +50 -6
- package/dist/src/download.d.ts.map +1 -1
- package/dist/src/eps.d.ts +62 -0
- package/dist/src/eps.d.ts.map +1 -0
- package/dist/src/frame-icons.d.ts +11 -0
- package/dist/src/frame-icons.d.ts.map +1 -0
- package/dist/src/frame-import.d.ts +61 -0
- package/dist/src/frame-import.d.ts.map +1 -0
- package/dist/src/frame-spec.d.ts +24 -0
- package/dist/src/frame-spec.d.ts.map +1 -0
- package/dist/src/frame-styles.d.ts +50 -0
- package/dist/src/frame-styles.d.ts.map +1 -0
- package/dist/src/frame.d.ts +126 -0
- package/dist/src/frame.d.ts.map +1 -0
- package/dist/src/frames/builtin.d.ts +8 -0
- package/dist/src/frames/builtin.d.ts.map +1 -0
- package/dist/src/frames/official.d.ts +18 -0
- package/dist/src/frames/official.d.ts.map +1 -0
- package/dist/src/helpers.d.ts +15 -2
- package/dist/src/helpers.d.ts.map +1 -1
- package/dist/src/index.d.ts +25 -13
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/logo-budget.d.ts +54 -0
- package/dist/src/logo-budget.d.ts.map +1 -0
- package/dist/src/logo-cleanup.d.ts +25 -0
- package/dist/src/logo-cleanup.d.ts.map +1 -0
- package/dist/src/logo.d.ts +28 -0
- package/dist/src/logo.d.ts.map +1 -0
- package/dist/src/print.d.ts +73 -0
- package/dist/src/print.d.ts.map +1 -0
- package/dist/src/qr-code-canvas.d.ts +13 -0
- package/dist/src/qr-code-canvas.d.ts.map +1 -0
- package/dist/src/qr-code.d.ts +4 -2
- package/dist/src/qr-code.d.ts.map +1 -1
- package/dist/src/qr-outline.d.ts +41 -0
- package/dist/src/qr-outline.d.ts.map +1 -0
- package/dist/src/qr-shape.d.ts +72 -0
- package/dist/src/qr-shape.d.ts.map +1 -0
- package/dist/src/scan-risk.d.ts +40 -0
- package/dist/src/scan-risk.d.ts.map +1 -0
- package/dist/src/scan-score.d.ts +154 -0
- package/dist/src/scan-score.d.ts.map +1 -0
- package/dist/src/shapes.d.ts +36 -0
- package/dist/src/shapes.d.ts.map +1 -0
- package/dist/src/silhouette.d.ts +28 -0
- package/dist/src/silhouette.d.ts.map +1 -0
- package/dist/src/utils/color.d.ts.map +1 -1
- package/dist/src/utils/fmt.d.ts +24 -0
- package/dist/src/utils/fmt.d.ts.map +1 -0
- package/dist/src/utils/paint.d.ts +80 -0
- package/dist/src/utils/paint.d.ts.map +1 -0
- package/dist/src/utils/parse-color.d.ts +21 -0
- package/dist/src/utils/parse-color.d.ts.map +1 -0
- package/dist/src/utils/path-data.d.ts +24 -0
- package/dist/src/utils/path-data.d.ts.map +1 -0
- package/dist/src/utils/png.d.ts +16 -0
- package/dist/src/utils/png.d.ts.map +1 -0
- package/dist/src/utils/polygon-clip.d.ts +26 -0
- package/dist/src/utils/polygon-clip.d.ts.map +1 -0
- package/dist/src/utils/print-shared.d.ts +20 -0
- package/dist/src/utils/print-shared.d.ts.map +1 -0
- package/dist/src/utils/svg-geometry.d.ts +49 -0
- package/dist/src/utils/svg-geometry.d.ts.map +1 -0
- package/dist/src/utils/svg-gradient.d.ts +59 -0
- package/dist/src/utils/svg-gradient.d.ts.map +1 -0
- package/dist/src/utils/svg-painter.d.ts +152 -0
- package/dist/src/utils/svg-painter.d.ts.map +1 -0
- package/dist/src/utils/webp.d.ts +25 -0
- package/dist/src/utils/webp.d.ts.map +1 -0
- package/dist/src/utils.d.ts +18 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/webp.d.ts +19 -0
- package/dist/src/webp.d.ts.map +1 -0
- package/dist/types/art.d.ts +64 -0
- package/dist/types/art.d.ts.map +1 -0
- package/dist/types/color.d.ts +125 -7
- package/dist/types/color.d.ts.map +1 -1
- package/dist/types/corner-dot.d.ts +52 -2
- package/dist/types/corner-dot.d.ts.map +1 -1
- package/dist/types/corner-eye.d.ts +43 -2
- package/dist/types/corner-eye.d.ts.map +1 -1
- package/dist/types/frame-spec.d.ts +3509 -0
- package/dist/types/frame-spec.d.ts.map +1 -0
- package/dist/types/frame.d.ts +68 -0
- package/dist/types/frame.d.ts.map +1 -0
- package/dist/types/image-pattern.d.ts +15 -1
- package/dist/types/image-pattern.d.ts.map +1 -1
- package/dist/types/index.d.ts +15 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +6 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/qr.d.ts +1684 -4
- package/dist/types/qr.d.ts.map +1 -1
- package/dist/types/template.d.ts +2 -2
- package/dist/types/template.d.ts.map +1 -1
- package/package.json +70 -25
- package/src/api.tsx +67 -17
- package/src/art-trace.ts +554 -0
- package/src/art.tsx +2226 -0
- package/src/body-patterns.tsx +389 -0
- package/src/codegen.ts +10 -5
- package/src/codeword-map.ts +265 -0
- package/src/constants.ts +4 -8
- package/src/corner-dot.tsx +209 -33
- package/src/corner-eye.ts +328 -60
- package/src/detection.ts +5 -11
- package/src/download.tsx +174 -70
- package/src/eps.ts +701 -0
- package/src/frame-icons.ts +325 -0
- package/src/frame-import.ts +1198 -0
- package/src/frame-spec.ts +518 -0
- package/src/frame-styles.ts +1095 -0
- package/src/frame.tsx +630 -0
- package/src/frames/builtin/banner-bottom.json +58 -0
- package/src/frames/builtin/circle.json +81 -0
- package/src/frames/builtin/rounded-border.json +60 -0
- package/src/frames/builtin/ticket.json +51 -0
- package/src/frames/builtin.ts +20 -0
- package/src/frames/official/attendance.json +110 -0
- package/src/frames/official/audio-guide.json +95 -0
- package/src/frames/official/book-now.json +103 -0
- package/src/frames/official/check-in.json +110 -0
- package/src/frames/official/christmas.json +131 -0
- package/src/frames/official/donate.json +77 -0
- package/src/frames/official/event-ticket.json +77 -0
- package/src/frames/official/feedback-bubble.json +73 -0
- package/src/frames/official/follow-us.json +83 -0
- package/src/frames/official/get-the-app.json +107 -0
- package/src/frames/official/halloween.json +80 -0
- package/src/frames/official/new-year.json +94 -0
- package/src/frames/official/order-at-table.json +86 -0
- package/src/frames/official/product-info.json +119 -0
- package/src/frames/official/register-product.json +77 -0
- package/src/frames/official/review-us.json +127 -0
- package/src/frames/official/rsvp-card.json +112 -0
- package/src/frames/official/save-contact.json +117 -0
- package/src/frames/official/scan-to-pay.json +94 -0
- package/src/frames/official/shop-window.json +81 -0
- package/src/frames/official/sign-rider.json +81 -0
- package/src/frames/official/table-tent.json +75 -0
- package/src/frames/official/wifi-card.json +89 -0
- package/src/frames/official/winter.json +142 -0
- package/src/frames/official.ts +77 -0
- package/src/helpers.ts +168 -11
- package/src/index.tsx +150 -172
- package/src/logo-budget.ts +226 -0
- package/src/logo-cleanup.ts +146 -0
- package/src/logo.tsx +137 -0
- package/src/print.ts +794 -0
- package/src/qr-code-canvas.tsx +241 -0
- package/src/qr-code.tsx +51 -16
- package/src/qr-outline.ts +511 -0
- package/src/qr-shape.ts +255 -0
- package/src/scan-risk.ts +197 -0
- package/src/scan-score.ts +1629 -0
- package/src/shapes.ts +169 -0
- package/src/silhouette.ts +334 -0
- package/src/utils/color.ts +10 -1
- package/src/utils/fmt.ts +59 -0
- package/src/utils/paint.ts +317 -0
- package/src/utils/parse-color.ts +135 -0
- package/src/utils/path-data.ts +182 -0
- package/src/utils/png.ts +175 -0
- package/src/utils/polygon-clip.ts +163 -0
- package/src/utils/print-shared.ts +74 -0
- package/src/utils/svg-geometry.ts +838 -0
- package/src/utils/svg-gradient.ts +407 -0
- package/src/utils/svg-painter.ts +946 -0
- package/src/utils/webp.ts +556 -0
- package/src/utils.tsx +794 -385
- package/src/webp.ts +84 -0
- package/types/art.ts +74 -0
- package/types/color.ts +132 -12
- package/types/corner-dot.ts +41 -4
- package/types/corner-eye.ts +31 -4
- package/types/frame-spec.ts +748 -0
- package/types/frame.ts +67 -0
- package/types/image-pattern.ts +15 -0
- package/types/index.ts +106 -4
- package/types/qr.ts +180 -2
- package/types/template.ts +2 -2
- package/dist/cli.js +0 -4319
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: disc geometry */
|
|
2
|
+
/** biome-ignore-all lint/suspicious/noBitwiseOperators: a 32-bit PRNG */
|
|
3
|
+
import type { Modules } from "../types";
|
|
4
|
+
import { type QRCodeShape, type QRSilhouette } from "../types/qr";
|
|
5
|
+
import { type Outline } from "./qr-outline";
|
|
6
|
+
/** The light ring a shaped code keeps around its symbol, in modules. */
|
|
7
|
+
export declare function circleQuietZone(margin: number): number;
|
|
8
|
+
/**
|
|
9
|
+
* The outline a heart or silhouette code is drawn in, or null for square
|
|
10
|
+
* and circle codes and for silhouettes that can't hold a code (those draw
|
|
11
|
+
* as square codes).
|
|
12
|
+
*/
|
|
13
|
+
export declare function getShapeOutline(shape: QRCodeShape | undefined): Outline | null;
|
|
14
|
+
/**
|
|
15
|
+
* True when the code is drawn in an outline (a circle, a heart or a
|
|
16
|
+
* silhouette that fits) rather than as a plain square.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isShapedCode(shape: QRCodeShape | undefined): boolean;
|
|
19
|
+
/** Whether a silhouette can hold a code, and why not. */
|
|
20
|
+
export type QRSilhouetteFit = {
|
|
21
|
+
ok: true;
|
|
22
|
+
/** Share of the artwork's width the symbol and its quiet ring take */
|
|
23
|
+
share: number;
|
|
24
|
+
} | {
|
|
25
|
+
ok: false;
|
|
26
|
+
reason: "invalid" | "empty" | "thin";
|
|
27
|
+
/** A sentence for people, e.g. for an upload control */
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Whether `silhouette` is roomy enough for a code: the symbol and its quiet
|
|
32
|
+
* ring must take at least QR_SILHOUETTE_MIN_SHARE of the artwork's width.
|
|
33
|
+
* Silhouettes that fail draw as square codes; editors should refuse them
|
|
34
|
+
* with `message`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getQRSilhouetteFit(silhouette: QRSilhouette): QRSilhouetteFit;
|
|
37
|
+
/**
|
|
38
|
+
* Modules between the symbol and the edge of the artwork it is drawn in:
|
|
39
|
+
* `margin` for a square code; for a shaped one, enough for the symbol, its
|
|
40
|
+
* quiet ring and a band of decoration to fit inside the outline.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getLayoutMargin(symbolModules: number, margin: number, shape: QRCodeShape | undefined): number;
|
|
43
|
+
/**
|
|
44
|
+
* The decorative modules of a circle code, on the whole layout grid
|
|
45
|
+
* (`symbolModules + 2 × layoutMargin` across): dark cells outside the
|
|
46
|
+
* symbol's quiet ring and inside the disc, the same for the same `value`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function circleDecoration(value: string, symbolModules: number, margin: number): Modules;
|
|
49
|
+
/**
|
|
50
|
+
* The decorative modules of a code drawn in an outline (circle, heart or
|
|
51
|
+
* silhouette), on the whole layout grid, or null for a square code. Like a
|
|
52
|
+
* circle's: about half dark, seeded by `value`, outside the quiet ring and
|
|
53
|
+
* at least EDGE_INSET inside the outline.
|
|
54
|
+
*/
|
|
55
|
+
export declare function shapeDecoration(value: string, symbolModules: number, margin: number, shape: QRCodeShape | undefined): Modules | null;
|
|
56
|
+
/**
|
|
57
|
+
* The background outline of a shaped code drawn `size` px across: a disc
|
|
58
|
+
* (`{ circle: r }`), path data for a heart or silhouette, or null for a
|
|
59
|
+
* square code.
|
|
60
|
+
*/
|
|
61
|
+
export declare function shapeBackground(shape: QRCodeShape | undefined, size: number): {
|
|
62
|
+
circle: number;
|
|
63
|
+
} | {
|
|
64
|
+
path: string;
|
|
65
|
+
} | null;
|
|
66
|
+
/**
|
|
67
|
+
* Path data of a shaped code's outline drawn `size` px across, for editors
|
|
68
|
+
* that preview a shape on its own; null for a square code (or a silhouette
|
|
69
|
+
* that can't hold one, which draws square).
|
|
70
|
+
*/
|
|
71
|
+
export declare function getQRShapePath(shape: QRCodeShape | undefined, size: number): string | null;
|
|
72
|
+
//# sourceMappingURL=qr-shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-shape.d.ts","sourceRoot":"","sources":["../../src/qr-shape.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AAOzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,OAAO,EAEb,MAAM,cAAc,CAAC;AAetB,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,WAAW,GAAG,SAAS,GAC7B,OAAO,GAAG,IAAI,CAQhB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1
|
+
import type { QRProps } from "../types";
|
|
2
|
+
import type { CornerEyeDotPattern } from "../types/corner-dot";
|
|
3
|
+
import type { CornerEyePattern } from "../types/corner-eye";
|
|
4
|
+
import type { BodyPattern } from "../types/image-pattern";
|
|
5
|
+
/** Eye dots that break the finder's 1:1:3:1:1 ratio inside these eyes. */
|
|
6
|
+
export declare const WEAK_DOT_EYES: Partial<Record<CornerEyeDotPattern, readonly CornerEyePattern[]>>;
|
|
7
|
+
/** Body patterns whose thin modules next to these eyes fail at 9 px/module. */
|
|
8
|
+
export declare const WEAK_BODY_EYES: Partial<Record<BodyPattern, readonly CornerEyePattern[]>>;
|
|
9
|
+
/**
|
|
10
|
+
* Shapes that are fragile on their own, whatever they are paired with:
|
|
11
|
+
* circle and curly eyes read only in lenient decoders (scan-score's eye
|
|
12
|
+
* check), and these centres fail jsQR in sharp renders (screens, PNGs).
|
|
13
|
+
*/
|
|
14
|
+
export declare const WEAK_EYES: readonly CornerEyePattern[];
|
|
15
|
+
export declare const WEAK_DOTS: readonly CornerEyeDotPattern[];
|
|
16
|
+
/** Eyes whose circle centre fails strict decoders in sharp renders. */
|
|
17
|
+
export declare const WEAK_SHARP_DOT_EYES: Partial<Record<CornerEyeDotPattern, readonly CornerEyePattern[]>>;
|
|
18
|
+
/**
|
|
19
|
+
* Bodies that read every sharp render of a weak pair above, keyed
|
|
20
|
+
* "centre/eye". Pairs not listed fail with every body.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SHARP_DOT_EYE_SAFE_BODIES: Partial<Record<`${CornerEyeDotPattern}/${CornerEyePattern}`, readonly BodyPattern[]>>;
|
|
23
|
+
/** True when this centre, eye and body fail strict decoders in sharp renders. */
|
|
24
|
+
export declare function isWeakSharpPair(dot: CornerEyeDotPattern, eye: CornerEyePattern, body: BodyPattern): boolean;
|
|
25
|
+
export interface StylePairRisk {
|
|
26
|
+
/**
|
|
27
|
+
* A weak pair ("dot-eye", "body-eye"), a weak shape on its own, or a
|
|
28
|
+
* centre and eye that fail strict decoders in sharp renders only
|
|
29
|
+
* ("sharp-dot-eye": a warning; the editor doesn't block it).
|
|
30
|
+
*/
|
|
31
|
+
kind: "dot-eye" | "body-eye" | "eye" | "dot" | "sharp-dot-eye";
|
|
32
|
+
message: string;
|
|
33
|
+
fix: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The known-weak style pair in `props`, if any. QRCodeSVG's defaults apply
|
|
37
|
+
* (circle body, gear eyes, circle dots).
|
|
38
|
+
*/
|
|
39
|
+
export declare function getStylePairRisk(props: Pick<QRProps, "bodyPattern" | "cornerEyePattern" | "cornerEyeDotPattern">): StylePairRisk | null;
|
|
40
|
+
//# sourceMappingURL=scan-risk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-risk.d.ts","sourceRoot":"","sources":["../../src/scan-risk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAO1D,0EAA0E;AAC1E,eAAO,MAAM,aAAa,EAAE,OAAO,CACjC,MAAM,CAAC,mBAAmB,EAAE,SAAS,gBAAgB,EAAE,CAAC,CAwBzD,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,cAAc,EAAE,OAAO,CAClC,MAAM,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC,CAKjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,gBAAgB,EAAwB,CAAC;AAC1E,eAAO,MAAM,SAAS,EAAE,SAAS,mBAAmB,EAInD,CAAC;AAWF,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,EAAE,OAAO,CACvC,MAAM,CAAC,mBAAmB,EAAE,SAAS,gBAAgB,EAAE,CAAC,CAkBzD,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,OAAO,CAC7C,MAAM,CAAC,GAAG,mBAAmB,IAAI,gBAAgB,EAAE,EAAE,SAAS,WAAW,EAAE,CAAC,CAwB7E,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,eAAe,CAC7B,GAAG,EAAE,mBAAmB,EACxB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,WAAW,GAChB,OAAO,CAKT;AAED,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,eAAe,CAAC;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,IAAI,CACT,OAAO,EACP,aAAa,GAAG,kBAAkB,GAAG,qBAAqB,CAC3D,GACA,aAAa,GAAG,IAAI,CAwCtB"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { QRProps } from "../types";
|
|
2
|
+
import type { QRArtPixels } from "./art";
|
|
3
|
+
export type ScanGrade = "great" | "ok" | "risky" | "fails";
|
|
4
|
+
export interface ScanCheck {
|
|
5
|
+
id: string;
|
|
6
|
+
/** False only for a problem; a skipped check is `true` so it costs nothing. */
|
|
7
|
+
passed: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The check couldn't run on this input (a photo cropped too tight to see
|
|
10
|
+
* the quiet zone): neither passed nor failed. Show it as "not checked".
|
|
11
|
+
*/
|
|
12
|
+
skipped?: boolean;
|
|
13
|
+
message: string;
|
|
14
|
+
/** How to fix a failed check */
|
|
15
|
+
fix?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ScanScoreResult {
|
|
18
|
+
/** 0–100 */
|
|
19
|
+
score: number;
|
|
20
|
+
grade: ScanGrade;
|
|
21
|
+
checks: ScanCheck[];
|
|
22
|
+
}
|
|
23
|
+
export interface ImageScanScoreResult extends ScanScoreResult {
|
|
24
|
+
/** Decoded content, or null when no QR code was found */
|
|
25
|
+
data: string | null;
|
|
26
|
+
/** QR version (1–40) when the code could be located */
|
|
27
|
+
version: number | null;
|
|
28
|
+
}
|
|
29
|
+
export interface ScanScoreOptions {
|
|
30
|
+
/** QR code widths in pixels to test (default 96, 160, 320) */
|
|
31
|
+
sizes?: number[];
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
}
|
|
34
|
+
/** Widths (px) of the QR code that `getScanScore` decodes by default. */
|
|
35
|
+
export declare const SCAN_TEST_SIZES: readonly [96, 160, 320];
|
|
36
|
+
/**
|
|
37
|
+
* The lightest and darkest a picture gets, as "#rrggbb": the colors at its
|
|
38
|
+
* 90th and 10th percentile luminance. The contrast check judges an image
|
|
39
|
+
* fill by these (see getImageTones).
|
|
40
|
+
*/
|
|
41
|
+
export interface ImageTones {
|
|
42
|
+
light: string;
|
|
43
|
+
dark: string;
|
|
44
|
+
}
|
|
45
|
+
/** Image tones by image `src`. */
|
|
46
|
+
export type ImageToneMap = Record<string, ImageTones>;
|
|
47
|
+
/**
|
|
48
|
+
* Image tones from RGBA pixels (alpha below half skipped): the average color
|
|
49
|
+
* of the darkest and the lightest tenth of the pixels.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getImageTonesFromPixels(pixels: {
|
|
52
|
+
data: ArrayLike<number>;
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
}): ImageTones | null;
|
|
56
|
+
/** Image tones of a picture (browser only): drawn at 64 px and sampled. */
|
|
57
|
+
export declare function getImageTones(src: string): Promise<ImageTones | null>;
|
|
58
|
+
/** Contrast at or above this scans reliably (the scan score's pass line). */
|
|
59
|
+
export declare const SCAN_CONTRAST_MIN = 4.5;
|
|
60
|
+
/** Below this the score costs 30 points instead of 10. */
|
|
61
|
+
export declare const SCAN_CONTRAST_LOW = 3;
|
|
62
|
+
/** Below this the code fails the scan score outright. */
|
|
63
|
+
export declare const SCAN_CONTRAST_FAIL = 1.5;
|
|
64
|
+
/**
|
|
65
|
+
* Contrast a picture needs to scan reliably, in the code or behind it: its
|
|
66
|
+
* detail reads as noise at phone distances. Measured with the sample photos
|
|
67
|
+
* through the camera model (tests/export-image.test.ts): every picture in
|
|
68
|
+
* the dots decoded from 6.5:1, and busy photos behind the dots from 12:1.
|
|
69
|
+
*/
|
|
70
|
+
export declare const SCAN_IMAGE_CONTRAST_MIN: {
|
|
71
|
+
readonly code: 7;
|
|
72
|
+
readonly background: 12;
|
|
73
|
+
};
|
|
74
|
+
export interface ScanContrast {
|
|
75
|
+
/**
|
|
76
|
+
* Worst contrast between any code color and any background color (≥ 1);
|
|
77
|
+
* Infinity when no code color parses
|
|
78
|
+
*/
|
|
79
|
+
ratio: number;
|
|
80
|
+
/**
|
|
81
|
+
* What `ratio`'s pair needs: SCAN_CONTRAST_MIN for colors, more when a
|
|
82
|
+
* picture is involved (SCAN_IMAGE_CONTRAST_MIN). The low and fail lines
|
|
83
|
+
* scale with it.
|
|
84
|
+
*/
|
|
85
|
+
required: number;
|
|
86
|
+
/** Some code color is lighter than the background */
|
|
87
|
+
inverted: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The contrast check behind the scan score: the worst WCAG contrast ratio
|
|
91
|
+
* between every code color (foreground, eyes, eye centres and per-eye
|
|
92
|
+
* colors, every gradient stop) and every background color. See-through
|
|
93
|
+
* colors count as they look: the background over white paper, the code
|
|
94
|
+
* over the background.
|
|
95
|
+
*/
|
|
96
|
+
export declare function getScanContrast(props: QRProps, options?: {
|
|
97
|
+
imageTones?: ImageToneMap;
|
|
98
|
+
}): ScanContrast;
|
|
99
|
+
/**
|
|
100
|
+
* Estimates how reliably a QR design scans (browser only). Renders the code
|
|
101
|
+
* at several sizes with mild blur and contrast loss, decodes each with jsQR,
|
|
102
|
+
* and combines that with contrast, logo coverage vs error correction, quiet
|
|
103
|
+
* zone and eye-shape risk. jsQR is loaded on demand.
|
|
104
|
+
*
|
|
105
|
+
* This is a heuristic: real cameras, lighting and scanner apps vary.
|
|
106
|
+
*/
|
|
107
|
+
export declare function getScanScore(props: QRProps, options?: ScanScoreOptions): Promise<ScanScoreResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Smallest code width (px) the artwork passed to `getScanScoreFromPixels`
|
|
110
|
+
* should have: twice the largest default test size, so every test size is a
|
|
111
|
+
* downscale, as it is in the browser.
|
|
112
|
+
*/
|
|
113
|
+
export declare const PIXEL_SCORE_MIN_CODE_WIDTH = 640;
|
|
114
|
+
/**
|
|
115
|
+
* `getScanScore` for servers and other places without a DOM: the same
|
|
116
|
+
* checks, weights and camera model, decoding `pixels` instead of drawing the
|
|
117
|
+
* SVG on a canvas. `pixels` is the whole artwork as `props` renders it (the
|
|
118
|
+
* code plus its frame, if any), at any size with the code at least
|
|
119
|
+
* `PIXEL_SCORE_MIN_CODE_WIDTH` px wide (rasterized with resvg, sharp or a
|
|
120
|
+
* canvas). Transparent pixels count as white, like paper. Logos must already
|
|
121
|
+
* be painted into the pixels; an opaque placeholder of the same size scores
|
|
122
|
+
* the same.
|
|
123
|
+
*/
|
|
124
|
+
export declare function getScanScoreFromPixels(props: QRProps, pixels: QRArtPixels, options?: ScanScoreOptions): Promise<ScanScoreResult>;
|
|
125
|
+
/**
|
|
126
|
+
* Scores an existing QR code image (browser only, nothing is uploaded):
|
|
127
|
+
* finds and decodes the code, then checks it still decodes when shrunk and
|
|
128
|
+
* blurred, its contrast, polarity, quiet zone and the image resolution.
|
|
129
|
+
*/
|
|
130
|
+
export declare function getImageScanScore(source: HTMLImageElement | Blob, options?: ScanScoreOptions): Promise<ImageScanScoreResult>;
|
|
131
|
+
export interface PixelScanResult {
|
|
132
|
+
/** What the pixels decode to as they are, or null when no code was found */
|
|
133
|
+
data: string | null;
|
|
134
|
+
/** QR version of the code that was found, or null */
|
|
135
|
+
version: number | null;
|
|
136
|
+
/**
|
|
137
|
+
* True when the pixels decode to `expected` as they are and, at every
|
|
138
|
+
* check size, through the phone-camera model (two of three attempts)
|
|
139
|
+
*/
|
|
140
|
+
passed: boolean;
|
|
141
|
+
}
|
|
142
|
+
/** Code widths (px) `scanQRPixels` checks through the camera model. */
|
|
143
|
+
export declare const PIXEL_SCAN_SIZES: readonly [320];
|
|
144
|
+
/**
|
|
145
|
+
* Checks that raw RGBA pixels (from `decodePNGPixels`, `sharp().raw()` or a
|
|
146
|
+
* canvas) hold a QR code that decodes to `expected`: as they are, and through
|
|
147
|
+
* the phone-camera model (blur and contrast loss) with the code shrunk to each
|
|
148
|
+
* of `sizes` px. Needs no DOM, so it runs in Node. Light-on-dark codes fail,
|
|
149
|
+
* since many scanner apps can't read them.
|
|
150
|
+
*/
|
|
151
|
+
export declare function scanQRPixels(pixels: QRArtPixels, expected: string, options?: {
|
|
152
|
+
sizes?: readonly number[];
|
|
153
|
+
}): Promise<PixelScanResult>;
|
|
154
|
+
//# sourceMappingURL=scan-score.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-score.d.ts","sourceRoot":"","sources":["../../src/scan-score.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,OAAO,EAAE,MAAM,UAAU,CAAC;AAGrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAmBzC,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,+EAA+E;IAC/E,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY;IACZ,KAAK,EAAE,MAAM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
/** biome-ignore-all lint/suspicious/noBitwiseOperators: integer hashing */
|
|
3
|
+
export type Point = [number, number];
|
|
4
|
+
/** Closed polygon through `points`. */
|
|
5
|
+
export declare function polygonPath(points: Point[]): string;
|
|
6
|
+
/** Clockwise circle as two arcs. */
|
|
7
|
+
export declare function circlePath(cx: number, cy: number, r: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Rectangle with its own radius per corner, clockwise from the top-left:
|
|
10
|
+
* `[topLeft, topRight, bottomRight, bottomLeft]`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function roundedRectPath(x: number, y: number, width: number, height: number, radii?: [number, number, number, number] | number): string;
|
|
13
|
+
/** Points of a regular polygon (clockwise), first vertex at `rotation` degrees. */
|
|
14
|
+
export declare function regularPolygon(cx: number, cy: number, radius: number, sides: number, rotation?: number): Point[];
|
|
15
|
+
/** Points of a star with `points` tips, the first tip straight up. */
|
|
16
|
+
export declare function starPoints(cx: number, cy: number, outer: number, inner: number, points?: number): Point[];
|
|
17
|
+
/**
|
|
18
|
+
* Points of a superellipse |x/a|^e + |y/b|^e = 1 (a squircle when e = 4),
|
|
19
|
+
* clockwise from the right.
|
|
20
|
+
*/
|
|
21
|
+
export declare function superellipsePoints(cx: number, cy: number, a: number, b: number, exponent?: number, steps?: number): Point[];
|
|
22
|
+
/**
|
|
23
|
+
* Heart centered on (cx, cy), `size` wide; its height is about 0.92 × size.
|
|
24
|
+
* Drawn clockwise from the top notch.
|
|
25
|
+
*/
|
|
26
|
+
export declare function heartPath(cx: number, cy: number, size: number): string;
|
|
27
|
+
/** Rotates `points` by `degrees` around (cx, cy). */
|
|
28
|
+
export declare function rotatePoints(points: Point[], cx: number, cy: number, degrees: number): Point[];
|
|
29
|
+
/**
|
|
30
|
+
* Deterministic pseudo-random number in [0, 1) for a module position, so
|
|
31
|
+
* "random" styles render the same markup on the server and the client.
|
|
32
|
+
*/
|
|
33
|
+
export declare function hash2(x: number, y: number, salt?: number): number;
|
|
34
|
+
/** Small deterministic string hash (FNV-1a), base 36. */
|
|
35
|
+
export declare function hashString(value: string): string;
|
|
36
|
+
//# sourceMappingURL=shapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapes.d.ts","sourceRoot":"","sources":["../../src/shapes.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,2EAA2E;AAS3E,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErC,uCAAuC;AACvC,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAQnD;AAED,oCAAoC;AACpC,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,MAAU,GACnD,MAAM,CAmBR;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAC5B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,QAAQ,SAAM,GACb,KAAK,EAAE,CAKT;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CACxB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,SAAI,GACT,KAAK,EAAE,CAMT;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,SAAI,EACZ,KAAK,SAAK,GACT,KAAK,EAAE,CAUT;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAUtE;AAED,qDAAqD;AACrD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,KAAK,EAAE,EACf,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,GACd,KAAK,EAAE,CAWT;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,MAAM,CAQ5D;AAED,yDAAyD;AACzD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOhD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: sampling constants */
|
|
2
|
+
import { type QRSilhouette } from "../types/qr";
|
|
3
|
+
import type { QRArtPixels } from "./art";
|
|
4
|
+
export interface QRSilhouetteOptions {
|
|
5
|
+
/**
|
|
6
|
+
* What makes a pixel part of the shape: "alpha" (opaque pixels), "dark"
|
|
7
|
+
* (dark pixels, on white where see-through) or "auto" (default: alpha
|
|
8
|
+
* when the picture has see-through parts, else dark).
|
|
9
|
+
*/
|
|
10
|
+
mode?: "auto" | "alpha" | "dark";
|
|
11
|
+
/** Cells along the longer side (8 to QR_SILHOUETTE_MAX_CELLS, default the max) */
|
|
12
|
+
cells?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Samples raw RGBA pixels (a canvas, `sharp().raw()`, …) into a silhouette
|
|
16
|
+
* for `shape`. Works everywhere, no DOM needed. Throws when no shape is
|
|
17
|
+
* found or it is too small to trace; check the result with
|
|
18
|
+
* `getQRSilhouetteFit` before using it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createQRSilhouette(pixels: QRArtPixels, options?: QRSilhouetteOptions): QRSilhouette;
|
|
21
|
+
/**
|
|
22
|
+
* Loads a picture (PNG, JPEG, SVG, … as a Blob, data URL, same-origin URL
|
|
23
|
+
* or <img>) in the browser, draws it on a canvas and samples it with
|
|
24
|
+
* `createQRSilhouette`. The picture itself is never kept: an SVG is drawn
|
|
25
|
+
* as an image (no scripts run) and only the grid comes back.
|
|
26
|
+
*/
|
|
27
|
+
export declare function loadQRSilhouette(source: string | Blob | HTMLImageElement, options?: QRSilhouetteOptions): Promise<QRSilhouette>;
|
|
28
|
+
//# sourceMappingURL=silhouette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"silhouette.d.ts","sourceRoot":"","sources":["../../src/silhouette.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAQrE,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAOzC,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACjC,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoID;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAyFd;AAiCD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,gBAAgB,EACxC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,YAAY,CAAC,CAgCvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/utils/color.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,QAAQ,SAAY,GACnB,MAAM,
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/utils/color.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,QAAQ,SAAY,GACnB,MAAM,CA4BR"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Decimals kept for coordinates, radii and lengths. */
|
|
2
|
+
export declare const COORD_DECIMALS = 3;
|
|
3
|
+
/**
|
|
4
|
+
* Decimals kept for scale factors: their error grows with the distance from
|
|
5
|
+
* the origin (a 1000-unit artwork scaled by a 6-decimal factor still lands
|
|
6
|
+
* within 0.001).
|
|
7
|
+
*/
|
|
8
|
+
export declare const SCALE_DECIMALS = 6;
|
|
9
|
+
/** `value` rounded to `decimals` places (half up), never -0. */
|
|
10
|
+
export declare function roundTo(value: number, decimals?: number): number;
|
|
11
|
+
/**
|
|
12
|
+
* `value` for SVG, EPS or PDF output: rounded to `decimals` places, with no
|
|
13
|
+
* trailing zeros and no "-0". `fmt(12.345678901234567)` is "12.346",
|
|
14
|
+
* `fmt(4.5)` is "4.5" and `fmt(-0.0001)` is "0". No exponent for
|
|
15
|
+
* |value| < 1e21 with up to 6 decimals.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fmt(value: number, decimals?: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Template tag that writes every interpolated number with `fmt` (strings
|
|
20
|
+
* pass through), for path data and transforms:
|
|
21
|
+
* compact`M${x} ${y}h${w}` is "M1.5 2.333h7".
|
|
22
|
+
*/
|
|
23
|
+
export declare function compact(strings: TemplateStringsArray, ...values: (number | string)[]): string;
|
|
24
|
+
//# sourceMappingURL=fmt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fmt.d.ts","sourceRoot":"","sources":["../../../src/utils/fmt.ts"],"names":[],"mappings":"AAeA,wDAAwD;AACxD,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAiB,GAAG,MAAM,CAIxE;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAiB,GAAG,MAAM,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE,oBAAoB,EAC7B,GAAG,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAC7B,MAAM,CAQR"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: color and wedge math */
|
|
2
|
+
import type { GradientStop } from "../../types/color";
|
|
3
|
+
import { type RGBAColor } from "./parse-color";
|
|
4
|
+
/** "#rrggbb" for a color (alpha dropped). */
|
|
5
|
+
export declare function toHex6(color: RGBAColor): string;
|
|
6
|
+
/**
|
|
7
|
+
* A CSS color as an opaque color plus an opacity. Colors without alpha, fully
|
|
8
|
+
* transparent ones ("transparent" stays "transparent") and colors that don't
|
|
9
|
+
* parse come back unchanged, so they render exactly as before.
|
|
10
|
+
*/
|
|
11
|
+
export declare function splitAlpha(color: string): {
|
|
12
|
+
color: string;
|
|
13
|
+
opacity?: number;
|
|
14
|
+
};
|
|
15
|
+
/** `color` composited over an opaque `backdrop` (straight alpha). */
|
|
16
|
+
export declare function flattenOver(color: RGBAColor, backdrop: RGBAColor): RGBAColor;
|
|
17
|
+
export interface ParsedStop {
|
|
18
|
+
/** 0–1 */
|
|
19
|
+
offset: number;
|
|
20
|
+
color: RGBAColor;
|
|
21
|
+
}
|
|
22
|
+
/** Stops sorted by offset, offsets clamped to 0–1, colors parsed. */
|
|
23
|
+
export declare function parseStops(stops: GradientStop[]): ParsedStop[];
|
|
24
|
+
/**
|
|
25
|
+
* Color at `t` (0–1) along sorted stops, blended in premultiplied sRGB as
|
|
26
|
+
* CSS and SVG do, so a stop fading to transparent doesn't turn grey.
|
|
27
|
+
*/
|
|
28
|
+
export declare function colorAt(stops: ParsedStop[], t: number): RGBAColor;
|
|
29
|
+
export interface ConicWedge {
|
|
30
|
+
/** Triangle from the centre, as SVG path data */
|
|
31
|
+
d: string;
|
|
32
|
+
/** Opaque "#rrggbb" */
|
|
33
|
+
color: string;
|
|
34
|
+
/** Set when stops differ in alpha: this wedge's own opacity */
|
|
35
|
+
opacity?: number;
|
|
36
|
+
/** Start angle, degrees clockwise from the +x axis (0–360) */
|
|
37
|
+
from: number;
|
|
38
|
+
/** Degrees the wedge covers from `from` (overlap included) */
|
|
39
|
+
sweep: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ConicFan {
|
|
42
|
+
wedges: ConicWedge[];
|
|
43
|
+
/**
|
|
44
|
+
* Set when every stop shares one alpha below 1: the wedges are opaque and
|
|
45
|
+
* the whole fan is drawn at this opacity (one group, so overlaps don't
|
|
46
|
+
* add up).
|
|
47
|
+
*/
|
|
48
|
+
opacity?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Wedges that draw an angular (conic) gradient around (`cx`, `cy`): each is
|
|
52
|
+
* a thin triangle filled with the gradient's color at its middle angle, as
|
|
53
|
+
* many as the color change needs (about 2 levels per wedge, at most 4° and
|
|
54
|
+
* 720 wedges). `angle` is where the sweep starts, clockwise from the top,
|
|
55
|
+
* as in CSS `conic-gradient(from <angle>deg, …)`; `radius` must reach every
|
|
56
|
+
* point the fan has to cover (1.003 × the farthest point is enough).
|
|
57
|
+
*
|
|
58
|
+
* Anti-aliased renderers (PDF viewers, browsers) blend the background into
|
|
59
|
+
* the seam where two shapes meet edge to edge. So when the stops share one
|
|
60
|
+
* alpha, every wedge reaches one wedge width into the next (and the first
|
|
61
|
+
* one back under the last); painted in order, each seam lies on the solid
|
|
62
|
+
* wedge before it. When stops differ in alpha, wedges carry their own
|
|
63
|
+
* opacity and meet edge to edge, so nothing is painted twice.
|
|
64
|
+
*/
|
|
65
|
+
export declare function conicWedges(stops: GradientStop[], angle: number, cx: number, cy: number, radius: number): ConicFan;
|
|
66
|
+
/** Angles (degrees, 0–360 from +x, clockwise) of a point around a centre. */
|
|
67
|
+
export declare function angleAround(cx: number, cy: number, x: number, y: number): number;
|
|
68
|
+
/**
|
|
69
|
+
* The arc of directions (degrees from +x, clockwise) a box covers seen from
|
|
70
|
+
* (`cx`, `cy`), or null when the centre is inside the box (every direction).
|
|
71
|
+
*/
|
|
72
|
+
export declare function angularSpan(cx: number, cy: number, box: {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
}): [number, number] | null;
|
|
78
|
+
/** True when the arcs [a0, a1] and [b0, b1] (degrees, a1 ≥ a0) meet. */
|
|
79
|
+
export declare function arcsOverlap(a: [number, number], b: [number, number]): boolean;
|
|
80
|
+
//# sourceMappingURL=paint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paint.d.ts","sourceRoot":"","sources":["../../../src/utils/paint.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAMvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAO3D,6CAA6C;AAC7C,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAMA;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,GA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A;CAAE,GAC3D,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAoCzB;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAS7E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: color math */
|
|
2
|
+
export interface RGBAColor {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
/** 0 (transparent) to 1 (opaque) */
|
|
7
|
+
a: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Parses hex (#rgb, #rgba, #rrggbb, #rrggbbaa), rgb()/rgba(), `transparent`
|
|
11
|
+
* and common color names. Returns null for anything else.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseColor(input: string | null | undefined): RGBAColor | null;
|
|
14
|
+
/**
|
|
15
|
+
* Naive RGB → CMYK conversion (no ICC profile): K = 1 − max(R, G, B) and
|
|
16
|
+
* C/M/Y from what is left. Pure black maps to K only. Returns 0–1 values.
|
|
17
|
+
* Ask your printer for a proper color-managed conversion when exact brand
|
|
18
|
+
* colors matter.
|
|
19
|
+
*/
|
|
20
|
+
export declare function rgbToCmyk(r: number, g: number, b: number): [c: number, m: number, y: number, k: number];
|
|
21
|
+
//# sourceMappingURL=parse-color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-color.d.ts","sourceRoot":"","sources":["../../../src/utils/parse-color.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,oCAAoC;IACpC,CAAC,EAAE,MAAM,CAAC;CACX;AAmCD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CA2D7E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAc9C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: path grammar */
|
|
2
|
+
/** One path command with its own arguments (implicit repeats are split). */
|
|
3
|
+
export interface PathCommand {
|
|
4
|
+
/** Command letter as written: upper case is absolute, lower case relative */
|
|
5
|
+
command: string;
|
|
6
|
+
values: number[];
|
|
7
|
+
}
|
|
8
|
+
/** Characters path data in a frame spec may contain. */
|
|
9
|
+
export declare const PATH_DATA_CHARSET: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* Reads path data into commands, or returns null when it breaks the grammar
|
|
12
|
+
* (unknown characters, a missing argument, an exponent, more than
|
|
13
|
+
* `maxDecimals` decimals, or not starting with a move).
|
|
14
|
+
*/
|
|
15
|
+
export declare function tokenizePathData(d: string, maxDecimals?: number): PathCommand[] | null;
|
|
16
|
+
/** Segments a command adds once drawn (an arc becomes up to four curves). */
|
|
17
|
+
export declare function countPathSegments(commands: PathCommand[]): number;
|
|
18
|
+
/**
|
|
19
|
+
* Writes commands back as path data, scaled by `scale` and moved by
|
|
20
|
+
* (dx, dy). Relative commands are only scaled; arc radii scale and arc
|
|
21
|
+
* angles and flags are kept, so the shape is exact under the uniform scale.
|
|
22
|
+
*/
|
|
23
|
+
export declare function writePathData(commands: PathCommand[], scale?: number, dx?: number, dy?: number): string;
|
|
24
|
+
//# sourceMappingURL=path-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-data.d.ts","sourceRoot":"","sources":["../../../src/utils/path-data.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAU/D,4EAA4E;AAC5E,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAeD,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,QAAwC,CAAC;AAIvE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,MAAM,EACT,WAAW,SAA2B,GACrC,WAAW,EAAE,GAAG,IAAI,CAgFtB;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAMjE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,SAAI,EACT,EAAE,SAAI,EACN,EAAE,SAAI,GACL,MAAM,CAqCR"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: PNG format constants */
|
|
2
|
+
/** biome-ignore-all lint/suspicious/noBitwiseOperators: PNG filters */
|
|
3
|
+
export interface DecodedImage {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
/** RGBA bytes, row by row */
|
|
7
|
+
data: Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
/** zlib-wrapped deflate, or null when Compression Streams are unavailable. */
|
|
10
|
+
export declare function deflate(bytes: Uint8Array): Promise<Uint8Array | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Decodes 8-bit, non-interlaced PNGs (gray, gray+alpha, RGB, RGBA, palette).
|
|
13
|
+
* Returns null for anything else.
|
|
14
|
+
*/
|
|
15
|
+
export declare function decodePng(bytes: Uint8Array): Promise<DecodedImage | null>;
|
|
16
|
+
//# sourceMappingURL=png.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"png.d.ts","sourceRoot":"","sources":["../../../src/utils/png.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,uEAAuE;AAIvE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,IAAI,EAAE,UAAU,CAAC;CAClB;AAYD,8EAA8E;AAC9E,wBAAsB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAK3E;AAiCD;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CA2G9B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: geometry */
|
|
2
|
+
import type { Segment } from "./svg-geometry";
|
|
3
|
+
export type Point = [number, number];
|
|
4
|
+
/**
|
|
5
|
+
* Closed polygons of `segments` (one per subpath), with curves flattened to
|
|
6
|
+
* at most `tolerance` units of chord error (roughly).
|
|
7
|
+
*/
|
|
8
|
+
export declare function flattenSegments(segments: Segment[], tolerance?: number): Point[][];
|
|
9
|
+
export interface ClipBox {
|
|
10
|
+
x0: number;
|
|
11
|
+
y0: number;
|
|
12
|
+
x1: number;
|
|
13
|
+
y1: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Sutherland–Hodgman clip of one closed polygon to an axis-aligned box. The
|
|
17
|
+
* result keeps the polygon's winding inside the box, so a shape made of
|
|
18
|
+
* several subpaths fills the same way (nonzero or even-odd) once each
|
|
19
|
+
* subpath is clipped.
|
|
20
|
+
*/
|
|
21
|
+
export declare function clipPolygon(points: Point[], box: ClipBox): Point[];
|
|
22
|
+
/** Closed polygons as path data (absolute, 3 decimals). */
|
|
23
|
+
export declare function polygonsToPath(polygons: Point[][]): string;
|
|
24
|
+
/** Bounding box of segments (control points included), or null if empty. */
|
|
25
|
+
export declare function segmentsBounds(segments: Segment[]): ClipBox | null;
|
|
26
|
+
//# sourceMappingURL=polygon-clip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polygon-clip.d.ts","sourceRoot":"","sources":["../../../src/utils/polygon-clip.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAM3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErC;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,SAAS,SAAO,GACf,KAAK,EAAE,EAAE,CAyDX;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAID;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,GAAG,KAAK,EAAE,CA+BlE;AAOD,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,CAQ1D;AAED,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,GAAG,IAAI,CAqBlE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { QRProps } from "../../types";
|
|
2
|
+
import { type SvgPainter } from "./svg-painter";
|
|
3
|
+
/** Logical render size; print output is scaled from this. */
|
|
4
|
+
export declare const PRINT_RENDER_SIZE = 1000;
|
|
5
|
+
/** SVG markup of the artwork at the logical print render size (1000 units). */
|
|
6
|
+
export declare function renderPrintSVG(props: QRProps): Promise<string>;
|
|
7
|
+
/** Color the bleed area is filled with, if any. */
|
|
8
|
+
export declare function getPrintBleedColor(props: QRProps): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* SVG paint for the bleed area: `getPrintBleedColor`, except that a gradient
|
|
11
|
+
* background (no frame or template) returns the background's own
|
|
12
|
+
* `url(#…)` fill from `markup`, so the bleed continues the gradient.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPrintBleedFill(props: QRProps, markup: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* What see-through paint is flattened over where a format can't blend: the
|
|
17
|
+
* background (its first color for a gradient) on white paper.
|
|
18
|
+
*/
|
|
19
|
+
export declare function setBackdrop(painter: SvgPainter, props: QRProps): void;
|
|
20
|
+
//# sourceMappingURL=print-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-shared.d.ts","sourceRoot":"","sources":["../../../src/utils/print-shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAU3C,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3D,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,+EAA+E;AAC/E,wBAAsB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAQpE;AAED,mDAAmD;AACnD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAMhE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,IAAI,CAef;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,QAO9D"}
|