qr-code-styling-node 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 +71 -7
- package/lib/art/art.d.ts +12 -8
- package/lib/art/functionModules.d.ts +1 -1
- package/lib/core/QRCanvas.d.ts +3 -0
- package/lib/core/QROptions.d.ts +2 -0
- package/lib/core/QRSVG.d.ts +5 -1
- package/lib/figures/dot/canvas/QRDot.d.ts +2 -0
- package/lib/figures/dot/svg/QRDot.d.ts +2 -0
- package/lib/figures/shapes.d.ts +50 -0
- package/lib/qr-code-styling.common.js +1 -1
- package/lib/qr-code-styling.common.js.map +1 -1
- package/lib/qr-code-styling.js +1 -1
- package/lib/qr-code-styling.js.map +1 -1
- package/lib/qr-code-styling.mjs +742 -178
- package/lib/qr-code-styling.mjs.map +4 -4
- package/lib/tools/cornerTypes.d.ts +10 -0
- package/lib/tools/frameLayout.d.ts +43 -0
- package/lib/tools/qrArea.d.ts +14 -0
- package/lib/tools/svgDom.d.ts +3 -0
- package/lib/types/index.d.ts +44 -5
- package/package.json +4 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RequiredOptions } from "../core/QROptions";
|
|
2
|
+
import { CornerDotType, CornerSquareType, DotType } from "../types";
|
|
3
|
+
/** Dot types with a round look; blend art matches its corners and correction dots to them. */
|
|
4
|
+
export declare const ROUND_DOT_TYPES: DotType[];
|
|
5
|
+
/** True when alignment patterns must be drawn as plain squares for this dot type to scan. */
|
|
6
|
+
export declare const needsSolidAlignment: (type: DotType) => boolean;
|
|
7
|
+
export default function getCornerTypes(options: RequiredOptions): {
|
|
8
|
+
square?: CornerSquareType;
|
|
9
|
+
dot?: CornerDotType;
|
|
10
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { RequiredOptions } from "../core/QROptions";
|
|
2
|
+
export interface FrameLayout {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
/** Where the QR code goes, as a square. */
|
|
6
|
+
qr: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
size: number;
|
|
10
|
+
};
|
|
11
|
+
frame?: {
|
|
12
|
+
thickness: number;
|
|
13
|
+
radius: number;
|
|
14
|
+
color: string;
|
|
15
|
+
};
|
|
16
|
+
label?: {
|
|
17
|
+
text: string;
|
|
18
|
+
band: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
};
|
|
24
|
+
color: string;
|
|
25
|
+
font: string;
|
|
26
|
+
fontSize: number;
|
|
27
|
+
fontFamily: string;
|
|
28
|
+
fontWeight: string;
|
|
29
|
+
};
|
|
30
|
+
background: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const hasFrame: (options: RequiredOptions) => boolean;
|
|
33
|
+
export default function getFrameLayout(options: RequiredOptions): FrameLayout;
|
|
34
|
+
/** Options for drawing the bare QR code inside the frame. */
|
|
35
|
+
export declare const innerOptions: (options: RequiredOptions, size: number) => RequiredOptions;
|
|
36
|
+
/** Area behind the logo: the logo box including its margin, with rounded corners. */
|
|
37
|
+
export declare const getLogoPlate: (options: RequiredOptions, dx: number, dy: number, width: number, height: number) => {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
radius: number;
|
|
43
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RequiredOptions } from "../core/QROptions";
|
|
2
|
+
export interface QRArea {
|
|
3
|
+
count: number;
|
|
4
|
+
/** Size of one module in pixels. */
|
|
5
|
+
dotSize: number;
|
|
6
|
+
/** Top-left corner of the code (without margin). */
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Where the code sits in the output. By default it is centered and fills the size minus the margin.
|
|
12
|
+
* With art.placement it sits in that square of the picture instead.
|
|
13
|
+
*/
|
|
14
|
+
export default function getQRArea(options: RequiredOptions, count: number): QRArea;
|
package/lib/tools/svgDom.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export declare class VirtualSVGElement {
|
|
|
10
10
|
parentNode: VirtualSVGElement | null;
|
|
11
11
|
childNodes: VirtualSVGElement[];
|
|
12
12
|
private _attributes;
|
|
13
|
+
private _text;
|
|
14
|
+
get textContent(): string;
|
|
15
|
+
set textContent(value: string);
|
|
13
16
|
constructor(tagName: string);
|
|
14
17
|
get nodeName(): string;
|
|
15
18
|
setAttribute(name: string, value: string): void;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface UnknownObject {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}
|
|
4
|
-
export type DotType = "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded";
|
|
5
|
-
export type CornerDotType = "dot" | "square";
|
|
6
|
-
export type CornerSquareType = "dot" | "square" | "extra-rounded";
|
|
4
|
+
export type DotType = "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded" | "diamond" | "small-square" | "vertical-lines" | "horizontal-lines" | "fluid";
|
|
5
|
+
export type CornerDotType = "dot" | "square" | "rounded";
|
|
6
|
+
export type CornerSquareType = "dot" | "square" | "extra-rounded" | "rounded";
|
|
7
7
|
export type Extension = "svg" | "png" | "jpeg" | "webp";
|
|
8
8
|
export type GradientType = "radial" | "linear";
|
|
9
9
|
export type DrawType = "canvas" | "svg";
|
|
@@ -87,22 +87,33 @@ export interface ResvgConstructor {
|
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
export type ArtMode = "halftone" | "colorize";
|
|
90
|
+
export type ArtMode = "halftone" | "colorize" | "blend";
|
|
91
91
|
export interface ArtOptions {
|
|
92
92
|
/** The picture to blend into the QR code (URL or data URL). */
|
|
93
93
|
image: string;
|
|
94
94
|
/**
|
|
95
95
|
* "halftone": the picture is redrawn as fine black/white (or colored) pixels, with the QR modules in the middle.
|
|
96
96
|
* "colorize": the dots keep their shape and are painted with a darkened copy of the picture.
|
|
97
|
+
* "blend": the picture fills the whole image; dots are drawn only where the picture is not already
|
|
98
|
+
* dark or light enough for the code, so it reads as an illustration.
|
|
97
99
|
*/
|
|
98
100
|
mode?: ArtMode;
|
|
99
101
|
/** halftone only: use the picture's own colors instead of dotsOptions/backgroundOptions colors. */
|
|
100
102
|
colored?: boolean;
|
|
101
103
|
/** colorize only: also show a light copy of the picture behind the dots. Default true. */
|
|
102
104
|
background?: boolean;
|
|
103
|
-
/** 0 to 1. Higher keeps dark and light further apart: easier to scan, less of the picture. Default 0.5 (halftone), 0.7 (colorize). */
|
|
105
|
+
/** 0 to 1. Higher keeps dark and light further apart: easier to scan, less of the picture. Default 0.5 (halftone), 0.7 (colorize), 0.6 (blend). */
|
|
104
106
|
contrast?: number;
|
|
105
107
|
crossOrigin?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Put the code in a square of the picture instead of the middle, in pixels of the output:
|
|
110
|
+
* { x, y, size }. Mostly for "blend", where the picture fills the whole image. The margin is ignored.
|
|
111
|
+
*/
|
|
112
|
+
placement?: {
|
|
113
|
+
x: number;
|
|
114
|
+
y: number;
|
|
115
|
+
size: number;
|
|
116
|
+
};
|
|
106
117
|
}
|
|
107
118
|
/** Same signature as jsQR: (rgba, width, height) => { data } | null. */
|
|
108
119
|
export type QRDecoder = (data: Uint8ClampedArray, width: number, height: number, options?: Record<string, unknown>) => {
|
|
@@ -122,6 +133,26 @@ export interface VerifyResult {
|
|
|
122
133
|
contrast?: number;
|
|
123
134
|
attempts: number;
|
|
124
135
|
}
|
|
136
|
+
export interface FrameOptions {
|
|
137
|
+
/** Frame and label band color. Default "#000". */
|
|
138
|
+
color?: string;
|
|
139
|
+
/** Border thickness in px. Default 4% of the size. */
|
|
140
|
+
width?: number;
|
|
141
|
+
/** Outer corner radius in px. Default 0. */
|
|
142
|
+
radius?: number;
|
|
143
|
+
/** Space between the frame and the QR code in px. Default 4% of the size. */
|
|
144
|
+
padding?: number;
|
|
145
|
+
}
|
|
146
|
+
export interface LabelOptions {
|
|
147
|
+
text: string;
|
|
148
|
+
position?: "top" | "bottom";
|
|
149
|
+
/** Default white on a frame, otherwise the dots color. */
|
|
150
|
+
color?: string;
|
|
151
|
+
/** In px. Default 7% of the size. */
|
|
152
|
+
fontSize?: number;
|
|
153
|
+
fontFamily?: string;
|
|
154
|
+
fontWeight?: string | number;
|
|
155
|
+
}
|
|
125
156
|
export type Options = {
|
|
126
157
|
type?: DrawType;
|
|
127
158
|
width?: number;
|
|
@@ -138,6 +169,10 @@ export type Options = {
|
|
|
138
169
|
resvg?: ResvgConstructor;
|
|
139
170
|
/** Blend a picture into the QR code. Needs a canvas (browser, or nodeCanvas on Node). */
|
|
140
171
|
art?: ArtOptions;
|
|
172
|
+
/** A border around the code. The code shrinks to fit inside width x height. */
|
|
173
|
+
frameOptions?: FrameOptions;
|
|
174
|
+
/** A line of text above or below the code, such as "Scan to order". */
|
|
175
|
+
labelOptions?: LabelOptions;
|
|
141
176
|
qrOptions?: {
|
|
142
177
|
typeNumber?: TypeNumber;
|
|
143
178
|
mode?: Mode;
|
|
@@ -149,6 +184,10 @@ export type Options = {
|
|
|
149
184
|
imageSize?: number;
|
|
150
185
|
crossOrigin?: string;
|
|
151
186
|
margin?: number;
|
|
187
|
+
/** Plate drawn behind the logo, e.g. "#ffffff". */
|
|
188
|
+
backgroundColor?: string;
|
|
189
|
+
/** Corner radius of the plate, 0 (square) to 0.5 (round). Default 0.2. */
|
|
190
|
+
backgroundRadius?: number;
|
|
152
191
|
};
|
|
153
192
|
dotsOptions?: {
|
|
154
193
|
type?: DotType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qr-code-styling-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Style your QR codes: dots, corners, gradients and a logo. Works in the browser and on Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"qr",
|
|
@@ -71,7 +71,9 @@
|
|
|
71
71
|
"start": "webpack serve --open --config webpack.config.dev-server.js",
|
|
72
72
|
"clean": "node -e \"require('fs').rmSync('lib',{recursive:true,force:true})\"",
|
|
73
73
|
"bench": "npm run build && node scripts/bench.mjs",
|
|
74
|
-
"art-examples": "npm run build && node scripts/art-examples.mjs"
|
|
74
|
+
"art-examples": "npm run build && node scripts/art-examples.mjs",
|
|
75
|
+
"style-examples": "npm run build && node scripts/style-examples.mjs",
|
|
76
|
+
"blend-examples": "npm run build && node scripts/blend-examples.mjs"
|
|
75
77
|
},
|
|
76
78
|
"dependencies": {
|
|
77
79
|
"qrcode-generator": "^1.4.3"
|