qr-code-styling-node 1.11.0 → 1.12.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 CHANGED
@@ -118,6 +118,25 @@ fontSize |number |7% of the size |In p
118
118
  fontFamily|string |`'Helvetica, Arial, sans-serif'` |
119
119
  fontWeight|string or number |`'bold'` |
120
120
 
121
+ ### Connected and decorative dots
122
+
123
+ <img src="https://raw.githubusercontent.com/ducminhquan/qr-code-styling/master/src/assets/dot_examples.png" width="720" />
124
+
125
+ `fluid` joins neighbouring dots into soft strokes, `wave` chains each row into soft beads, `blob` gives every
126
+ module its own hand-drawn corners, and `circuit` draws round pads with thin traces to their neighbours. With
127
+ these four, finders and alignment patterns are drawn solid and rounded (unless you set a corner type), so the
128
+ code keeps scanning.
129
+
130
+ ### Smaller SVG files
131
+
132
+ `svgOptions: { mergePaths: true }` draws all dots as one `<path>` instead of one element per module (and does
133
+ the same for finders drawn with dots). The picture is the same; files are 15-50% smaller and render faster,
134
+ which helps when a page shows many codes.
135
+
136
+ ```js
137
+ new QRCodeStyling({ type: "svg", data: "https://example.com", svgOptions: { mergePaths: true } });
138
+ ```
139
+
121
140
  ### QR art
122
141
 
123
142
  <img src="https://raw.githubusercontent.com/ducminhquan/qr-code-styling/master/src/assets/art_examples.png" width="720" />
@@ -248,6 +267,7 @@ width |number |`300` |Size of canvas
248
267
  height |number |`300` |Size of canvas
249
268
  type |string (`'canvas' 'svg'`)|`canvas` |The type of the element that will be rendered
250
269
  shape |string (`'square' 'circle'`)|`'square'` |`'circle'` draws a round code with decorative dots around the real one
270
+ svgOptions |object `{ mergePaths }` | |SVG only: `mergePaths: true` draws all dots as one path (smaller files)
251
271
  data |string | |The date will be encoded to the QR code
252
272
  image |string | |The image will be copied to the center of the QR code
253
273
  margin |number |`0` |Margin around canvas
@@ -292,7 +312,7 @@ Property|Type
292
312
  --------|------------------------------------------------------------------------------|-------------|-------------------
293
313
  color |string |`'#000'` |Color of QR dots
294
314
  gradient|object | |Gradient of QR dots
295
- type |string (`'rounded' 'dots' 'classy' 'classy-rounded' 'square' 'extra-rounded' 'diamond' 'small-square' 'vertical-lines' 'horizontal-lines' 'fluid'`)|`'square'` |Style of QR dots. With `diamond`, `small-square` and the lines, corners and alignment patterns stay solid unless you set a corner type. `fluid` joins neighbouring dots into soft strokes, with solid rounded corners
315
+ type |string (`'rounded' 'dots' 'classy' 'classy-rounded' 'square' 'extra-rounded' 'diamond' 'small-square' 'vertical-lines' 'horizontal-lines' 'fluid' 'wave' 'blob' 'circuit'`)|`'square'` |Style of QR dots. With `diamond`, `small-square` and the lines, corners and alignment patterns stay solid unless you set a corner type. With `fluid`, `wave`, `blob` and `circuit` they are solid and rounded
296
316
 
297
317
  `options.backgroundOptions` structure
298
318
 
@@ -30,6 +30,8 @@ export default class QRSVG {
30
30
  drawBackground(): void;
31
31
  drawDots(filter?: FilterFunction): void;
32
32
  drawCorners(): void;
33
+ /** Finder modules drawn with the dots' own figure, as one path (svgOptions.mergePaths). */
34
+ _drawMergedMask(mask: number[][], x: number, y: number, dotSize: number, clipPath?: SVGElement): void;
33
35
  _drawArtRects(rects: ArtRect[]): void;
34
36
  _appendImage(href: string, x: number, y: number): void;
35
37
  imageToBlob(): void;
@@ -48,3 +48,22 @@ export declare const fluid: (x: number, y: number, size: number, neighbors: {
48
48
  top: boolean;
49
49
  bottom: boolean;
50
50
  }) => Shape;
51
+ type Neighbors = {
52
+ left: boolean;
53
+ right: boolean;
54
+ top: boolean;
55
+ bottom: boolean;
56
+ };
57
+ /**
58
+ * "wave" dot: modules in a row flow into each other as a chain of soft beads; a run's ends are round.
59
+ * Only horizontal neighbours connect.
60
+ */
61
+ export declare const wave: (x: number, y: number, size: number, { left, right }: Neighbors) => Shape;
62
+ /** "blob" dot: a hand-drawn looking rounded square; each module gets its own corner radii and size. */
63
+ export declare const blob: (x: number, y: number, size: number) => Shape;
64
+ /**
65
+ * "circuit" dot: a round pad with thin traces to its dark neighbours, like a printed circuit board.
66
+ * One outline per module, so traces never overlap the pad (the renderers fill with even-odd).
67
+ */
68
+ export declare const circuit: (x: number, y: number, size: number, neighbors: Neighbors) => Shape;
69
+ export {};