qr-code-styling-node 1.3.4 → 1.6.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/LICENSE CHANGED
@@ -1,6 +1,7 @@
1
1
  MIT License
2
2
 
3
3
  Copyright (c) 2019 Denys Kozak
4
+ Copyright (c) 2021-present qr-code-styling-node contributors
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,22 +1,26 @@
1
- # QR Code Styling
2
- [![Version](https://img.shields.io/npm/v/qr-code-styling.svg)](https://www.npmjs.org/package/qr-code-styling)
1
+ # QR Code Styling (Node)
2
+ [![npm](https://img.shields.io/npm/v/qr-code-styling-node.svg)](https://www.npmjs.com/package/qr-code-styling-node)
3
+ [![CI](https://github.com/ducminhquan/qr-code-styling/actions/workflows/ci.yml/badge.svg)](https://github.com/ducminhquan/qr-code-styling/actions/workflows/ci.yml)
3
4
 
4
- JavaScript library for generating QR codes with a logo and styling.
5
+ JavaScript library for generating styled QR codes with a logo: custom dots, corners, gradients and backgrounds.
6
+ Works in the browser (canvas or SVG) and on Node.js servers, with a single dependency and one options object.
5
7
 
6
- Try it here https://qr-code-styling.com
8
+ `qr-code-styling-node` is an independently maintained project. It started as a fork of
9
+ [qr-code-styling](https://github.com/kozakdenys/qr-code-styling) by Denys Kozak and keeps its API,
10
+ so code written for either package keeps working. See [CHANGELOG.md](CHANGELOG.md) for what changed.
7
11
 
8
- If you have issues / suggestions / notes / questions, please open an issue or contact me. Let's create a cool library together.
12
+ Found a bug or have an idea? [Open an issue](https://github.com/ducminhquan/qr-code-styling/issues).
9
13
  ### Examples
10
14
  <p float="left">
11
- <img style="display:inline-block" src="https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/facebook_example_new.png" width="240" />
12
- <img style="display:inline-block" src="https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/qr_code_example.png" width="240" />
13
- <img style="display:inline-block" src="https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/telegram_example_new.png" width="240" />
15
+ <img style="display:inline-block" src="https://raw.githubusercontent.com/ducminhquan/qr-code-styling/master/src/assets/facebook_example_new.png" width="240" />
16
+ <img style="display:inline-block" src="https://raw.githubusercontent.com/ducminhquan/qr-code-styling/master/src/assets/qr_code_example.png" width="240" />
17
+ <img style="display:inline-block" src="https://raw.githubusercontent.com/ducminhquan/qr-code-styling/master/src/assets/telegram_example_new.png" width="240" />
14
18
  </p>
15
19
 
16
20
  ### Installation
17
21
 
18
22
  ```
19
- npm install qr-code-styling
23
+ npm install qr-code-styling-node
20
24
  ```
21
25
 
22
26
  ### Usage
@@ -27,7 +31,7 @@ npm install qr-code-styling
27
31
  <head>
28
32
  <meta charset="UTF-8">
29
33
  <title>QR Code Styling</title>
30
- <script type="text/javascript" src="https://unpkg.com/qr-code-styling@1.3.3/lib/qr-code-styling.js"></script>
34
+ <script type="text/javascript" src="https://unpkg.com/qr-code-styling-node@1.6.0/lib/qr-code-styling.js"></script>
31
35
  </head>
32
36
  <body>
33
37
  <div id="canvas"></div>
@@ -36,6 +40,7 @@ npm install qr-code-styling
36
40
  const qrCode = new QRCodeStyling({
37
41
  width: 300,
38
42
  height: 300,
43
+ type: "svg",
39
44
  data: "https://www.facebook.com/",
40
45
  image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
41
46
  dotsOptions: {
@@ -52,12 +57,25 @@ npm install qr-code-styling
52
57
  });
53
58
 
54
59
  qrCode.append(document.getElementById("canvas"));
60
+ qrCode.download({ name: "qr", extension: "svg" });
55
61
  </script>
56
62
  </body>
57
63
  </html>
58
64
  ```
65
+ ---
59
66
 
60
- [**Usage with React**](https://codesandbox.io/s/qr-code-styling-react-example-l8rwl?file=/src/App.js)
67
+ ### Using with a bundler or TypeScript
68
+
69
+ ```js
70
+ import QRCodeStyling, { dotTypes } from "qr-code-styling-node";
71
+
72
+ const qrCode = new QRCodeStyling({ data: "https://example.com", dotsOptions: { type: dotTypes.rounded } });
73
+ qrCode.append(document.getElementById("canvas"));
74
+ ```
75
+
76
+ The package ships an ES module build (`import`), a CommonJS/UMD build (`require` and `<script>`) and TypeScript types.
77
+
78
+ ---
61
79
 
62
80
  ### API Documentation
63
81
 
@@ -70,19 +88,22 @@ options|object|Init object
70
88
 
71
89
  `options` structure
72
90
 
73
- Property |Type |Default Value|Description
74
- -----------------------|------|-------------|-----------------------------------------------------
75
- width |number|`300` |Size of canvas
76
- height |number|`300` |Size of canvas
77
- data |string| |The date will be encoded to the QR code
78
- image |string| |The image will be copied to the center of the QR code
79
- margin |number|`0` |Margin around canvas
80
- qrOptions |object| |Options will be passed to `qrcode-generator` lib
81
- imageOptions |object| |Specific image options, details see below
82
- dotsOptions |object| |Dots styling options
83
- cornersSquareOptions |object| |Square in the corners styling options
84
- cornersDotOptionsHelper|object| |Dots in the corners styling options
85
- backgroundOptions |object| |QR background styling options
91
+ Property |Type |Default Value|Description
92
+ -----------------------|-------------------------|-------------|-----------------------------------------------------
93
+ width |number |`300` |Size of canvas
94
+ height |number |`300` |Size of canvas
95
+ type |string (`'canvas' 'svg'`)|`canvas` |The type of the element that will be rendered
96
+ data |string | |The date will be encoded to the QR code
97
+ image |string | |The image will be copied to the center of the QR code
98
+ margin |number |`0` |Margin around canvas
99
+ qrOptions |object | |Options will be passed to `qrcode-generator` lib
100
+ imageOptions |object | |Specific image options, details see below
101
+ dotsOptions |object | |Dots styling options
102
+ cornersSquareOptions |object | |Square in the corners styling options
103
+ cornersDotOptionsHelper|object | |Dots in the corners styling options
104
+ backgroundOptions |object | |QR background styling options
105
+ nodeCanvas |node-canvas | |Only specify when running on a node server for canvas type, please refer to node section below
106
+ jsDom |jsdom | |Only specify when running on a node server for svg type, please refer to node section below
86
107
 
87
108
  `options.qrOptions` structure
88
109
 
@@ -100,6 +121,9 @@ hideBackgroundDots|boolean |`true` |Hide al
100
121
  imageSize |number |`0.4` |Coefficient of the image size. Not recommended to use ove 0.5. Lower is better
101
122
  margin |number |`0` |Margin of the image in px
102
123
  crossOrigin |string(`'anonymous' 'use-credentials'`)| |Set "anonymous" if you want to download QR code from other origins.
124
+ saveAsBlob |boolean |`false` |Saves image as base64 blob in svg type, see bellow
125
+
126
+ When QR type is svg, the image may not load in certain applications as it is saved as a url, and some svg applications will not render url images for security reasons. Setting `saveAsBlob` to true will instead save the image as a blob, allowing it to render correctly in more places, but will also increase the file size.
103
127
 
104
128
  `options.dotsOptions` structure
105
129
 
@@ -170,27 +194,108 @@ Param |Type |Description
170
194
  ---------|-----------|-----------
171
195
  container|DOM element|This container will be used for appending of the QR code
172
196
 
197
+ `QRCodeStyling.getRawData(extension) => Promise<Blob>`
198
+
199
+ Param |Type |Default Value|Description
200
+ ---------|------------------------------------|-------------|------------
201
+ extension|string (`'png' 'jpeg' 'webp' 'svg'`)|`'png'` |Blob type on browser, Buffer type on Node
202
+
173
203
  `QRCodeStyling.update(options) => void`
174
204
 
175
205
  Param |Type |Description
176
206
  -------|------|--------------------------------------
177
207
  options|object|The same options as for initialization
178
208
 
179
- `QRCodeStyling.download(downloadOptions) => void`
209
+ `QRCodeStyling.download(downloadOptions) => Promise<void>`
180
210
 
181
211
  Param |Type |Description
182
212
  ---------------|------|------------
183
213
  downloadOptions|object|Options with extension and name of file (not required)
184
214
 
215
+ Promise returned will resolve into the data URI of the QR code image.
216
+
185
217
  `downloadOptions` structure
186
218
 
187
- Property |Type |Default Value|Description
188
- ---------|------------------------------|-------------|-----------------------------------------------------
189
- name |string |`'qr'` |Name of the downloaded file
190
- extension|string (`'png' 'jpeg' 'webp'`)|`'png'` |File extension
219
+ Property |Type |Default Value|Description
220
+ ---------|------------------------------------|-------------|-----------------------------------------------------
221
+ name |string |`'qr'` |Name of the downloaded file
222
+ extension|string (`'png' 'jpeg' 'webp' 'svg'`)|`'png'` |File extension
223
+
224
+ ### Node Support
225
+ You can use this on a node server by passing through the node-canvas or jsdom object depending if your creating a non-svg or svg respectively. You must pass both if using `imageOptions.saveAsBlob`.
226
+
227
+ Calling `getRawData` in node will return a Buffer instead of a Blob.
228
+
229
+ `canvas` and `jsdom` are not dependencies of this package; install the ones you need (`npm install canvas jsdom`).
230
+
231
+ ```js
232
+ const QRCodeStyling = require("qr-code-styling-node");
233
+ // The 1.5.0 style import keeps working too:
234
+ // const { QRCodeStyling } = require("qr-code-styling-node/lib/qr-code-styling.common.js");
235
+ const nodeCanvas = require("canvas");
236
+ const { JSDOM } = require("jsdom");
237
+ const fs = require("fs");
238
+
239
+ const options = {
240
+ width: 300,
241
+ height: 300,
242
+ data: "https://www.facebook.com/",
243
+ image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
244
+ dotsOptions: {
245
+ color: "#4267b2",
246
+ type: "rounded"
247
+ },
248
+ backgroundOptions: {
249
+ color: "#e9ebee",
250
+ },
251
+ imageOptions: {
252
+ crossOrigin: "anonymous",
253
+ margin: 20
254
+ }
255
+ }
256
+
257
+ // For canvas type
258
+ const qrCodeImage = new QRCodeStyling({
259
+ nodeCanvas, // this is required
260
+ ...options
261
+ });
262
+
263
+ qrCodeImage.getRawData("png").then((buffer) => {
264
+ fs.writeFileSync("test.png", buffer);
265
+ });
266
+
267
+ // For svg type
268
+ const qrCodeSvg = new QRCodeStyling({
269
+ jsdom: JSDOM, // this is required
270
+ type: "svg",
271
+ ...options
272
+ });
273
+
274
+ qrCodeSvg.getRawData("svg").then((buffer) => {
275
+ fs.writeFileSync("test.svg", buffer);
276
+ });
277
+
278
+ // For svg type with the inner-image saved as a blob
279
+ // (inner-image will render in more places but file will be larger)
280
+ const qrCodeSvgWithBlobImage = new QRCodeStyling({
281
+ jsdom: JSDOM, // this is required
282
+ nodeCanvas, // this is required
283
+ type: "svg",
284
+ ...options,
285
+ imageOptions: {
286
+ saveAsBlob: true,
287
+ crossOrigin: "anonymous",
288
+ margin: 20
289
+ }
290
+ });
291
+
292
+ qrCodeSvgWithBlobImage.getRawData("svg").then((buffer) => {
293
+ fs.writeFileSync("test_blob.svg", buffer);
294
+ });
191
295
 
296
+ ```
192
297
 
193
298
  ### License
194
299
 
195
- [MIT License](https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/LICENSE). Copyright (c) 2021 Denys Kozak
300
+ [MIT License](LICENSE). Copyright (c) 2019 Denys Kozak (original qr-code-styling) and qr-code-styling-node contributors.
196
301
 
@@ -0,0 +1,3 @@
1
+ import { DrawTypes } from "../types";
2
+ declare const _default: DrawTypes;
3
+ export default _default;
@@ -1,8 +1,7 @@
1
- import { RequiredOptions, Gradient } from "./QROptions";
2
- import { QRCode } from "../types";
3
- declare type FilterFunction = (i: number, j: number) => boolean;
1
+ import { RequiredOptions } from "./QROptions";
2
+ import { QRCode, Gradient, FilterFunction, Canvas } from "../types";
4
3
  export default class QRCanvas {
5
- _canvas: HTMLCanvasElement;
4
+ _canvas: Canvas;
6
5
  _options: RequiredOptions;
7
6
  _qr?: QRCode;
8
7
  _image?: HTMLImageElement;
@@ -10,7 +9,7 @@ export default class QRCanvas {
10
9
  get context(): CanvasRenderingContext2D | null;
11
10
  get width(): number;
12
11
  get height(): number;
13
- getCanvas(): HTMLCanvasElement;
12
+ getCanvas(): Canvas;
14
13
  clear(): void;
15
14
  drawQR(qr: QRCode): Promise<void>;
16
15
  drawBackground(): void;
@@ -32,4 +31,3 @@ export default class QRCanvas {
32
31
  size: number;
33
32
  }): CanvasGradient;
34
33
  }
35
- export {};
@@ -1,20 +1,20 @@
1
1
  import QRCanvas from "./QRCanvas";
2
- import { Options, RequiredOptions } from "./QROptions";
3
- import { Extension, QRCode } from "../types";
4
- declare type DownloadOptions = {
5
- name?: string;
6
- extension?: Extension;
7
- };
2
+ import QRSVG from "./QRSVG";
3
+ import { RequiredOptions } from "./QROptions";
4
+ import { Extension, QRCode, Options, DownloadOptions } from "../types";
8
5
  export default class QRCodeStyling {
9
6
  _options: RequiredOptions;
10
7
  _container?: HTMLElement;
11
8
  _canvas?: QRCanvas;
9
+ _svg?: QRSVG;
12
10
  _qr?: QRCode;
13
- _drawingPromise?: Promise<void>;
11
+ _canvasDrawingPromise?: Promise<void>;
12
+ _svgDrawingPromise?: Promise<void>;
14
13
  constructor(options?: Partial<Options>);
15
14
  static _clearContainer(container?: HTMLElement): void;
15
+ _getQRStylingElement(extension?: Extension): Promise<QRCanvas | QRSVG>;
16
16
  update(options?: Partial<Options>): void;
17
17
  append(container?: HTMLElement): void;
18
- download(downloadOptions?: Partial<DownloadOptions> | string): void;
18
+ getRawData(extension?: Extension): Promise<Blob | Buffer | null>;
19
+ download(downloadOptions?: Partial<DownloadOptions> | string): Promise<void>;
19
20
  }
20
- export {};
@@ -1,49 +1,6 @@
1
- import { DotType, GradientType, CornerSquareType, CornerDotType, TypeNumber, ErrorCorrectionLevel, Mode } from "../types";
2
- export declare type Gradient = {
3
- type: GradientType;
4
- rotation?: number;
5
- colorStops: {
6
- offset: number;
7
- color: string;
8
- }[];
9
- };
10
- export declare type Options = {
11
- width?: number;
12
- height?: number;
13
- data?: string;
14
- image?: string;
15
- qrOptions?: {
16
- typeNumber?: TypeNumber;
17
- mode?: Mode;
18
- errorCorrectionLevel?: ErrorCorrectionLevel;
19
- };
20
- imageOptions?: {
21
- hideBackgroundDots?: boolean;
22
- imageSize?: number;
23
- crossOrigin?: string;
24
- margin?: number;
25
- };
26
- dotsOptions?: {
27
- type?: DotType;
28
- color?: string;
29
- gradient?: Gradient;
30
- };
31
- cornersSquareOptions?: {
32
- type?: CornerSquareType;
33
- color?: string;
34
- gradient?: Gradient;
35
- };
36
- cornersDotOptions?: {
37
- type?: CornerDotType;
38
- color?: string;
39
- gradient?: Gradient;
40
- };
41
- backgroundOptions?: {
42
- color?: string;
43
- gradient?: Gradient;
44
- };
45
- };
1
+ import { DotType, Options, TypeNumber, ErrorCorrectionLevel, Mode, DrawType, Gradient } from "../types";
46
2
  export interface RequiredOptions extends Options {
3
+ type: DrawType;
47
4
  width: number;
48
5
  height: number;
49
6
  margin: number;
@@ -54,6 +11,7 @@ export interface RequiredOptions extends Options {
54
11
  errorCorrectionLevel: ErrorCorrectionLevel;
55
12
  };
56
13
  imageOptions: {
14
+ saveAsBlob: boolean;
57
15
  hideBackgroundDots: boolean;
58
16
  imageSize: number;
59
17
  crossOrigin?: string;
@@ -0,0 +1,42 @@
1
+ import { RequiredOptions } from "./QROptions";
2
+ import { QRCode, FilterFunction, Gradient, Window, Canvas } from "../types";
3
+ export default class QRSVG {
4
+ _canvas?: Canvas;
5
+ _window: Window;
6
+ _element: SVGElement;
7
+ _defs: SVGElement;
8
+ _dotsClipPath?: SVGElement;
9
+ _cornersSquareClipPath?: SVGElement;
10
+ _cornersDotClipPath?: SVGElement;
11
+ _options: RequiredOptions;
12
+ _qr?: QRCode;
13
+ _image?: HTMLImageElement;
14
+ _imageUri?: string;
15
+ constructor(options: RequiredOptions);
16
+ get width(): number;
17
+ get height(): number;
18
+ getElement(): SVGElement;
19
+ clear(): void;
20
+ drawQR(qr: QRCode): Promise<void>;
21
+ drawBackground(): void;
22
+ drawDots(filter?: FilterFunction): void;
23
+ drawCorners(): void;
24
+ imageToBlob(): void;
25
+ loadImage(): Promise<void>;
26
+ drawImage({ width, height, count, dotSize }: {
27
+ width: number;
28
+ height: number;
29
+ count: number;
30
+ dotSize: number;
31
+ }): void;
32
+ _createColor({ options, color, additionalRotation, x, y, height, width, name }: {
33
+ options?: Gradient;
34
+ color?: string;
35
+ additionalRotation: number;
36
+ x: number;
37
+ y: number;
38
+ height: number;
39
+ width: number;
40
+ name: string;
41
+ }): void;
42
+ }
@@ -0,0 +1,15 @@
1
+ import { CornerDotType, RotateFigureArgsCanvas, BasicFigureDrawArgsCanvas, DrawArgsCanvas } from "../../../types";
2
+ export default class QRCornerDot {
3
+ _context: CanvasRenderingContext2D;
4
+ _type: CornerDotType;
5
+ constructor({ context, type }: {
6
+ context: CanvasRenderingContext2D;
7
+ type: CornerDotType;
8
+ });
9
+ draw(x: number, y: number, size: number, rotation: number): void;
10
+ _rotateFigure({ x, y, size, context, rotation, draw }: RotateFigureArgsCanvas): void;
11
+ _basicDot(args: BasicFigureDrawArgsCanvas): void;
12
+ _basicSquare(args: BasicFigureDrawArgsCanvas): void;
13
+ _drawDot({ x, y, size, context, rotation }: DrawArgsCanvas): void;
14
+ _drawSquare({ x, y, size, context, rotation }: DrawArgsCanvas): void;
15
+ }
@@ -0,0 +1,18 @@
1
+ import { CornerDotType, RotateFigureArgs, BasicFigureDrawArgs, DrawArgs, Window } from "../../../types";
2
+ export default class QRCornerDot {
3
+ _element?: SVGElement;
4
+ _svg: SVGElement;
5
+ _type: CornerDotType;
6
+ _window: Window;
7
+ constructor({ svg, type, window }: {
8
+ svg: SVGElement;
9
+ type: CornerDotType;
10
+ window: Window;
11
+ });
12
+ draw(x: number, y: number, size: number, rotation: number): void;
13
+ _rotateFigure({ x, y, size, rotation, draw }: RotateFigureArgs): void;
14
+ _basicDot(args: BasicFigureDrawArgs): void;
15
+ _basicSquare(args: BasicFigureDrawArgs): void;
16
+ _drawDot({ x, y, size, rotation }: DrawArgs): void;
17
+ _drawSquare({ x, y, size, rotation }: DrawArgs): void;
18
+ }
@@ -0,0 +1,17 @@
1
+ import { CornerSquareType, RotateFigureArgsCanvas, BasicFigureDrawArgsCanvas, DrawArgsCanvas } from "../../../types";
2
+ export default class QRCornerSquare {
3
+ _context: CanvasRenderingContext2D;
4
+ _type: CornerSquareType;
5
+ constructor({ context, type }: {
6
+ context: CanvasRenderingContext2D;
7
+ type: CornerSquareType;
8
+ });
9
+ draw(x: number, y: number, size: number, rotation: number): void;
10
+ _rotateFigure({ x, y, size, context, rotation, draw }: RotateFigureArgsCanvas): void;
11
+ _basicDot(args: BasicFigureDrawArgsCanvas): void;
12
+ _basicSquare(args: BasicFigureDrawArgsCanvas): void;
13
+ _basicExtraRounded(args: BasicFigureDrawArgsCanvas): void;
14
+ _drawDot({ x, y, size, context, rotation }: DrawArgsCanvas): void;
15
+ _drawSquare({ x, y, size, context, rotation }: DrawArgsCanvas): void;
16
+ _drawExtraRounded({ x, y, size, context, rotation }: DrawArgsCanvas): void;
17
+ }
@@ -0,0 +1,20 @@
1
+ import { CornerSquareType, DrawArgs, BasicFigureDrawArgs, RotateFigureArgs, Window } from "../../../types";
2
+ export default class QRCornerSquare {
3
+ _element?: SVGElement;
4
+ _svg: SVGElement;
5
+ _type: CornerSquareType;
6
+ _window: Window;
7
+ constructor({ svg, type, window }: {
8
+ svg: SVGElement;
9
+ type: CornerSquareType;
10
+ window: Window;
11
+ });
12
+ draw(x: number, y: number, size: number, rotation: number): void;
13
+ _rotateFigure({ x, y, size, rotation, draw }: RotateFigureArgs): void;
14
+ _basicDot(args: BasicFigureDrawArgs): void;
15
+ _basicSquare(args: BasicFigureDrawArgs): void;
16
+ _basicExtraRounded(args: BasicFigureDrawArgs): void;
17
+ _drawDot({ x, y, size, rotation }: DrawArgs): void;
18
+ _drawSquare({ x, y, size, rotation }: DrawArgs): void;
19
+ _drawExtraRounded({ x, y, size, rotation }: DrawArgs): void;
20
+ }
@@ -0,0 +1,24 @@
1
+ import { DotType, GetNeighbor, RotateFigureArgsCanvas, BasicFigureDrawArgsCanvas, DrawArgsCanvas } from "../../../types";
2
+ export default class QRDot {
3
+ _context: CanvasRenderingContext2D;
4
+ _type: DotType;
5
+ constructor({ context, type }: {
6
+ context: CanvasRenderingContext2D;
7
+ type: DotType;
8
+ });
9
+ draw(x: number, y: number, size: number, getNeighbor: GetNeighbor): void;
10
+ _rotateFigure({ x, y, size, context, rotation, draw }: RotateFigureArgsCanvas): void;
11
+ _basicDot(args: BasicFigureDrawArgsCanvas): void;
12
+ _basicSquare(args: BasicFigureDrawArgsCanvas): void;
13
+ _basicSideRounded(args: BasicFigureDrawArgsCanvas): void;
14
+ _basicCornerRounded(args: BasicFigureDrawArgsCanvas): void;
15
+ _basicCornerExtraRounded(args: BasicFigureDrawArgsCanvas): void;
16
+ _basicCornersRounded(args: BasicFigureDrawArgsCanvas): void;
17
+ _basicCornersExtraRounded(args: BasicFigureDrawArgsCanvas): void;
18
+ _drawDot({ x, y, size, context }: DrawArgsCanvas): void;
19
+ _drawSquare({ x, y, size, context }: DrawArgsCanvas): void;
20
+ _drawRounded({ x, y, size, context, getNeighbor }: DrawArgsCanvas): void;
21
+ _drawExtraRounded({ x, y, size, context, getNeighbor }: DrawArgsCanvas): void;
22
+ _drawClassy({ x, y, size, context, getNeighbor }: DrawArgsCanvas): void;
23
+ _drawClassyRounded({ x, y, size, context, getNeighbor }: DrawArgsCanvas): void;
24
+ }
@@ -0,0 +1,26 @@
1
+ import { DotType, GetNeighbor, DrawArgs, BasicFigureDrawArgs, RotateFigureArgs, Window } from "../../../types";
2
+ export default class QRDot {
3
+ _element?: SVGElement;
4
+ _svg: SVGElement;
5
+ _type: DotType;
6
+ _window: Window;
7
+ constructor({ svg, type, window }: {
8
+ svg: SVGElement;
9
+ type: DotType;
10
+ window: Window;
11
+ });
12
+ draw(x: number, y: number, size: number, getNeighbor: GetNeighbor): void;
13
+ _rotateFigure({ x, y, size, rotation, draw }: RotateFigureArgs): void;
14
+ _basicDot(args: BasicFigureDrawArgs): void;
15
+ _basicSquare(args: BasicFigureDrawArgs): void;
16
+ _basicSideRounded(args: BasicFigureDrawArgs): void;
17
+ _basicCornerRounded(args: BasicFigureDrawArgs): void;
18
+ _basicCornerExtraRounded(args: BasicFigureDrawArgs): void;
19
+ _basicCornersRounded(args: BasicFigureDrawArgs): void;
20
+ _drawDot({ x, y, size }: DrawArgs): void;
21
+ _drawSquare({ x, y, size }: DrawArgs): void;
22
+ _drawRounded({ x, y, size, getNeighbor }: DrawArgs): void;
23
+ _drawExtraRounded({ x, y, size, getNeighbor }: DrawArgs): void;
24
+ _drawClassy({ x, y, size, getNeighbor }: DrawArgs): void;
25
+ _drawClassyRounded({ x, y, size, getNeighbor }: DrawArgs): void;
26
+ }
package/lib/index.d.ts CHANGED
@@ -6,5 +6,7 @@ import errorCorrectionLevels from "./constants/errorCorrectionLevels";
6
6
  import errorCorrectionPercents from "./constants/errorCorrectionPercents";
7
7
  import modes from "./constants/modes";
8
8
  import qrTypes from "./constants/qrTypes";
9
- export { dotTypes, cornerDotTypes, cornerSquareTypes, errorCorrectionLevels, errorCorrectionPercents, modes, qrTypes };
9
+ import drawTypes from "./constants/drawTypes";
10
+ export * from "./types";
11
+ export { dotTypes, cornerDotTypes, cornerSquareTypes, errorCorrectionLevels, errorCorrectionPercents, modes, qrTypes, drawTypes };
10
12
  export default QRCodeStyling;