@vkontakte/vk-qr 3.0.0 → 3.1.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
@@ -32,7 +32,18 @@ import * as vkQr from '@vkontakte/vk-qr';
32
32
  // Returns SVG code of generated 256x256 QR code with VK logo
33
33
  const qrSvg = vkQr.createQR('Text to encode', {
34
34
  qrSize: 256,
35
- isShowLogo: true
35
+ isShowLogo: true,
36
+ });
37
+ ```
38
+
39
+ Customize the background frame thickness and corner radius in pixels:
40
+
41
+ ```js
42
+ const qrSvg = vkQr.createQR('Text to encode', {
43
+ qrSize: 256,
44
+ isShowBackground: true,
45
+ backgroundPadding: 12,
46
+ backgroundRadius: 16,
36
47
  });
37
48
  ```
38
49
 
@@ -51,7 +62,6 @@ generatedSvgCode = vkQr.createQR(text[, qrOptions]);
51
62
 
52
63
  - `options` _optional_
53
64
  An options object containing any custom settings that you want to apply to the generated QR code. The possible options are:
54
-
55
65
  - `qrSize`: Size of QR code.
56
66
  Default is 128
57
67
 
@@ -64,6 +74,10 @@ generatedSvgCode = vkQr.createQR(text[, qrOptions]);
64
74
 
65
75
  - `backgroundColor`: QR code background HEX color. Works if `isShowBackground` is enabled. Default is "#ffffff"
66
76
 
77
+ - `backgroundPadding`: Background frame thickness (padding on each side) in output pixels. Works if `isShowBackground` is enabled. Default is 20
78
+
79
+ - `backgroundRadius`: Background corner radius in output pixels. Works if `isShowBackground` is enabled. Default is 36
80
+
67
81
  - `foregroundColor`: QR code HEX color
68
82
 
69
83
  - `logoColor`: Color of logo. Default is "#4680c2"
@@ -74,6 +88,11 @@ generatedSvgCode = vkQr.createQR(text[, qrOptions]);
74
88
 
75
89
  - `ecc`: ECC level in range [0-3] (0 - low, 3 - high)
76
90
 
91
+ `backgroundPadding` and `backgroundRadius` accept finite, non-negative numbers, including 0.
92
+ Invalid values use the defaults. Both are limited to half of `qrSize`.
93
+ The outer SVG size stays `qrSize` × `qrSize`; padding reduces the space available to the QR code
94
+ equally on all sides. If padding fills the entire image, only the background is rendered.
95
+
77
96
  ### Return value
78
97
 
79
98
  A string with SVG code.
@@ -0,0 +1,10 @@
1
+ /** SVG units per QR module. */
2
+ export declare const TILE_SIZE = 100;
3
+ export declare const FINDER_PATTERN_SIZE = 7;
4
+ export declare const SMALL_QR_SIZE = 25;
5
+ export declare const MODULE_CORNER_RADIUS = 35;
6
+ export declare const FINDER_CORNER_RADIUS = 67;
7
+ /** Default background dimensions in output pixels. */
8
+ export declare const BACKGROUND_PADDING = 20;
9
+ export declare const BACKGROUND_RADIUS = 36;
10
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,eAAO,MAAM,SAAS,MAAM,CAAC;AAC7B,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,sDAAsD;AACtD,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,iBAAiB,KAAK,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** A connected group of modules stored in its smallest bounding box. */
2
+ export interface Figure {
3
+ x: number;
4
+ y: number;
5
+ pixels: boolean[][];
6
+ }
7
+ export declare function isFinderPattern(figure: Figure, size: number): boolean;
8
+ export declare function extractFigures(image: boolean[][]): Figure[];
9
+ //# sourceMappingURL=figures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figures.d.ts","sourceRoot":"","sources":["../src/figures.ts"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;CACrB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAoBrE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,MAAM,EAAE,CA0E3D"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { QrOptions } from './types.ts';
1
+ import type { QrOptions } from './types.js';
2
2
  /**
3
3
  * Generates SVG QR code by a text
4
4
  * @param text String to encode
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAqB,MAAM,YAAY,CAAC;AAc/D;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;AAEpE;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,SAAS,GAClB,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAqB,MAAM,YAAY,CAAC;AAe/D;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;AAEpE;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,SAAS,GAClB,MAAM,CAAC"}