qr-code-styling-node 1.8.0 → 1.9.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.
@@ -0,0 +1,8 @@
1
+ import { RequiredOptions } from "../core/QROptions";
2
+ import { CornerDotType, CornerSquareType, DotType } from "../types";
3
+ /** True when alignment patterns must be drawn as plain squares for this dot type to scan. */
4
+ export declare const needsSolidAlignment: (type: DotType) => boolean;
5
+ export default function getCornerTypes(options: RequiredOptions): {
6
+ square?: CornerSquareType;
7
+ dot?: CornerDotType;
8
+ };
@@ -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
+ };
@@ -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;
@@ -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";
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";
@@ -122,6 +122,26 @@ export interface VerifyResult {
122
122
  contrast?: number;
123
123
  attempts: number;
124
124
  }
125
+ export interface FrameOptions {
126
+ /** Frame and label band color. Default "#000". */
127
+ color?: string;
128
+ /** Border thickness in px. Default 4% of the size. */
129
+ width?: number;
130
+ /** Outer corner radius in px. Default 0. */
131
+ radius?: number;
132
+ /** Space between the frame and the QR code in px. Default 4% of the size. */
133
+ padding?: number;
134
+ }
135
+ export interface LabelOptions {
136
+ text: string;
137
+ position?: "top" | "bottom";
138
+ /** Default white on a frame, otherwise the dots color. */
139
+ color?: string;
140
+ /** In px. Default 7% of the size. */
141
+ fontSize?: number;
142
+ fontFamily?: string;
143
+ fontWeight?: string | number;
144
+ }
125
145
  export type Options = {
126
146
  type?: DrawType;
127
147
  width?: number;
@@ -138,6 +158,10 @@ export type Options = {
138
158
  resvg?: ResvgConstructor;
139
159
  /** Blend a picture into the QR code. Needs a canvas (browser, or nodeCanvas on Node). */
140
160
  art?: ArtOptions;
161
+ /** A border around the code. The code shrinks to fit inside width x height. */
162
+ frameOptions?: FrameOptions;
163
+ /** A line of text above or below the code, such as "Scan to order". */
164
+ labelOptions?: LabelOptions;
141
165
  qrOptions?: {
142
166
  typeNumber?: TypeNumber;
143
167
  mode?: Mode;
@@ -149,6 +173,10 @@ export type Options = {
149
173
  imageSize?: number;
150
174
  crossOrigin?: string;
151
175
  margin?: number;
176
+ /** Plate drawn behind the logo, e.g. "#ffffff". */
177
+ backgroundColor?: string;
178
+ /** Corner radius of the plate, 0 (square) to 0.5 (round). Default 0.2. */
179
+ backgroundRadius?: number;
152
180
  };
153
181
  dotsOptions?: {
154
182
  type?: DotType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qr-code-styling-node",
3
- "version": "1.8.0",
3
+ "version": "1.9.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,8 @@
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"
75
76
  },
76
77
  "dependencies": {
77
78
  "qrcode-generator": "^1.4.3"