@vkontakte/vk-qr 2.0.12 → 2.1.1
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 +2 -2
- package/dist/cjs/index.js +7 -6
- package/dist/es/index.js +7 -6
- package/dist/types/svg.d.ts +1 -0
- package/dist/types/types.d.ts +4 -0
- package/dist/umd/qrCodeGenerator.js +7 -6
- package/dist/umd/qrCodeGenerator.min.js +1 -1
- package/package.json +8 -5
- package/src/index.ts +3 -2
- package/src/svg.ts +48 -59
- package/src/types.ts +5 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
[<img width="150" height="150" src="https://
|
|
3
|
+
[<img width="150" height="150" src="https://user-images.githubusercontent.com/45998835/154472026-cae3934d-8013-4898-b7f0-cef7476a6424.png">](https://github.com/VKCOM/vk-qr)
|
|
4
4
|
|
|
5
5
|
[![npm][npm-shield]][npm-url] [![NPM][npm-downloads-shield]][npm-url] [](https://travis-ci.org/VKCOM/vk-qr)
|
|
6
6
|
|
|
@@ -71,7 +71,7 @@ generatedSvgCode = vkQr.createQR(text[, qrOptions]);
|
|
|
71
71
|
- `logoData`: Reference to logo as a reference IRI
|
|
72
72
|
|
|
73
73
|
- `suffix`: SVG elements id postfix
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
- `ecc`: ECC level in range [0-3] (0 - low, 3 - high)
|
|
76
76
|
|
|
77
77
|
### Return value
|
package/dist/cjs/index.js
CHANGED
|
@@ -174,16 +174,16 @@ var convertSegmentsToSvgString = function (qrCode, options) {
|
|
|
174
174
|
scale = 'scale(0.85)';
|
|
175
175
|
position += 50;
|
|
176
176
|
}
|
|
177
|
-
var pointPosition = (qrCode.size - QR_BORDER) *
|
|
177
|
+
var pointPosition = (qrCode.size - QR_BORDER) * options.incTileSize;
|
|
178
178
|
parts.push("<use fill-rule=\"evenodd\" transform=\"translate(0,0)\" xlink:href=\"#point-" + options.suffix + "\"/>");
|
|
179
179
|
parts.push("<use fill-rule=\"evenodd\" transform=\"translate(" + pointPosition + ",0)\" xlink:href=\"#point-" + options.suffix + "\"/>");
|
|
180
180
|
parts.push("<use fill-rule=\"evenodd\" transform=\"translate(0," + pointPosition + ")\" xlink:href=\"#point-" + options.suffix + "\"/>");
|
|
181
181
|
if (options.isShowLogo) {
|
|
182
182
|
if (!options.logoData) {
|
|
183
|
-
parts.push("\n <use style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"
|
|
183
|
+
parts.push("\n <use style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n fill=\"none\"\n fill-rule=\"evenodd\"\n transform=\"translate(" + position + "," + position + ") " + scale + "\" xlink:href=\"#vk_logo-" + options.suffix + "\"\n />\n ");
|
|
184
184
|
}
|
|
185
185
|
else {
|
|
186
|
-
parts.push("\n <image
|
|
186
|
+
parts.push("\n <image\n preserveAspectRatio=\"xMidYMid slice\" clip-path=\"url(#logo-mask-" + options.suffix + ")\"\n style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n transform=\"translate(" + position + "," + position + ") " + scale + "\"\n xlink:href=\"" + options.logoData + "\"\n />\n ");
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
var backgroundSize = 99 * qrCode.size;
|
|
@@ -193,13 +193,13 @@ var convertSegmentsToSvgString = function (qrCode, options) {
|
|
|
193
193
|
var qrScale = (options.qrSize - 20 * 2) / options.qrSize; // 0.756972112
|
|
194
194
|
var padding = (backgroundSize / options.qrSize) * 21;
|
|
195
195
|
var radius = Math.ceil(backgroundSize / (options.qrSize / 36)); // 7.11111111 = 256px/36px radius
|
|
196
|
-
qrBackground = "\n <rect
|
|
196
|
+
qrBackground = "\n <rect\n x=\"0\"\n width=\"" + backgroundSize + "\"\n height=\"" + backgroundSize + "\"\n rx=\"" + radius + "\"\n fill=\"" + options.backgroundColor + "\"\n />";
|
|
197
197
|
qrTransform = "translate(" + padding + ", " + padding + ") scale(" + qrScale + ")";
|
|
198
198
|
}
|
|
199
199
|
// eslint-disable-next-line
|
|
200
200
|
var oneSide = "M0,0 L66,0 C" + _84_7 + ",-3.44940413e-15 " + _100 + ",15.2223185 " + _100 + ",34 L" + _100 + ",66 C" + _100 + "," + _84_7 + " " + _84_7 + "," + _100 + " 66," + _100 + " L0," + _100 + " L0,0 Z";
|
|
201
201
|
var twoSides = "M0,0 L" + _100 + ",0 L" + _100 + ",66 C" + _100 + "," + _84_7 + " " + _84_7 + "," + _100 + " 66," + _100 + " L0," + _100 + " L0,0 Z";
|
|
202
|
-
return "\n <svg
|
|
202
|
+
return "\n <svg\n version=\"1.1\"\n viewBox=\"0 0 " + backgroundSize + " " + backgroundSize + "\"\n width=\"" + options.qrSize + "px\"\n height=\"" + options.qrSize + "px\"\n " + (options.className ? "class=\"" + options.className + "\"" : '') + "\n xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <defs>\n <rect id=\"rect-" + options.suffix + "\" width=\"100\" height=\"100\" fill=\"" + options.foregroundColor + "\"/>\n <path\n id=\"empty-" + options.suffix + "\"\n d=\"M0," + _28_6 + "v" + _42_9 + "C0," + _87_3 + "," + _12_8 + "," + _100 + "," + _28_6 + "," + _100 + "h" + _42_9 + "c" + _15_9 + ",0," + _28_6 + "-" + _12_8 + "," + _28_6 + "-" + _28_6 + "V" + _28_6 + "C" + _100 + "," + _12_7 + "," + _87_2 + ",0," + _71_4 + ",0H" + _28_6 + " C" + _12_8 + ",0,0," + _12_8 + ",0," + _28_6 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path id=\"b-" + options.suffix + "\" d=\"" + oneSide + "\" transform=\"rotate(-90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"r-" + options.suffix + "\" d=\"" + oneSide + "\" transform=\"rotate(-180 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"l-" + options.suffix + "\" d=\"" + oneSide + "\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"t-" + options.suffix + "\" d=\"" + oneSide + "\" transform=\"rotate(90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"l-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(-90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"lt-" + options.suffix + "\" d=\"" + twoSides + "\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"lb-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(-90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"rb-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(-180 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"rt-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path\n id=\"n_lt-" + options.suffix + "\"\n d=\"M" + _30_5 + "," + _2 + "V0H0v" + _30_5 + "h" + _2 + "C" + _2 + "," + _14_7 + "," + _14_8 + "," + _2 + "," + _30_5 + "," + _2 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path\n id=\"n_lb-" + options.suffix + "\"\n d=\"M" + _2 + "," + _69_5 + "H0V" + _100 + "h" + _30_5 + "v-" + _2 + "C" + _14_7 + "," + _98 + "," + _2 + "," + _85_2 + "," + _2 + "," + _69_5 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path\n id=\"n_rt-" + options.suffix + "\"\n d=\"M" + _98 + "," + _30_5 + "h" + _2 + "V0H" + _69_5 + "v" + _2 + "C" + _85_3 + "," + _2 + "," + _98 + "," + _14_8 + "," + _98 + "," + _30_5 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path id=\"n_rb-" + options.suffix + "\"\n d=\"M" + _69_5 + "," + _98 + "v" + _2 + "H" + _100 + "V" + _69_5 + "h-" + _2 + "C" + _98 + "," + _85_3 + "," + _85_2 + "," + _98 + "," + _69_5 + "," + _98 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path\n id=\"point-" + options.suffix + "\"\n fill=\"" + options.foregroundColor + "\"\n d=\"M600.001786,457.329333 L600.001786,242.658167 C600.001786,147.372368 587.039517,124.122784 581.464617,118.535383 C575.877216,112.960483 552.627632,99.9982143 457.329333,99.9982143 L242.670667,99.9982143 C147.372368,99.9982143 124.122784,112.960483 118.547883,118.535383 C112.972983,124.122784 99.9982143,147.372368 99.9982143,242.658167 L99.9982143,457.329333 C99.9982143,552.627632 112.972983,575.877216 118.547883,581.464617 C124.122784,587.027017 147.372368,600.001786 242.670667,600.001786 L457.329333,600.001786 C552.627632,600.001786 575.877216,587.027017 581.464617,581.464617 C587.039517,575.877216 600.001786,552.627632 600.001786,457.329333 Z M457.329333,0 C653.338333,0 700,46.6616668 700,242.658167 C700,438.667167 700,261.332833 700,457.329333 C700,653.338333 653.338333,700 457.329333,700 C261.332833,700 438.667167,700 242.670667,700 C46.6616668,700 0,653.338333 0,457.329333 C0,261.332833 0,352.118712 0,242.658167 C0,46.6616668 46.6616668,0 242.670667,0 C438.667167,0 261.332833,0 457.329333,0 Z M395.996667,200 C480.004166,200 500,220.008332 500,303.990835 C500,387.998334 500,312.001666 500,395.996667 C500,479.991668 480.004166,500 395.996667,500 C312.001666,500 387.998334,500 304.003333,500 C220.008332,500 200,479.991668 200,395.996667 C200,312.001666 200,350.906061 200,303.990835 C200,220.008332 220.008332,200 304.003333,200 C387.998334,200 312.001666,200 395.996667,200 Z\"\n />\n <g id=\"vk_logo-" + options.suffix + "\">\n <path\n fill=\"" + options.logoColor + "\"\n d=\"M83.3334 363.333C83.3334 231.34 83.3334 165.343 124.338 124.338C165.343 83.3333 231.34 83.3333 363.333 83.3333H386.667C518.66 83.3333 584.657 83.3333 625.662 124.338C666.667 165.343 666.667 231.34 666.667 363.333V386.667C666.667 518.66 666.667 584.657 625.662 625.662C584.657 666.667 518.66 666.667 386.667 666.667H363.333C231.34 666.667 165.343 666.667 124.338 625.662C83.3334 584.657 83.3334 518.66 83.3334 386.667V363.333Z\"\n />\n <path\n fill=\"#FFF\"\n d=\"M394.907 508.681C263.293 508.681 183.442 417.365 180.313 265.625H246.972C249.05 377.09 299.763 424.323 338.638 434.036V265.625H402.519V361.82C440.016 357.664 479.264 313.909 492.456 265.625H555.333C545.27 325 502.543 368.754 472.353 386.803C502.566 401.395 551.177 439.593 569.926 508.681H500.815C486.222 462.498 450.476 426.728 402.542 421.872V508.681H394.907Z\"\n />\n </g>\n <clipPath id=\"logo-mask-" + options.suffix + "\">\n <rect x=\"0\" y=\"0\" width=\"750\" height=\"750\" />\n </clipPath>\n </defs>\n\n " + qrBackground + "\n\n <g transform=\"" + qrTransform + "\">\n " + parts.join('\n') + "\n </g>\n </svg>";
|
|
203
203
|
};
|
|
204
204
|
|
|
205
205
|
/*
|
|
@@ -1137,7 +1137,7 @@ var BACKGROUND_COLOR_DEFAULT = '#ffffff';
|
|
|
1137
1137
|
/** Default foreground color */
|
|
1138
1138
|
var FOREGROUND_COLOR_DEFAULT = '#000000';
|
|
1139
1139
|
/** Default logo color */
|
|
1140
|
-
var LOGO_COLOR_DEFAULT = '#
|
|
1140
|
+
var LOGO_COLOR_DEFAULT = '#07f';
|
|
1141
1141
|
/**
|
|
1142
1142
|
* Implementation
|
|
1143
1143
|
*/
|
|
@@ -1170,6 +1170,7 @@ function createQR(text, qrSizeOrOptions, classNameLegacy, legacyOptions) {
|
|
|
1170
1170
|
suffix: options.suffix ? options.suffix.toString() : '0',
|
|
1171
1171
|
logoData: typeof options.logoData === 'string' ? options.logoData : null,
|
|
1172
1172
|
ecc: (typeof options.ecc === 'number' && eccLevels[options.ecc] ? options.ecc : 3),
|
|
1173
|
+
incTileSize: typeof options.incTileSize === 'number' ? options.incTileSize : INC_TILE_SIZE,
|
|
1173
1174
|
};
|
|
1174
1175
|
// Code generation
|
|
1175
1176
|
var segments = QrSegment.makeSegments(text);
|
package/dist/es/index.js
CHANGED
|
@@ -172,16 +172,16 @@ var convertSegmentsToSvgString = function (qrCode, options) {
|
|
|
172
172
|
scale = 'scale(0.85)';
|
|
173
173
|
position += 50;
|
|
174
174
|
}
|
|
175
|
-
var pointPosition = (qrCode.size - QR_BORDER) *
|
|
175
|
+
var pointPosition = (qrCode.size - QR_BORDER) * options.incTileSize;
|
|
176
176
|
parts.push("<use fill-rule=\"evenodd\" transform=\"translate(0,0)\" xlink:href=\"#point-" + options.suffix + "\"/>");
|
|
177
177
|
parts.push("<use fill-rule=\"evenodd\" transform=\"translate(" + pointPosition + ",0)\" xlink:href=\"#point-" + options.suffix + "\"/>");
|
|
178
178
|
parts.push("<use fill-rule=\"evenodd\" transform=\"translate(0," + pointPosition + ")\" xlink:href=\"#point-" + options.suffix + "\"/>");
|
|
179
179
|
if (options.isShowLogo) {
|
|
180
180
|
if (!options.logoData) {
|
|
181
|
-
parts.push("\n <use style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"
|
|
181
|
+
parts.push("\n <use style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n fill=\"none\"\n fill-rule=\"evenodd\"\n transform=\"translate(" + position + "," + position + ") " + scale + "\" xlink:href=\"#vk_logo-" + options.suffix + "\"\n />\n ");
|
|
182
182
|
}
|
|
183
183
|
else {
|
|
184
|
-
parts.push("\n <image
|
|
184
|
+
parts.push("\n <image\n preserveAspectRatio=\"xMidYMid slice\" clip-path=\"url(#logo-mask-" + options.suffix + ")\"\n style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n transform=\"translate(" + position + "," + position + ") " + scale + "\"\n xlink:href=\"" + options.logoData + "\"\n />\n ");
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
var backgroundSize = 99 * qrCode.size;
|
|
@@ -191,13 +191,13 @@ var convertSegmentsToSvgString = function (qrCode, options) {
|
|
|
191
191
|
var qrScale = (options.qrSize - 20 * 2) / options.qrSize; // 0.756972112
|
|
192
192
|
var padding = (backgroundSize / options.qrSize) * 21;
|
|
193
193
|
var radius = Math.ceil(backgroundSize / (options.qrSize / 36)); // 7.11111111 = 256px/36px radius
|
|
194
|
-
qrBackground = "\n <rect
|
|
194
|
+
qrBackground = "\n <rect\n x=\"0\"\n width=\"" + backgroundSize + "\"\n height=\"" + backgroundSize + "\"\n rx=\"" + radius + "\"\n fill=\"" + options.backgroundColor + "\"\n />";
|
|
195
195
|
qrTransform = "translate(" + padding + ", " + padding + ") scale(" + qrScale + ")";
|
|
196
196
|
}
|
|
197
197
|
// eslint-disable-next-line
|
|
198
198
|
var oneSide = "M0,0 L66,0 C" + _84_7 + ",-3.44940413e-15 " + _100 + ",15.2223185 " + _100 + ",34 L" + _100 + ",66 C" + _100 + "," + _84_7 + " " + _84_7 + "," + _100 + " 66," + _100 + " L0," + _100 + " L0,0 Z";
|
|
199
199
|
var twoSides = "M0,0 L" + _100 + ",0 L" + _100 + ",66 C" + _100 + "," + _84_7 + " " + _84_7 + "," + _100 + " 66," + _100 + " L0," + _100 + " L0,0 Z";
|
|
200
|
-
return "\n <svg
|
|
200
|
+
return "\n <svg\n version=\"1.1\"\n viewBox=\"0 0 " + backgroundSize + " " + backgroundSize + "\"\n width=\"" + options.qrSize + "px\"\n height=\"" + options.qrSize + "px\"\n " + (options.className ? "class=\"" + options.className + "\"" : '') + "\n xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <defs>\n <rect id=\"rect-" + options.suffix + "\" width=\"100\" height=\"100\" fill=\"" + options.foregroundColor + "\"/>\n <path\n id=\"empty-" + options.suffix + "\"\n d=\"M0," + _28_6 + "v" + _42_9 + "C0," + _87_3 + "," + _12_8 + "," + _100 + "," + _28_6 + "," + _100 + "h" + _42_9 + "c" + _15_9 + ",0," + _28_6 + "-" + _12_8 + "," + _28_6 + "-" + _28_6 + "V" + _28_6 + "C" + _100 + "," + _12_7 + "," + _87_2 + ",0," + _71_4 + ",0H" + _28_6 + " C" + _12_8 + ",0,0," + _12_8 + ",0," + _28_6 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path id=\"b-" + options.suffix + "\" d=\"" + oneSide + "\" transform=\"rotate(-90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"r-" + options.suffix + "\" d=\"" + oneSide + "\" transform=\"rotate(-180 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"l-" + options.suffix + "\" d=\"" + oneSide + "\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"t-" + options.suffix + "\" d=\"" + oneSide + "\" transform=\"rotate(90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"l-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(-90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"lt-" + options.suffix + "\" d=\"" + twoSides + "\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"lb-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(-90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"rb-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(-180 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"rt-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path\n id=\"n_lt-" + options.suffix + "\"\n d=\"M" + _30_5 + "," + _2 + "V0H0v" + _30_5 + "h" + _2 + "C" + _2 + "," + _14_7 + "," + _14_8 + "," + _2 + "," + _30_5 + "," + _2 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path\n id=\"n_lb-" + options.suffix + "\"\n d=\"M" + _2 + "," + _69_5 + "H0V" + _100 + "h" + _30_5 + "v-" + _2 + "C" + _14_7 + "," + _98 + "," + _2 + "," + _85_2 + "," + _2 + "," + _69_5 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path\n id=\"n_rt-" + options.suffix + "\"\n d=\"M" + _98 + "," + _30_5 + "h" + _2 + "V0H" + _69_5 + "v" + _2 + "C" + _85_3 + "," + _2 + "," + _98 + "," + _14_8 + "," + _98 + "," + _30_5 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path id=\"n_rb-" + options.suffix + "\"\n d=\"M" + _69_5 + "," + _98 + "v" + _2 + "H" + _100 + "V" + _69_5 + "h-" + _2 + "C" + _98 + "," + _85_3 + "," + _85_2 + "," + _98 + "," + _69_5 + "," + _98 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path\n id=\"point-" + options.suffix + "\"\n fill=\"" + options.foregroundColor + "\"\n d=\"M600.001786,457.329333 L600.001786,242.658167 C600.001786,147.372368 587.039517,124.122784 581.464617,118.535383 C575.877216,112.960483 552.627632,99.9982143 457.329333,99.9982143 L242.670667,99.9982143 C147.372368,99.9982143 124.122784,112.960483 118.547883,118.535383 C112.972983,124.122784 99.9982143,147.372368 99.9982143,242.658167 L99.9982143,457.329333 C99.9982143,552.627632 112.972983,575.877216 118.547883,581.464617 C124.122784,587.027017 147.372368,600.001786 242.670667,600.001786 L457.329333,600.001786 C552.627632,600.001786 575.877216,587.027017 581.464617,581.464617 C587.039517,575.877216 600.001786,552.627632 600.001786,457.329333 Z M457.329333,0 C653.338333,0 700,46.6616668 700,242.658167 C700,438.667167 700,261.332833 700,457.329333 C700,653.338333 653.338333,700 457.329333,700 C261.332833,700 438.667167,700 242.670667,700 C46.6616668,700 0,653.338333 0,457.329333 C0,261.332833 0,352.118712 0,242.658167 C0,46.6616668 46.6616668,0 242.670667,0 C438.667167,0 261.332833,0 457.329333,0 Z M395.996667,200 C480.004166,200 500,220.008332 500,303.990835 C500,387.998334 500,312.001666 500,395.996667 C500,479.991668 480.004166,500 395.996667,500 C312.001666,500 387.998334,500 304.003333,500 C220.008332,500 200,479.991668 200,395.996667 C200,312.001666 200,350.906061 200,303.990835 C200,220.008332 220.008332,200 304.003333,200 C387.998334,200 312.001666,200 395.996667,200 Z\"\n />\n <g id=\"vk_logo-" + options.suffix + "\">\n <path\n fill=\"" + options.logoColor + "\"\n d=\"M83.3334 363.333C83.3334 231.34 83.3334 165.343 124.338 124.338C165.343 83.3333 231.34 83.3333 363.333 83.3333H386.667C518.66 83.3333 584.657 83.3333 625.662 124.338C666.667 165.343 666.667 231.34 666.667 363.333V386.667C666.667 518.66 666.667 584.657 625.662 625.662C584.657 666.667 518.66 666.667 386.667 666.667H363.333C231.34 666.667 165.343 666.667 124.338 625.662C83.3334 584.657 83.3334 518.66 83.3334 386.667V363.333Z\"\n />\n <path\n fill=\"#FFF\"\n d=\"M394.907 508.681C263.293 508.681 183.442 417.365 180.313 265.625H246.972C249.05 377.09 299.763 424.323 338.638 434.036V265.625H402.519V361.82C440.016 357.664 479.264 313.909 492.456 265.625H555.333C545.27 325 502.543 368.754 472.353 386.803C502.566 401.395 551.177 439.593 569.926 508.681H500.815C486.222 462.498 450.476 426.728 402.542 421.872V508.681H394.907Z\"\n />\n </g>\n <clipPath id=\"logo-mask-" + options.suffix + "\">\n <rect x=\"0\" y=\"0\" width=\"750\" height=\"750\" />\n </clipPath>\n </defs>\n\n " + qrBackground + "\n\n <g transform=\"" + qrTransform + "\">\n " + parts.join('\n') + "\n </g>\n </svg>";
|
|
201
201
|
};
|
|
202
202
|
|
|
203
203
|
/*
|
|
@@ -1135,7 +1135,7 @@ var BACKGROUND_COLOR_DEFAULT = '#ffffff';
|
|
|
1135
1135
|
/** Default foreground color */
|
|
1136
1136
|
var FOREGROUND_COLOR_DEFAULT = '#000000';
|
|
1137
1137
|
/** Default logo color */
|
|
1138
|
-
var LOGO_COLOR_DEFAULT = '#
|
|
1138
|
+
var LOGO_COLOR_DEFAULT = '#07f';
|
|
1139
1139
|
/**
|
|
1140
1140
|
* Implementation
|
|
1141
1141
|
*/
|
|
@@ -1168,6 +1168,7 @@ function createQR(text, qrSizeOrOptions, classNameLegacy, legacyOptions) {
|
|
|
1168
1168
|
suffix: options.suffix ? options.suffix.toString() : '0',
|
|
1169
1169
|
logoData: typeof options.logoData === 'string' ? options.logoData : null,
|
|
1170
1170
|
ecc: (typeof options.ecc === 'number' && eccLevels[options.ecc] ? options.ecc : 3),
|
|
1171
|
+
incTileSize: typeof options.incTileSize === 'number' ? options.incTileSize : INC_TILE_SIZE,
|
|
1171
1172
|
};
|
|
1172
1173
|
// Code generation
|
|
1173
1174
|
var segments = QrSegment.makeSegments(text);
|
package/dist/types/svg.d.ts
CHANGED
package/dist/types/types.d.ts
CHANGED
|
@@ -178,16 +178,16 @@
|
|
|
178
178
|
scale = 'scale(0.85)';
|
|
179
179
|
position += 50;
|
|
180
180
|
}
|
|
181
|
-
var pointPosition = (qrCode.size - QR_BORDER) *
|
|
181
|
+
var pointPosition = (qrCode.size - QR_BORDER) * options.incTileSize;
|
|
182
182
|
parts.push("<use fill-rule=\"evenodd\" transform=\"translate(0,0)\" xlink:href=\"#point-" + options.suffix + "\"/>");
|
|
183
183
|
parts.push("<use fill-rule=\"evenodd\" transform=\"translate(" + pointPosition + ",0)\" xlink:href=\"#point-" + options.suffix + "\"/>");
|
|
184
184
|
parts.push("<use fill-rule=\"evenodd\" transform=\"translate(0," + pointPosition + ")\" xlink:href=\"#point-" + options.suffix + "\"/>");
|
|
185
185
|
if (options.isShowLogo) {
|
|
186
186
|
if (!options.logoData) {
|
|
187
|
-
parts.push("\n <use style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"
|
|
187
|
+
parts.push("\n <use style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n fill=\"none\"\n fill-rule=\"evenodd\"\n transform=\"translate(" + position + "," + position + ") " + scale + "\" xlink:href=\"#vk_logo-" + options.suffix + "\"\n />\n ");
|
|
188
188
|
}
|
|
189
189
|
else {
|
|
190
|
-
parts.push("\n <image
|
|
190
|
+
parts.push("\n <image\n preserveAspectRatio=\"xMidYMid slice\" clip-path=\"url(#logo-mask-" + options.suffix + ")\"\n style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n transform=\"translate(" + position + "," + position + ") " + scale + "\"\n xlink:href=\"" + options.logoData + "\"\n />\n ");
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
var backgroundSize = 99 * qrCode.size;
|
|
@@ -197,13 +197,13 @@
|
|
|
197
197
|
var qrScale = (options.qrSize - 20 * 2) / options.qrSize; // 0.756972112
|
|
198
198
|
var padding = (backgroundSize / options.qrSize) * 21;
|
|
199
199
|
var radius = Math.ceil(backgroundSize / (options.qrSize / 36)); // 7.11111111 = 256px/36px radius
|
|
200
|
-
qrBackground = "\n <rect
|
|
200
|
+
qrBackground = "\n <rect\n x=\"0\"\n width=\"" + backgroundSize + "\"\n height=\"" + backgroundSize + "\"\n rx=\"" + radius + "\"\n fill=\"" + options.backgroundColor + "\"\n />";
|
|
201
201
|
qrTransform = "translate(" + padding + ", " + padding + ") scale(" + qrScale + ")";
|
|
202
202
|
}
|
|
203
203
|
// eslint-disable-next-line
|
|
204
204
|
var oneSide = "M0,0 L66,0 C" + _84_7 + ",-3.44940413e-15 " + _100 + ",15.2223185 " + _100 + ",34 L" + _100 + ",66 C" + _100 + "," + _84_7 + " " + _84_7 + "," + _100 + " 66," + _100 + " L0," + _100 + " L0,0 Z";
|
|
205
205
|
var twoSides = "M0,0 L" + _100 + ",0 L" + _100 + ",66 C" + _100 + "," + _84_7 + " " + _84_7 + "," + _100 + " 66," + _100 + " L0," + _100 + " L0,0 Z";
|
|
206
|
-
return "\n <svg
|
|
206
|
+
return "\n <svg\n version=\"1.1\"\n viewBox=\"0 0 " + backgroundSize + " " + backgroundSize + "\"\n width=\"" + options.qrSize + "px\"\n height=\"" + options.qrSize + "px\"\n " + (options.className ? "class=\"" + options.className + "\"" : '') + "\n xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <defs>\n <rect id=\"rect-" + options.suffix + "\" width=\"100\" height=\"100\" fill=\"" + options.foregroundColor + "\"/>\n <path\n id=\"empty-" + options.suffix + "\"\n d=\"M0," + _28_6 + "v" + _42_9 + "C0," + _87_3 + "," + _12_8 + "," + _100 + "," + _28_6 + "," + _100 + "h" + _42_9 + "c" + _15_9 + ",0," + _28_6 + "-" + _12_8 + "," + _28_6 + "-" + _28_6 + "V" + _28_6 + "C" + _100 + "," + _12_7 + "," + _87_2 + ",0," + _71_4 + ",0H" + _28_6 + " C" + _12_8 + ",0,0," + _12_8 + ",0," + _28_6 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path id=\"b-" + options.suffix + "\" d=\"" + oneSide + "\" transform=\"rotate(-90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"r-" + options.suffix + "\" d=\"" + oneSide + "\" transform=\"rotate(-180 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"l-" + options.suffix + "\" d=\"" + oneSide + "\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"t-" + options.suffix + "\" d=\"" + oneSide + "\" transform=\"rotate(90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"l-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(-90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"lt-" + options.suffix + "\" d=\"" + twoSides + "\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"lb-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(-90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"rb-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(-180 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path id=\"rt-" + options.suffix + "\" d=\"" + twoSides + "\" transform=\"rotate(90 50 50)\" fill=\"" + options.foregroundColor + "\"/>\n <path\n id=\"n_lt-" + options.suffix + "\"\n d=\"M" + _30_5 + "," + _2 + "V0H0v" + _30_5 + "h" + _2 + "C" + _2 + "," + _14_7 + "," + _14_8 + "," + _2 + "," + _30_5 + "," + _2 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path\n id=\"n_lb-" + options.suffix + "\"\n d=\"M" + _2 + "," + _69_5 + "H0V" + _100 + "h" + _30_5 + "v-" + _2 + "C" + _14_7 + "," + _98 + "," + _2 + "," + _85_2 + "," + _2 + "," + _69_5 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path\n id=\"n_rt-" + options.suffix + "\"\n d=\"M" + _98 + "," + _30_5 + "h" + _2 + "V0H" + _69_5 + "v" + _2 + "C" + _85_3 + "," + _2 + "," + _98 + "," + _14_8 + "," + _98 + "," + _30_5 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path id=\"n_rb-" + options.suffix + "\"\n d=\"M" + _69_5 + "," + _98 + "v" + _2 + "H" + _100 + "V" + _69_5 + "h-" + _2 + "C" + _98 + "," + _85_3 + "," + _85_2 + "," + _98 + "," + _69_5 + "," + _98 + "z\"\n fill=\"" + options.foregroundColor + "\"\n />\n <path\n id=\"point-" + options.suffix + "\"\n fill=\"" + options.foregroundColor + "\"\n d=\"M600.001786,457.329333 L600.001786,242.658167 C600.001786,147.372368 587.039517,124.122784 581.464617,118.535383 C575.877216,112.960483 552.627632,99.9982143 457.329333,99.9982143 L242.670667,99.9982143 C147.372368,99.9982143 124.122784,112.960483 118.547883,118.535383 C112.972983,124.122784 99.9982143,147.372368 99.9982143,242.658167 L99.9982143,457.329333 C99.9982143,552.627632 112.972983,575.877216 118.547883,581.464617 C124.122784,587.027017 147.372368,600.001786 242.670667,600.001786 L457.329333,600.001786 C552.627632,600.001786 575.877216,587.027017 581.464617,581.464617 C587.039517,575.877216 600.001786,552.627632 600.001786,457.329333 Z M457.329333,0 C653.338333,0 700,46.6616668 700,242.658167 C700,438.667167 700,261.332833 700,457.329333 C700,653.338333 653.338333,700 457.329333,700 C261.332833,700 438.667167,700 242.670667,700 C46.6616668,700 0,653.338333 0,457.329333 C0,261.332833 0,352.118712 0,242.658167 C0,46.6616668 46.6616668,0 242.670667,0 C438.667167,0 261.332833,0 457.329333,0 Z M395.996667,200 C480.004166,200 500,220.008332 500,303.990835 C500,387.998334 500,312.001666 500,395.996667 C500,479.991668 480.004166,500 395.996667,500 C312.001666,500 387.998334,500 304.003333,500 C220.008332,500 200,479.991668 200,395.996667 C200,312.001666 200,350.906061 200,303.990835 C200,220.008332 220.008332,200 304.003333,200 C387.998334,200 312.001666,200 395.996667,200 Z\"\n />\n <g id=\"vk_logo-" + options.suffix + "\">\n <path\n fill=\"" + options.logoColor + "\"\n d=\"M83.3334 363.333C83.3334 231.34 83.3334 165.343 124.338 124.338C165.343 83.3333 231.34 83.3333 363.333 83.3333H386.667C518.66 83.3333 584.657 83.3333 625.662 124.338C666.667 165.343 666.667 231.34 666.667 363.333V386.667C666.667 518.66 666.667 584.657 625.662 625.662C584.657 666.667 518.66 666.667 386.667 666.667H363.333C231.34 666.667 165.343 666.667 124.338 625.662C83.3334 584.657 83.3334 518.66 83.3334 386.667V363.333Z\"\n />\n <path\n fill=\"#FFF\"\n d=\"M394.907 508.681C263.293 508.681 183.442 417.365 180.313 265.625H246.972C249.05 377.09 299.763 424.323 338.638 434.036V265.625H402.519V361.82C440.016 357.664 479.264 313.909 492.456 265.625H555.333C545.27 325 502.543 368.754 472.353 386.803C502.566 401.395 551.177 439.593 569.926 508.681H500.815C486.222 462.498 450.476 426.728 402.542 421.872V508.681H394.907Z\"\n />\n </g>\n <clipPath id=\"logo-mask-" + options.suffix + "\">\n <rect x=\"0\" y=\"0\" width=\"750\" height=\"750\" />\n </clipPath>\n </defs>\n\n " + qrBackground + "\n\n <g transform=\"" + qrTransform + "\">\n " + parts.join('\n') + "\n </g>\n </svg>";
|
|
207
207
|
};
|
|
208
208
|
|
|
209
209
|
/*
|
|
@@ -1141,7 +1141,7 @@
|
|
|
1141
1141
|
/** Default foreground color */
|
|
1142
1142
|
var FOREGROUND_COLOR_DEFAULT = '#000000';
|
|
1143
1143
|
/** Default logo color */
|
|
1144
|
-
var LOGO_COLOR_DEFAULT = '#
|
|
1144
|
+
var LOGO_COLOR_DEFAULT = '#07f';
|
|
1145
1145
|
/**
|
|
1146
1146
|
* Implementation
|
|
1147
1147
|
*/
|
|
@@ -1174,6 +1174,7 @@
|
|
|
1174
1174
|
suffix: options.suffix ? options.suffix.toString() : '0',
|
|
1175
1175
|
logoData: typeof options.logoData === 'string' ? options.logoData : null,
|
|
1176
1176
|
ecc: (typeof options.ecc === 'number' && eccLevels[options.ecc] ? options.ecc : 3),
|
|
1177
|
+
incTileSize: typeof options.incTileSize === 'number' ? options.incTileSize : INC_TILE_SIZE,
|
|
1177
1178
|
};
|
|
1178
1179
|
// Code generation
|
|
1179
1180
|
var segments = QrSegment.makeSegments(text);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t=t||self).qrCodeGenerator=r()}(this,function(){"use strict";function k(t,r,e,o,n){if(t<7&&r<7)return!1;if(e-7<=t&&r<7)return!1;if(t<7&&e-7<=r)return!1;if(n){var i=9;e<=25&&i--;var s=(e-14-i)/2-1;return e<=25&&s++,!(7+s<t&&t<e-7-s-1&&7+s<r&&r<e-7-s-1)&&(0<=t&&t<e&&0<=r&&r<e&&o[r][t])}return o[r]&&o[r][t]}var h=function(){return(h=Object.assign||function(t){for(var r,e=1,o=arguments.length;e<o;e++)for(var n in r=arguments[e])Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n]);return t}).apply(this,arguments)},f=(N.encodeText=function(t,r){var e=R.makeSegments(t);return N.encodeSegments(e,r)},N.encodeBinary=function(t,r){var e=R.makeBytes(t);return N.encodeSegments([e],r)},N.encodeSegments=function(t,r,e,o,n,i){if(void 0===e&&(e=1),void 0===o&&(o=40),void 0===n&&(n=-1),void 0===i&&(i=!0),!(N.MIN_VERSION<=e&&e<=o&&o<=N.MAX_VERSION)||n<-1||7<n)throw"Invalid value";var s,a;for(s=e;;s++){var h=8*N.getNumDataCodewords(s,r),f=R.getTotalBits(t,s);if(f<=h){a=f;break}if(o<=s)throw"Data too long"}for(var l=0,u=[N.Ecc.MEDIUM,N.Ecc.QUARTILE,N.Ecc.HIGH];l<u.length;l++){var d=u[l];i&&a<=8*N.getNumDataCodewords(s,d)&&(r=d)}for(var c=new A,g=0,p=t;g<p.length;g++){var C=p[g];c.appendBits(C.mode.modeBits,4),c.appendBits(C.numChars,C.mode.numCharCountBits(s));for(var v=0,m=C.getData();v<m.length;v++){var w=m[v];c.array.push(w)}}if(c.array.length!=a)throw"Assertion error";var M=8*N.getNumDataCodewords(s,r);if(c.array.length>M)throw"Assertion error";if(c.appendBits(0,Math.min(4,M-c.array.length)),c.appendBits(0,(8-c.array.length%8)%8),c.array.length%8!=0)throw"Assertion error";for(var E=236;c.array.length<M;E^=253)c.appendBits(E,8);for(var y=[];8*y.length<c.array.length;)y.push(0);return c.array.forEach(function(t,r){return y[r>>>3]|=t<<7-(7&r)}),new N(s,r,y,n)},N.prototype.getModule=function(t,r){return 0<=t&&t<this.size&&0<=r&&r<this.size&&this.modules[r][t]},N.prototype.drawCanvas=function(t,r,e){if(t<=0||r<0)throw"Value out of range";var o=(this.size+2*r)*t;e.width=o,e.height=o;for(var n=e.getContext("2d"),i=-r;i<this.size+r;i++)for(var s=-r;s<this.size+r;s++)n.fillStyle=this.getModule(s,i)?"#000000":"#FFFFFF",n.fillRect((s+r)*t,(i+r)*t,t,t)},N.prototype.toSvgString=function(t){if(t<0)throw"Border must be non-negative";for(var r=[],e=0;e<this.size;e++)for(var o=0;o<this.size;o++)this.getModule(o,e)&&r.push("M"+(o+t)+","+(e+t)+"h1v1h-1z");return'<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 '+(this.size+2*t)+" "+(this.size+2*t)+'" stroke="none">\n\t<rect width="100%" height="100%" fill="#FFFFFF"/>\n\t<path d="'+r.join(" ")+'" fill="#000000"/>\n</svg>\n'},N.prototype.drawFunctionPatterns=function(){for(var t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);var r=this.getAlignmentPatternPositions(),e=r.length;for(t=0;t<e;t++)for(var o=0;o<e;o++)0==t&&0==o||0==t&&o==e-1||t==e-1&&0==o||this.drawAlignmentPattern(r[t],r[o]);this.drawFormatBits(0),this.drawVersion()},N.prototype.drawFormatBits=function(t){for(var r=this.errorCorrectionLevel.formatBits<<3|t,e=r,o=0;o<10;o++)e=e<<1^1335*(e>>>9);var n=21522^(r<<10|e);if(n>>>15!=0)throw"Assertion error";for(o=0;o<=5;o++)this.setFunctionModule(8,o,a(n,o));for(this.setFunctionModule(8,7,a(n,6)),this.setFunctionModule(8,8,a(n,7)),this.setFunctionModule(7,8,a(n,8)),o=9;o<15;o++)this.setFunctionModule(14-o,8,a(n,o));for(o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,a(n,o));for(o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,a(n,o));this.setFunctionModule(8,this.size-8,!0)},N.prototype.drawVersion=function(){if(!(this.version<7)){for(var t=this.version,r=0;r<12;r++)t=t<<1^7973*(t>>>11);var e=this.version<<12|t;if(e>>>18!=0)throw"Assertion error";for(r=0;r<18;r++){var o=a(e,r),n=this.size-11+r%3,i=Math.floor(r/3);this.setFunctionModule(n,i,o),this.setFunctionModule(i,n,o)}}},N.prototype.drawFinderPattern=function(t,r){for(var e=-4;e<=4;e++)for(var o=-4;o<=4;o++){var n=Math.max(Math.abs(o),Math.abs(e)),i=t+o,s=r+e;0<=i&&i<this.size&&0<=s&&s<this.size&&this.setFunctionModule(i,s,2!=n&&4!=n)}},N.prototype.drawAlignmentPattern=function(t,r){for(var e=-2;e<=2;e++)for(var o=-2;o<=2;o++)this.setFunctionModule(t+o,r+e,1!=Math.max(Math.abs(o),Math.abs(e)))},N.prototype.setFunctionModule=function(t,r,e){this.modules[r][t]=e,this.isFunction[r][t]=!0},N.prototype.addEccAndInterleave=function(t){var r=this.version,e=this.errorCorrectionLevel;if(t.length!=N.getNumDataCodewords(r,e))throw"Invalid argument";for(var o=N.NUM_ERROR_CORRECTION_BLOCKS[e.ordinal][r],n=N.ECC_CODEWORDS_PER_BLOCK[e.ordinal][r],i=Math.floor(N.getNumRawDataModules(r)/8),s=o-i%o,a=Math.floor(i/o),h=[],f=new C(n),l=0,u=0;l<o;l++){var d=t.slice(u,u+a-n+(l<s?0:1));u+=d.length;var c=f.getRemainder(d);l<s&&d.push(0),h.push(d.concat(c))}var g=[];for(l=0;l<h[0].length;l++)for(var p=0;p<h.length;p++)(l!=a-n||s<=p)&&g.push(h[p][l]);if(g.length!=i)throw"Assertion error";return g},N.prototype.drawCodewords=function(t){if(t.length!=Math.floor(N.getNumRawDataModules(this.version)/8))throw"Invalid argument";for(var r=0,e=this.size-1;1<=e;e-=2){6==e&&(e=5);for(var o=0;o<this.size;o++)for(var n=0;n<2;n++){var i=e-n,s=0==(e+1&2)?this.size-1-o:o;!this.isFunction[s][i]&&r<8*t.length&&(this.modules[s][i]=a(t[r>>>3],7-(7&r)),r++)}}if(r!=8*t.length)throw"Assertion error"},N.prototype.applyMask=function(t){if(t<0||7<t)throw"Mask value out of range";for(var r=0;r<this.size;r++)for(var e=0;e<this.size;e++){var o=void 0;switch(t){case 0:o=(e+r)%2==0;break;case 1:o=r%2==0;break;case 2:o=e%3==0;break;case 3:o=(e+r)%3==0;break;case 4:o=(Math.floor(e/3)+Math.floor(r/2))%2==0;break;case 5:o=e*r%2+e*r%3==0;break;case 6:o=(e*r%2+e*r%3)%2==0;break;case 7:o=((e+r)%2+e*r%3)%2==0;break;default:throw"Assertion error"}!this.isFunction[r][e]&&o&&(this.modules[r][e]=!this.modules[r][e])}},N.prototype.getPenaltyScore=function(){for(var t=0,r=0;r<this.size;r++){for(var e=[0,0,0,0,0,0,0],o=!1,n=0,i=0;i<this.size;i++)this.modules[r][i]==o?5==++n?t+=N.PENALTY_N1:5<n&&t++:(N.addRunToHistory(n,e),!o&&N.hasFinderLikePattern(e)&&(t+=N.PENALTY_N3),o=this.modules[r][i],n=1);N.addRunToHistory(n,e),o&&N.addRunToHistory(0,e),N.hasFinderLikePattern(e)&&(t+=N.PENALTY_N3)}for(i=0;i<this.size;i++){o=!(e=[0,0,0,0,0,0,0]);var s=0;for(r=0;r<this.size;r++)this.modules[r][i]==o?5==++s?t+=N.PENALTY_N1:5<s&&t++:(N.addRunToHistory(s,e),!o&&N.hasFinderLikePattern(e)&&(t+=N.PENALTY_N3),o=this.modules[r][i],s=1);N.addRunToHistory(s,e),o&&N.addRunToHistory(0,e),N.hasFinderLikePattern(e)&&(t+=N.PENALTY_N3)}for(r=0;r<this.size-1;r++)for(i=0;i<this.size-1;i++)(o=this.modules[r][i])==this.modules[r][i+1]&&o==this.modules[r+1][i]&&o==this.modules[r+1][i+1]&&(t+=N.PENALTY_N2);for(var a=0,h=0,f=this.modules;h<f.length;h++)for(var l=0,u=f[h];l<u.length;l++)(o=u[l])&&a++;var d=this.size*this.size;return t+=(Math.ceil(Math.abs(20*a-10*d)/d)-1)*N.PENALTY_N4},N.prototype.getAlignmentPatternPositions=function(){if(1==this.version)return[];for(var t=Math.floor(this.version/7)+2,r=32==this.version?26:2*Math.ceil((this.size-13)/(2*t-2)),e=[6],o=this.size-7;e.length<t;o-=r)e.splice(1,0,o);return e},N.getNumRawDataModules=function(t){if(t<N.MIN_VERSION||N.MAX_VERSION<t)throw"Version number out of range";var r=(16*t+128)*t+64;if(2<=t){var e=Math.floor(t/7)+2;r-=(25*e-10)*e-55,7<=t&&(r-=36)}return r},N.getNumDataCodewords=function(t,r){return Math.floor(N.getNumRawDataModules(t)/8)-N.ECC_CODEWORDS_PER_BLOCK[r.ordinal][t]*N.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][t]},N.addRunToHistory=function(t,r){r.pop(),r.unshift(t)},N.hasFinderLikePattern=function(t){var r=t[1];return 0<r&&t[2]==r&&t[4]==r&&t[5]==r&&t[3]==3*r&&Math.max(t[0],t[6])>=4*r},N.MIN_VERSION=1,N.MAX_VERSION=40,N.PENALTY_N1=3,N.PENALTY_N2=3,N.PENALTY_N3=40,N.PENALTY_N4=10,N.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],N.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],N);function N(t,r,e,o){if(this.version=t,this.errorCorrectionLevel=r,this.mask=o,this.modules=[],this.isFunction=[],t<N.MIN_VERSION||N.MAX_VERSION<t)throw"Version value out of range";if(o<-1||7<o)throw"Mask value out of range";this.size=4*t+17;for(var n=[],i=0;i<this.size;i++)n.push(!1);for(i=0;i<this.size;i++)this.modules.push(n.slice()),this.isFunction.push(n.slice());this.drawFunctionPatterns();var s=this.addEccAndInterleave(e);if(this.drawCodewords(s),-1==o){var a=1e9;for(i=0;i<8;i++){this.applyMask(i),this.drawFormatBits(i);var h=this.getPenaltyScore();h<a&&(o=i,a=h),this.applyMask(i)}}if(o<0||7<o)throw"Assertion error";this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}function a(t,r){return 0!=(t>>>r&1)}var R=(i.makeBytes=function(t){for(var r=new A,e=0,o=t;e<o.length;e++){var n=o[e];r.appendBits(n,8)}return new i(i.Mode.BYTE,t.length,r.array)},i.makeNumeric=function(t){if(!this.NUMERIC_REGEX.test(t))throw"String contains non-numeric characters";for(var r=new A,e=0;e<t.length;){var o=Math.min(t.length-e,3);r.appendBits(parseInt(t.substr(e,o),10),3*o+1),e+=o}return new i(i.Mode.NUMERIC,t.length,r.array)},i.makeAlphanumeric=function(t){if(!this.ALPHANUMERIC_REGEX.test(t))throw"String contains unencodable characters in alphanumeric mode";var r,e=new A;for(r=0;r+2<=t.length;r+=2){var o=45*i.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r));o+=i.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r+1)),e.appendBits(o,11)}return r<t.length&&e.appendBits(i.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r)),6),new i(i.Mode.ALPHANUMERIC,t.length,e.array)},i.makeSegments=function(t){return""==t?[]:this.NUMERIC_REGEX.test(t)?[i.makeNumeric(t)]:this.ALPHANUMERIC_REGEX.test(t)?[i.makeAlphanumeric(t)]:[i.makeBytes(i.toUtf8ByteArray(t))]},i.makeEci=function(t){var r=new A;if(t<0)throw"ECI assignment value out of range";if(t<128)r.appendBits(t,8);else if(t<16384)r.appendBits(2,2),r.appendBits(t,14);else{if(!(t<1e6))throw"ECI assignment value out of range";r.appendBits(6,3),r.appendBits(t,21)}return new i(i.Mode.ECI,0,r.array)},i.prototype.getData=function(){return this.bitData.slice()},i.getTotalBits=function(t,r){for(var e=0,o=0,n=t;o<n.length;o++){var i=n[o],s=i.mode.numCharCountBits(r);if(i.numChars>=1<<s)return 1/0;e+=4+s+i.bitData.length}return e},i.toUtf8ByteArray=function(t){t=encodeURI(t);for(var r=[],e=0;e<t.length;e++)"%"!=t.charAt(e)?r.push(t.charCodeAt(e)):(r.push(parseInt(t.substr(e+1,2),16)),e+=2);return r},i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",i);function i(t,r,e){if(this.mode=t,this.numChars=r,this.bitData=e,r<0)throw"Invalid argument";this.bitData=e.slice()}var C=(s.prototype.getRemainder=function(t){for(var o=this.coefficients.map(function(t){return 0}),r=function(t){var e=t^o.shift();o.push(0),n.coefficients.forEach(function(t,r){return o[r]^=s.multiply(t,e)})},n=this,e=0,i=t;e<i.length;e++)r(i[e]);return o},s.multiply=function(t,r){if(t>>>8!=0||r>>>8!=0)throw"Byte out of range";for(var e=0,o=7;0<=o;o--)e=e<<1^285*(e>>>7),e^=(r>>>o&1)*t;if(e>>>8!=0)throw"Assertion error";return e},s);function s(t){if(this.coefficients=[],t<1||255<t)throw"Degree out of range";for(var r=this.coefficients,e=0;e<t-1;e++)r.push(0);r.push(1);var o=1;for(e=0;e<t;e++){for(var n=0;n<r.length;n++)r[n]=s.multiply(r[n],o),n+1<r.length&&(r[n]^=r[n+1]);o=s.multiply(o,2)}}var t,r,e,o,A=(n.prototype.appendBits=function(t,r){if(r<0||31<r||t>>>r!=0)throw"Value out of range";for(var e=r-1;0<=e;e--)this.array.push(t>>>e&1)},n);function n(){this.array=[]}function l(t,r){this.ordinal=t,this.formatBits=r}function u(t,r){this.modeBits=t,this.numBitsCharCount=r}t=f=f||{},l.LOW=new l(0,1),l.MEDIUM=new l(1,0),l.QUARTILE=new l(2,3),l.HIGH=new l(3,2),r=l,t.Ecc=r,e=R=R||{},u.prototype.numCharCountBits=function(t){return this.numBitsCharCount[Math.floor((t+7)/17)]},u.NUMERIC=new u(1,[10,12,14]),u.ALPHANUMERIC=new u(2,[9,11,13]),u.BYTE=new u(4,[8,16,16]),u.KANJI=new u(8,[8,10,12]),u.ECI=new u(7,[0,0,0]),o=u,e.Mode=o;return{createQR:function(t,r,e,o){if("string"!=typeof t)throw new TypeError("Enter text for encoding");var n=h(h(h({},"object"==typeof r&&null!==r?r:{}),"object"==typeof o&&null!==o?o:{}),{qrSize:"object"==typeof r&&null!==r&&"number"==typeof r.qrSize?r.qrSize:r,className:"object"==typeof r&&null!==r&&"string"==typeof r.className?r.className:e}),i=[f.Ecc.LOW,f.Ecc.MEDIUM,f.Ecc.QUARTILE,f.Ecc.HIGH],s={qrSize:"number"==typeof n.qrSize?n.qrSize:128,className:"string"==typeof n.className?n.className:e||"",isShowLogo:!!n.isShowLogo||!1,isShowBackground:!!n.isShowBackground||!1,foregroundColor:"string"==typeof n.foregroundColor?n.foregroundColor:"#000000",backgroundColor:"string"==typeof n.backgroundColor?n.backgroundColor:"#ffffff",logoColor:"string"==typeof n.logoColor?n.logoColor:"#4680c2",suffix:n.suffix?n.suffix.toString():"0",logoData:"string"==typeof n.logoData?n.logoData:null,ecc:"number"==typeof n.ecc&&i[n.ecc]?n.ecc:3},a=R.makeSegments(t);return function(t,r){if("number"!=typeof r.qrSize)throw new Error("Size should be a number");if("string"!=typeof r.className)throw new Error("Classname should be a string");for(var e,o,n,i,s,a=12.8,h=28.6,f=30.5,l=84.7776815,u=69.5,d=100,c=[],g=0,p=0,C=0,v=0,m=0;m<t.size;m++){for(var w=g=0;w<t.size;w++){C=w+g,g+=96,v=m+p;var M,E=(e=w,o=m,n=t.size,i=t.modules,void 0===(s=r.isShowLogo)&&(s=!0),{l:k(e-1,o,n,i,s),r:k(e+1,o,n,i,s),t:k(e,o-1,n,i,s),b:k(e,o+1,n,i,s),current:k(e,o,n,i,s)}),y="";E.current?(y=!(y=y||E.l||E.r||E.t||E.b?"":"empty")&&E.l&&E.r||E.t&&E.b?"rect":"")||(y+=E.l?"l":E.r?"r":"",y=(y+=E.t?"t":E.b?"b":"")||"empty"):y=!(y=!(y=!(y=!y&&E.l&&E.t&&k(w-1,m-1,t.size,t.modules,r.isShowLogo)?"n_lt":"")&&E.l&&E.b&&k(w-1,m+1,t.size,t.modules,r.isShowLogo)?"n_lb":"")&&E.r&&E.t&&k(w+1,m-1,t.size,t.modules,r.isShowLogo)?"n_rt":"")&&E.r&&E.b&&k(w+1,m+1,t.size,t.modules,r.isShowLogo)?"n_rb":"",y&&(M='<use xlink:href="#'+y+"-"+r.suffix+'"/>',c.push('<g transform="translate('+C+","+v+')">'+M+"</g>"))}p+=96}var N="",R=(t.size-21)/2*96+672-10;t.size<=25&&(N="scale(0.85)",R+=50);var A=96*(t.size-7);c.push('<use fill-rule="evenodd" transform="translate(0,0)" xlink:href="#point-'+r.suffix+'"/>'),c.push('<use fill-rule="evenodd" transform="translate('+A+',0)" xlink:href="#point-'+r.suffix+'"/>'),c.push('<use fill-rule="evenodd" transform="translate(0,'+A+')" xlink:href="#point-'+r.suffix+'"/>'),r.isShowLogo&&(r.logoData?c.push('\n <image \n preserveAspectRatio="xMidYMid slice" clip-path="url(#logo-mask-'+r.suffix+')"\n style="width: 750px; height: 750px;" width="750" height="750" \n transform="translate('+R+","+R+") "+N+'" \n xlink:href="'+r.logoData+'" \n />\n '):c.push('\n <use style="width: 750px; height: 750px;" width="750" height="750" \n fill="none" \n fill-rule="evenodd" \n transform="translate('+R+","+R+") "+N+'" xlink:href="#vk_logo-'+r.suffix+'"\n />\n '));var L=99*t.size,z="",x="translate(0,0)";if(r.isShowBackground){var S=(r.qrSize-40)/r.qrSize,_=L/r.qrSize*21;z='\n <rect \n x="0" \n width="'+L+'" \n height="'+L+'" \n rx="'+Math.ceil(L/(r.qrSize/36))+'" \n fill="'+r.backgroundColor+'"\n />',x="translate("+_+", "+_+") scale("+S+")"}var b="M0,0 L66,0 C84.7776815,-3.44940413e-15 100,15.2223185 100,34 L100,66 C100,"+l+" "+l+","+d+" 66,"+d+" L0,"+d+" L0,0 Z",I="M0,0 L100,0 L100,66 C100,"+l+" "+l+","+d+" 66,"+d+" L0,"+d+" L0,0 Z";return'\n <svg \n version="1.1" \n viewBox="0 0 '+L+" "+L+'" \n width="'+r.qrSize+'px" \n height="'+r.qrSize+'px"\n '+(r.className?'class="'+r.className+'"':"")+' \n xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"\n >\n <defs>\n <rect id="rect-'+r.suffix+'" width="100" height="100" fill="'+r.foregroundColor+'"/>\n <path \n id="empty-'+r.suffix+'" \n d="M0,'+h+"v42.9C0,87.3,"+a+","+d+","+h+","+d+"h42.9c15.9,0,"+h+"-"+a+","+h+"-"+h+"V"+h+"C"+d+",12.7,87.2,0,71.4,0H"+h+" C"+a+",0,0,"+a+",0,"+h+'z"\n fill="'+r.foregroundColor+'"\n />\n <path id="b-'+r.suffix+'" d="'+b+'" transform="rotate(-90 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="r-'+r.suffix+'" d="'+b+'" transform="rotate(-180 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="l-'+r.suffix+'" d="'+b+'" fill="'+r.foregroundColor+'"/>\n <path id="t-'+r.suffix+'" d="'+b+'" transform="rotate(90 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="l-'+r.suffix+'" d="'+I+'" transform="rotate(-90 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="lt-'+r.suffix+'" d="'+I+'" fill="'+r.foregroundColor+'"/>\n <path id="lb-'+r.suffix+'" d="'+I+'" transform="rotate(-90 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="rb-'+r.suffix+'" d="'+I+'" transform="rotate(-180 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="rt-'+r.suffix+'" d="'+I+'" transform="rotate(90 50 50)" fill="'+r.foregroundColor+'"/>\n <path \n id="n_lt-'+r.suffix+'" \n d="M'+f+",2V0H0v"+f+"h2C2,14.7,14.8,2,"+f+',2z" \n fill="'+r.foregroundColor+'"\n />\n <path \n id="n_lb-'+r.suffix+'"\n d="M2,'+u+"H0V"+d+"h"+f+"v-2C14.7,98,2,85.2,2,"+u+'z" \n fill="'+r.foregroundColor+'"\n />\n <path \n id="n_rt-'+r.suffix+'" \n d="M98,'+f+"h2V0H"+u+"v2C85.3,2,98,14.8,98,"+f+'z" \n fill="'+r.foregroundColor+'"\n />\n <path id="n_rb-'+r.suffix+'" \n d="M'+u+",98v2H"+d+"V"+u+"h-2C98,85.3,85.2,98,"+u+',98z" \n fill="'+r.foregroundColor+'"\n />\n <path \n id="point-'+r.suffix+'" \n fill="'+r.foregroundColor+'"\n d="M600.001786,457.329333 L600.001786,242.658167 C600.001786,147.372368 587.039517,124.122784 581.464617,118.535383 C575.877216,112.960483 552.627632,99.9982143 457.329333,99.9982143 L242.670667,99.9982143 C147.372368,99.9982143 124.122784,112.960483 118.547883,118.535383 C112.972983,124.122784 99.9982143,147.372368 99.9982143,242.658167 L99.9982143,457.329333 C99.9982143,552.627632 112.972983,575.877216 118.547883,581.464617 C124.122784,587.027017 147.372368,600.001786 242.670667,600.001786 L457.329333,600.001786 C552.627632,600.001786 575.877216,587.027017 581.464617,581.464617 C587.039517,575.877216 600.001786,552.627632 600.001786,457.329333 Z M457.329333,0 C653.338333,0 700,46.6616668 700,242.658167 C700,438.667167 700,261.332833 700,457.329333 C700,653.338333 653.338333,700 457.329333,700 C261.332833,700 438.667167,700 242.670667,700 C46.6616668,700 0,653.338333 0,457.329333 C0,261.332833 0,352.118712 0,242.658167 C0,46.6616668 46.6616668,0 242.670667,0 C438.667167,0 261.332833,0 457.329333,0 Z M395.996667,200 C480.004166,200 500,220.008332 500,303.990835 C500,387.998334 500,312.001666 500,395.996667 C500,479.991668 480.004166,500 395.996667,500 C312.001666,500 387.998334,500 304.003333,500 C220.008332,500 200,479.991668 200,395.996667 C200,312.001666 200,350.906061 200,303.990835 C200,220.008332 220.008332,200 304.003333,200 C387.998334,200 312.001666,200 395.996667,200 Z" \n />\n <g id="vk_logo-'+r.suffix+'">\n <path \n fill="'+r.logoColor+'" \n d="M253.066667,0 C457.466667,0 272.533333,0 476.933333,0 C681.333333,0 730,48.6666667 730,253.066667 C730,457.466667 730,272.533333 730,476.933333 C730,681.333333 681.333333,730 476.933333,730 C272.533333,730 457.466667,730 253.066667,730 C48.6666667,730 0,681.333333 0,476.933333 C0,272.533333 0,367.206459 0,253.066667 C0,48.6666667 48.6666667,0 253.066667,0 Z"/><path fill="#FFF" d="M597.816744,251.493445 C601.198942,240.214758 597.816746,231.927083 581.719678,231.927083 L528.490512,231.927083 C514.956087,231.927083 508.716524,239.08642 505.332448,246.981031 C505.332448,246.981031 478.263599,312.960647 439.917002,355.818719 C427.510915,368.224806 421.871102,372.172112 415.10389,372.172112 C411.720753,372.172112 406.822917,368.224806 406.822917,356.947057 L406.822917,251.493445 C406.822917,237.95902 402.895137,231.927083 391.615512,231.927083 L307.969678,231.927083 C299.511836,231.927083 294.425223,238.208719 294.425223,244.162063 C294.425223,256.99245 313.597583,259.951287 315.573845,296.043086 L315.573845,374.428788 C315.573845,391.614583 312.470184,394.730425 305.702972,394.730425 C287.658011,394.730425 243.763595,328.456052 217.730151,252.620844 C212.628223,237.881107 207.511068,231.927083 193.907178,231.927083 L140.678012,231.927083 C125.469678,231.927083 122.427826,239.08642 122.427826,246.981031 C122.427826,261.079625 140.473725,331.006546 206.452402,423.489903 C250.437874,486.648674 312.410515,520.885417 368.803012,520.885417 C402.638134,520.885417 406.823845,513.28125 406.823845,500.183098 L406.823845,452.447917 C406.823845,437.239583 410.029185,434.204421 420.743703,434.204421 C428.638315,434.204421 442.172739,438.151727 473.753063,468.603713 C509.843923,504.694573 515.79398,520.885417 536.094678,520.885417 L589.323845,520.885417 C604.532178,520.885417 612.136345,513.28125 607.749619,498.274853 C602.949226,483.318593 585.717788,461.619053 562.853283,435.89599 C550.446258,421.234166 531.837128,405.444943 526.197316,397.548454 C518.302704,387.399043 520.558441,382.88663 526.197316,373.864619 C526.197316,373.864619 591.049532,282.508661 597.816744,251.493445 Z"\n />\n </g>\n <clipPath id="logo-mask-'+r.suffix+'">\n <rect x="0" y="0" width="750" height="750" />\n </clipPath>\n </defs>\n\n '+z+'\n\n <g transform="'+x+'">\n '+c.join("\n")+"\n </g>\n </svg>"}(f.encodeSegments(a,i[s.ecc],1,40,-1,!0),s)}}});
|
|
1
|
+
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t=t||self).qrCodeGenerator=r()}(this,function(){"use strict";function k(t,r,e,o,n){if(t<7&&r<7)return!1;if(e-7<=t&&r<7)return!1;if(t<7&&e-7<=r)return!1;if(n){var i=9;e<=25&&i--;var s=(e-14-i)/2-1;return e<=25&&s++,!(7+s<t&&t<e-7-s-1&&7+s<r&&r<e-7-s-1)&&(0<=t&&t<e&&0<=r&&r<e&&o[r][t])}return o[r]&&o[r][t]}var f=function(){return(f=Object.assign||function(t){for(var r,e=1,o=arguments.length;e<o;e++)for(var n in r=arguments[e])Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n]);return t}).apply(this,arguments)},h=(N.encodeText=function(t,r){var e=R.makeSegments(t);return N.encodeSegments(e,r)},N.encodeBinary=function(t,r){var e=R.makeBytes(t);return N.encodeSegments([e],r)},N.encodeSegments=function(t,r,e,o,n,i){if(void 0===e&&(e=1),void 0===o&&(o=40),void 0===n&&(n=-1),void 0===i&&(i=!0),!(N.MIN_VERSION<=e&&e<=o&&o<=N.MAX_VERSION)||n<-1||7<n)throw"Invalid value";var s,a;for(s=e;;s++){var f=8*N.getNumDataCodewords(s,r),h=R.getTotalBits(t,s);if(h<=f){a=h;break}if(o<=s)throw"Data too long"}for(var l=0,u=[N.Ecc.MEDIUM,N.Ecc.QUARTILE,N.Ecc.HIGH];l<u.length;l++){var d=u[l];i&&a<=8*N.getNumDataCodewords(s,d)&&(r=d)}for(var c=new z,g=0,p=t;g<p.length;g++){var v=p[g];c.appendBits(v.mode.modeBits,4),c.appendBits(v.numChars,v.mode.numCharCountBits(s));for(var C=0,m=v.getData();C<m.length;C++){var w=m[C];c.array.push(w)}}if(c.array.length!=a)throw"Assertion error";var M=8*N.getNumDataCodewords(s,r);if(c.array.length>M)throw"Assertion error";if(c.appendBits(0,Math.min(4,M-c.array.length)),c.appendBits(0,(8-c.array.length%8)%8),c.array.length%8!=0)throw"Assertion error";for(var E=236;c.array.length<M;E^=253)c.appendBits(E,8);for(var y=[];8*y.length<c.array.length;)y.push(0);return c.array.forEach(function(t,r){return y[r>>>3]|=t<<7-(7&r)}),new N(s,r,y,n)},N.prototype.getModule=function(t,r){return 0<=t&&t<this.size&&0<=r&&r<this.size&&this.modules[r][t]},N.prototype.drawCanvas=function(t,r,e){if(t<=0||r<0)throw"Value out of range";var o=(this.size+2*r)*t;e.width=o,e.height=o;for(var n=e.getContext("2d"),i=-r;i<this.size+r;i++)for(var s=-r;s<this.size+r;s++)n.fillStyle=this.getModule(s,i)?"#000000":"#FFFFFF",n.fillRect((s+r)*t,(i+r)*t,t,t)},N.prototype.toSvgString=function(t){if(t<0)throw"Border must be non-negative";for(var r=[],e=0;e<this.size;e++)for(var o=0;o<this.size;o++)this.getModule(o,e)&&r.push("M"+(o+t)+","+(e+t)+"h1v1h-1z");return'<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 '+(this.size+2*t)+" "+(this.size+2*t)+'" stroke="none">\n\t<rect width="100%" height="100%" fill="#FFFFFF"/>\n\t<path d="'+r.join(" ")+'" fill="#000000"/>\n</svg>\n'},N.prototype.drawFunctionPatterns=function(){for(var t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);var r=this.getAlignmentPatternPositions(),e=r.length;for(t=0;t<e;t++)for(var o=0;o<e;o++)0==t&&0==o||0==t&&o==e-1||t==e-1&&0==o||this.drawAlignmentPattern(r[t],r[o]);this.drawFormatBits(0),this.drawVersion()},N.prototype.drawFormatBits=function(t){for(var r=this.errorCorrectionLevel.formatBits<<3|t,e=r,o=0;o<10;o++)e=e<<1^1335*(e>>>9);var n=21522^(r<<10|e);if(n>>>15!=0)throw"Assertion error";for(o=0;o<=5;o++)this.setFunctionModule(8,o,a(n,o));for(this.setFunctionModule(8,7,a(n,6)),this.setFunctionModule(8,8,a(n,7)),this.setFunctionModule(7,8,a(n,8)),o=9;o<15;o++)this.setFunctionModule(14-o,8,a(n,o));for(o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,a(n,o));for(o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,a(n,o));this.setFunctionModule(8,this.size-8,!0)},N.prototype.drawVersion=function(){if(!(this.version<7)){for(var t=this.version,r=0;r<12;r++)t=t<<1^7973*(t>>>11);var e=this.version<<12|t;if(e>>>18!=0)throw"Assertion error";for(r=0;r<18;r++){var o=a(e,r),n=this.size-11+r%3,i=Math.floor(r/3);this.setFunctionModule(n,i,o),this.setFunctionModule(i,n,o)}}},N.prototype.drawFinderPattern=function(t,r){for(var e=-4;e<=4;e++)for(var o=-4;o<=4;o++){var n=Math.max(Math.abs(o),Math.abs(e)),i=t+o,s=r+e;0<=i&&i<this.size&&0<=s&&s<this.size&&this.setFunctionModule(i,s,2!=n&&4!=n)}},N.prototype.drawAlignmentPattern=function(t,r){for(var e=-2;e<=2;e++)for(var o=-2;o<=2;o++)this.setFunctionModule(t+o,r+e,1!=Math.max(Math.abs(o),Math.abs(e)))},N.prototype.setFunctionModule=function(t,r,e){this.modules[r][t]=e,this.isFunction[r][t]=!0},N.prototype.addEccAndInterleave=function(t){var r=this.version,e=this.errorCorrectionLevel;if(t.length!=N.getNumDataCodewords(r,e))throw"Invalid argument";for(var o=N.NUM_ERROR_CORRECTION_BLOCKS[e.ordinal][r],n=N.ECC_CODEWORDS_PER_BLOCK[e.ordinal][r],i=Math.floor(N.getNumRawDataModules(r)/8),s=o-i%o,a=Math.floor(i/o),f=[],h=new v(n),l=0,u=0;l<o;l++){var d=t.slice(u,u+a-n+(l<s?0:1));u+=d.length;var c=h.getRemainder(d);l<s&&d.push(0),f.push(d.concat(c))}var g=[];for(l=0;l<f[0].length;l++)for(var p=0;p<f.length;p++)(l!=a-n||s<=p)&&g.push(f[p][l]);if(g.length!=i)throw"Assertion error";return g},N.prototype.drawCodewords=function(t){if(t.length!=Math.floor(N.getNumRawDataModules(this.version)/8))throw"Invalid argument";for(var r=0,e=this.size-1;1<=e;e-=2){6==e&&(e=5);for(var o=0;o<this.size;o++)for(var n=0;n<2;n++){var i=e-n,s=0==(e+1&2)?this.size-1-o:o;!this.isFunction[s][i]&&r<8*t.length&&(this.modules[s][i]=a(t[r>>>3],7-(7&r)),r++)}}if(r!=8*t.length)throw"Assertion error"},N.prototype.applyMask=function(t){if(t<0||7<t)throw"Mask value out of range";for(var r=0;r<this.size;r++)for(var e=0;e<this.size;e++){var o=void 0;switch(t){case 0:o=(e+r)%2==0;break;case 1:o=r%2==0;break;case 2:o=e%3==0;break;case 3:o=(e+r)%3==0;break;case 4:o=(Math.floor(e/3)+Math.floor(r/2))%2==0;break;case 5:o=e*r%2+e*r%3==0;break;case 6:o=(e*r%2+e*r%3)%2==0;break;case 7:o=((e+r)%2+e*r%3)%2==0;break;default:throw"Assertion error"}!this.isFunction[r][e]&&o&&(this.modules[r][e]=!this.modules[r][e])}},N.prototype.getPenaltyScore=function(){for(var t=0,r=0;r<this.size;r++){for(var e=[0,0,0,0,0,0,0],o=!1,n=0,i=0;i<this.size;i++)this.modules[r][i]==o?5==++n?t+=N.PENALTY_N1:5<n&&t++:(N.addRunToHistory(n,e),!o&&N.hasFinderLikePattern(e)&&(t+=N.PENALTY_N3),o=this.modules[r][i],n=1);N.addRunToHistory(n,e),o&&N.addRunToHistory(0,e),N.hasFinderLikePattern(e)&&(t+=N.PENALTY_N3)}for(i=0;i<this.size;i++){o=!(e=[0,0,0,0,0,0,0]);var s=0;for(r=0;r<this.size;r++)this.modules[r][i]==o?5==++s?t+=N.PENALTY_N1:5<s&&t++:(N.addRunToHistory(s,e),!o&&N.hasFinderLikePattern(e)&&(t+=N.PENALTY_N3),o=this.modules[r][i],s=1);N.addRunToHistory(s,e),o&&N.addRunToHistory(0,e),N.hasFinderLikePattern(e)&&(t+=N.PENALTY_N3)}for(r=0;r<this.size-1;r++)for(i=0;i<this.size-1;i++)(o=this.modules[r][i])==this.modules[r][i+1]&&o==this.modules[r+1][i]&&o==this.modules[r+1][i+1]&&(t+=N.PENALTY_N2);for(var a=0,f=0,h=this.modules;f<h.length;f++)for(var l=0,u=h[f];l<u.length;l++)(o=u[l])&&a++;var d=this.size*this.size;return t+=(Math.ceil(Math.abs(20*a-10*d)/d)-1)*N.PENALTY_N4},N.prototype.getAlignmentPatternPositions=function(){if(1==this.version)return[];for(var t=Math.floor(this.version/7)+2,r=32==this.version?26:2*Math.ceil((this.size-13)/(2*t-2)),e=[6],o=this.size-7;e.length<t;o-=r)e.splice(1,0,o);return e},N.getNumRawDataModules=function(t){if(t<N.MIN_VERSION||N.MAX_VERSION<t)throw"Version number out of range";var r=(16*t+128)*t+64;if(2<=t){var e=Math.floor(t/7)+2;r-=(25*e-10)*e-55,7<=t&&(r-=36)}return r},N.getNumDataCodewords=function(t,r){return Math.floor(N.getNumRawDataModules(t)/8)-N.ECC_CODEWORDS_PER_BLOCK[r.ordinal][t]*N.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][t]},N.addRunToHistory=function(t,r){r.pop(),r.unshift(t)},N.hasFinderLikePattern=function(t){var r=t[1];return 0<r&&t[2]==r&&t[4]==r&&t[5]==r&&t[3]==3*r&&Math.max(t[0],t[6])>=4*r},N.MIN_VERSION=1,N.MAX_VERSION=40,N.PENALTY_N1=3,N.PENALTY_N2=3,N.PENALTY_N3=40,N.PENALTY_N4=10,N.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],N.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],N);function N(t,r,e,o){if(this.version=t,this.errorCorrectionLevel=r,this.mask=o,this.modules=[],this.isFunction=[],t<N.MIN_VERSION||N.MAX_VERSION<t)throw"Version value out of range";if(o<-1||7<o)throw"Mask value out of range";this.size=4*t+17;for(var n=[],i=0;i<this.size;i++)n.push(!1);for(i=0;i<this.size;i++)this.modules.push(n.slice()),this.isFunction.push(n.slice());this.drawFunctionPatterns();var s=this.addEccAndInterleave(e);if(this.drawCodewords(s),-1==o){var a=1e9;for(i=0;i<8;i++){this.applyMask(i),this.drawFormatBits(i);var f=this.getPenaltyScore();f<a&&(o=i,a=f),this.applyMask(i)}}if(o<0||7<o)throw"Assertion error";this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}function a(t,r){return 0!=(t>>>r&1)}var R=(i.makeBytes=function(t){for(var r=new z,e=0,o=t;e<o.length;e++){var n=o[e];r.appendBits(n,8)}return new i(i.Mode.BYTE,t.length,r.array)},i.makeNumeric=function(t){if(!this.NUMERIC_REGEX.test(t))throw"String contains non-numeric characters";for(var r=new z,e=0;e<t.length;){var o=Math.min(t.length-e,3);r.appendBits(parseInt(t.substr(e,o),10),3*o+1),e+=o}return new i(i.Mode.NUMERIC,t.length,r.array)},i.makeAlphanumeric=function(t){if(!this.ALPHANUMERIC_REGEX.test(t))throw"String contains unencodable characters in alphanumeric mode";var r,e=new z;for(r=0;r+2<=t.length;r+=2){var o=45*i.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r));o+=i.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r+1)),e.appendBits(o,11)}return r<t.length&&e.appendBits(i.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r)),6),new i(i.Mode.ALPHANUMERIC,t.length,e.array)},i.makeSegments=function(t){return""==t?[]:this.NUMERIC_REGEX.test(t)?[i.makeNumeric(t)]:this.ALPHANUMERIC_REGEX.test(t)?[i.makeAlphanumeric(t)]:[i.makeBytes(i.toUtf8ByteArray(t))]},i.makeEci=function(t){var r=new z;if(t<0)throw"ECI assignment value out of range";if(t<128)r.appendBits(t,8);else if(t<16384)r.appendBits(2,2),r.appendBits(t,14);else{if(!(t<1e6))throw"ECI assignment value out of range";r.appendBits(6,3),r.appendBits(t,21)}return new i(i.Mode.ECI,0,r.array)},i.prototype.getData=function(){return this.bitData.slice()},i.getTotalBits=function(t,r){for(var e=0,o=0,n=t;o<n.length;o++){var i=n[o],s=i.mode.numCharCountBits(r);if(i.numChars>=1<<s)return 1/0;e+=4+s+i.bitData.length}return e},i.toUtf8ByteArray=function(t){t=encodeURI(t);for(var r=[],e=0;e<t.length;e++)"%"!=t.charAt(e)?r.push(t.charCodeAt(e)):(r.push(parseInt(t.substr(e+1,2),16)),e+=2);return r},i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",i);function i(t,r,e){if(this.mode=t,this.numChars=r,this.bitData=e,r<0)throw"Invalid argument";this.bitData=e.slice()}var v=(s.prototype.getRemainder=function(t){for(var o=this.coefficients.map(function(t){return 0}),r=function(t){var e=t^o.shift();o.push(0),n.coefficients.forEach(function(t,r){return o[r]^=s.multiply(t,e)})},n=this,e=0,i=t;e<i.length;e++)r(i[e]);return o},s.multiply=function(t,r){if(t>>>8!=0||r>>>8!=0)throw"Byte out of range";for(var e=0,o=7;0<=o;o--)e=e<<1^285*(e>>>7),e^=(r>>>o&1)*t;if(e>>>8!=0)throw"Assertion error";return e},s);function s(t){if(this.coefficients=[],t<1||255<t)throw"Degree out of range";for(var r=this.coefficients,e=0;e<t-1;e++)r.push(0);r.push(1);var o=1;for(e=0;e<t;e++){for(var n=0;n<r.length;n++)r[n]=s.multiply(r[n],o),n+1<r.length&&(r[n]^=r[n+1]);o=s.multiply(o,2)}}var t,r,e,o,z=(n.prototype.appendBits=function(t,r){if(r<0||31<r||t>>>r!=0)throw"Value out of range";for(var e=r-1;0<=e;e--)this.array.push(t>>>e&1)},n);function n(){this.array=[]}function l(t,r){this.ordinal=t,this.formatBits=r}function u(t,r){this.modeBits=t,this.numBitsCharCount=r}t=h=h||{},l.LOW=new l(0,1),l.MEDIUM=new l(1,0),l.QUARTILE=new l(2,3),l.HIGH=new l(3,2),r=l,t.Ecc=r,e=R=R||{},u.prototype.numCharCountBits=function(t){return this.numBitsCharCount[Math.floor((t+7)/17)]},u.NUMERIC=new u(1,[10,12,14]),u.ALPHANUMERIC=new u(2,[9,11,13]),u.BYTE=new u(4,[8,16,16]),u.KANJI=new u(8,[8,10,12]),u.ECI=new u(7,[0,0,0]),o=u,e.Mode=o;return{createQR:function(t,r,e,o){if("string"!=typeof t)throw new TypeError("Enter text for encoding");var n=f(f(f({},"object"==typeof r&&null!==r?r:{}),"object"==typeof o&&null!==o?o:{}),{qrSize:"object"==typeof r&&null!==r&&"number"==typeof r.qrSize?r.qrSize:r,className:"object"==typeof r&&null!==r&&"string"==typeof r.className?r.className:e}),i=[h.Ecc.LOW,h.Ecc.MEDIUM,h.Ecc.QUARTILE,h.Ecc.HIGH],s={qrSize:"number"==typeof n.qrSize?n.qrSize:128,className:"string"==typeof n.className?n.className:e||"",isShowLogo:!!n.isShowLogo||!1,isShowBackground:!!n.isShowBackground||!1,foregroundColor:"string"==typeof n.foregroundColor?n.foregroundColor:"#000000",backgroundColor:"string"==typeof n.backgroundColor?n.backgroundColor:"#ffffff",logoColor:"string"==typeof n.logoColor?n.logoColor:"#07f",suffix:n.suffix?n.suffix.toString():"0",logoData:"string"==typeof n.logoData?n.logoData:null,ecc:"number"==typeof n.ecc&&i[n.ecc]?n.ecc:3,incTileSize:"number"==typeof n.incTileSize?n.incTileSize:96},a=R.makeSegments(t);return function(t,r){if("number"!=typeof r.qrSize)throw new Error("Size should be a number");if("string"!=typeof r.className)throw new Error("Classname should be a string");for(var e,o,n,i,s,a=12.8,f=28.6,h=30.5,l=84.7776815,u=69.5,d=100,c=[],g=0,p=0,v=0,C=0,m=0;m<t.size;m++){for(var w=g=0;w<t.size;w++){v=w+g,g+=96,C=m+p;var M,E=(e=w,o=m,n=t.size,i=t.modules,void 0===(s=r.isShowLogo)&&(s=!0),{l:k(e-1,o,n,i,s),r:k(e+1,o,n,i,s),t:k(e,o-1,n,i,s),b:k(e,o+1,n,i,s),current:k(e,o,n,i,s)}),y="";E.current?(y=!(y=y||E.l||E.r||E.t||E.b?"":"empty")&&E.l&&E.r||E.t&&E.b?"rect":"")||(y+=E.l?"l":E.r?"r":"",y=(y+=E.t?"t":E.b?"b":"")||"empty"):y=!(y=!(y=!(y=!y&&E.l&&E.t&&k(w-1,m-1,t.size,t.modules,r.isShowLogo)?"n_lt":"")&&E.l&&E.b&&k(w-1,m+1,t.size,t.modules,r.isShowLogo)?"n_lb":"")&&E.r&&E.t&&k(w+1,m-1,t.size,t.modules,r.isShowLogo)?"n_rt":"")&&E.r&&E.b&&k(w+1,m+1,t.size,t.modules,r.isShowLogo)?"n_rb":"",y&&(M='<use xlink:href="#'+y+"-"+r.suffix+'"/>',c.push('<g transform="translate('+v+","+C+')">'+M+"</g>"))}p+=96}var N="",R=(t.size-21)/2*96+672-10;t.size<=25&&(N="scale(0.85)",R+=50);var z=(t.size-7)*r.incTileSize;c.push('<use fill-rule="evenodd" transform="translate(0,0)" xlink:href="#point-'+r.suffix+'"/>'),c.push('<use fill-rule="evenodd" transform="translate('+z+',0)" xlink:href="#point-'+r.suffix+'"/>'),c.push('<use fill-rule="evenodd" transform="translate(0,'+z+')" xlink:href="#point-'+r.suffix+'"/>'),r.isShowLogo&&(r.logoData?c.push('\n <image\n preserveAspectRatio="xMidYMid slice" clip-path="url(#logo-mask-'+r.suffix+')"\n style="width: 750px; height: 750px;" width="750" height="750"\n transform="translate('+R+","+R+") "+N+'"\n xlink:href="'+r.logoData+'"\n />\n '):c.push('\n <use style="width: 750px; height: 750px;" width="750" height="750"\n fill="none"\n fill-rule="evenodd"\n transform="translate('+R+","+R+") "+N+'" xlink:href="#vk_logo-'+r.suffix+'"\n />\n '));var A=99*t.size,S="",x="translate(0,0)";if(r.isShowBackground){var L=(r.qrSize-40)/r.qrSize,_=A/r.qrSize*21;S='\n <rect\n x="0"\n width="'+A+'"\n height="'+A+'"\n rx="'+Math.ceil(A/(r.qrSize/36))+'"\n fill="'+r.backgroundColor+'"\n />',x="translate("+_+", "+_+") scale("+L+")"}var b="M0,0 L66,0 C84.7776815,-3.44940413e-15 100,15.2223185 100,34 L100,66 C100,"+l+" "+l+","+d+" 66,"+d+" L0,"+d+" L0,0 Z",I="M0,0 L100,0 L100,66 C100,"+l+" "+l+","+d+" 66,"+d+" L0,"+d+" L0,0 Z";return'\n <svg\n version="1.1"\n viewBox="0 0 '+A+" "+A+'"\n width="'+r.qrSize+'px"\n height="'+r.qrSize+'px"\n '+(r.className?'class="'+r.className+'"':"")+'\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"\n >\n <defs>\n <rect id="rect-'+r.suffix+'" width="100" height="100" fill="'+r.foregroundColor+'"/>\n <path\n id="empty-'+r.suffix+'"\n d="M0,'+f+"v42.9C0,87.3,"+a+","+d+","+f+","+d+"h42.9c15.9,0,"+f+"-"+a+","+f+"-"+f+"V"+f+"C"+d+",12.7,87.2,0,71.4,0H"+f+" C"+a+",0,0,"+a+",0,"+f+'z"\n fill="'+r.foregroundColor+'"\n />\n <path id="b-'+r.suffix+'" d="'+b+'" transform="rotate(-90 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="r-'+r.suffix+'" d="'+b+'" transform="rotate(-180 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="l-'+r.suffix+'" d="'+b+'" fill="'+r.foregroundColor+'"/>\n <path id="t-'+r.suffix+'" d="'+b+'" transform="rotate(90 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="l-'+r.suffix+'" d="'+I+'" transform="rotate(-90 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="lt-'+r.suffix+'" d="'+I+'" fill="'+r.foregroundColor+'"/>\n <path id="lb-'+r.suffix+'" d="'+I+'" transform="rotate(-90 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="rb-'+r.suffix+'" d="'+I+'" transform="rotate(-180 50 50)" fill="'+r.foregroundColor+'"/>\n <path id="rt-'+r.suffix+'" d="'+I+'" transform="rotate(90 50 50)" fill="'+r.foregroundColor+'"/>\n <path\n id="n_lt-'+r.suffix+'"\n d="M'+h+",2V0H0v"+h+"h2C2,14.7,14.8,2,"+h+',2z"\n fill="'+r.foregroundColor+'"\n />\n <path\n id="n_lb-'+r.suffix+'"\n d="M2,'+u+"H0V"+d+"h"+h+"v-2C14.7,98,2,85.2,2,"+u+'z"\n fill="'+r.foregroundColor+'"\n />\n <path\n id="n_rt-'+r.suffix+'"\n d="M98,'+h+"h2V0H"+u+"v2C85.3,2,98,14.8,98,"+h+'z"\n fill="'+r.foregroundColor+'"\n />\n <path id="n_rb-'+r.suffix+'"\n d="M'+u+",98v2H"+d+"V"+u+"h-2C98,85.3,85.2,98,"+u+',98z"\n fill="'+r.foregroundColor+'"\n />\n <path\n id="point-'+r.suffix+'"\n fill="'+r.foregroundColor+'"\n d="M600.001786,457.329333 L600.001786,242.658167 C600.001786,147.372368 587.039517,124.122784 581.464617,118.535383 C575.877216,112.960483 552.627632,99.9982143 457.329333,99.9982143 L242.670667,99.9982143 C147.372368,99.9982143 124.122784,112.960483 118.547883,118.535383 C112.972983,124.122784 99.9982143,147.372368 99.9982143,242.658167 L99.9982143,457.329333 C99.9982143,552.627632 112.972983,575.877216 118.547883,581.464617 C124.122784,587.027017 147.372368,600.001786 242.670667,600.001786 L457.329333,600.001786 C552.627632,600.001786 575.877216,587.027017 581.464617,581.464617 C587.039517,575.877216 600.001786,552.627632 600.001786,457.329333 Z M457.329333,0 C653.338333,0 700,46.6616668 700,242.658167 C700,438.667167 700,261.332833 700,457.329333 C700,653.338333 653.338333,700 457.329333,700 C261.332833,700 438.667167,700 242.670667,700 C46.6616668,700 0,653.338333 0,457.329333 C0,261.332833 0,352.118712 0,242.658167 C0,46.6616668 46.6616668,0 242.670667,0 C438.667167,0 261.332833,0 457.329333,0 Z M395.996667,200 C480.004166,200 500,220.008332 500,303.990835 C500,387.998334 500,312.001666 500,395.996667 C500,479.991668 480.004166,500 395.996667,500 C312.001666,500 387.998334,500 304.003333,500 C220.008332,500 200,479.991668 200,395.996667 C200,312.001666 200,350.906061 200,303.990835 C200,220.008332 220.008332,200 304.003333,200 C387.998334,200 312.001666,200 395.996667,200 Z"\n />\n <g id="vk_logo-'+r.suffix+'">\n <path\n fill="'+r.logoColor+'"\n d="M83.3334 363.333C83.3334 231.34 83.3334 165.343 124.338 124.338C165.343 83.3333 231.34 83.3333 363.333 83.3333H386.667C518.66 83.3333 584.657 83.3333 625.662 124.338C666.667 165.343 666.667 231.34 666.667 363.333V386.667C666.667 518.66 666.667 584.657 625.662 625.662C584.657 666.667 518.66 666.667 386.667 666.667H363.333C231.34 666.667 165.343 666.667 124.338 625.662C83.3334 584.657 83.3334 518.66 83.3334 386.667V363.333Z"\n />\n <path\n fill="#FFF"\n d="M394.907 508.681C263.293 508.681 183.442 417.365 180.313 265.625H246.972C249.05 377.09 299.763 424.323 338.638 434.036V265.625H402.519V361.82C440.016 357.664 479.264 313.909 492.456 265.625H555.333C545.27 325 502.543 368.754 472.353 386.803C502.566 401.395 551.177 439.593 569.926 508.681H500.815C486.222 462.498 450.476 426.728 402.542 421.872V508.681H394.907Z"\n />\n </g>\n <clipPath id="logo-mask-'+r.suffix+'">\n <rect x="0" y="0" width="750" height="750" />\n </clipPath>\n </defs>\n\n '+S+'\n\n <g transform="'+x+'">\n '+c.join("\n")+"\n </g>\n </svg>"}(h.encodeSegments(a,i[s.ecc],1,40,-1,!0),s)}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/vk-qr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "QR Code generator",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"browser": "dist/umd/qrCodeGenerator.js",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"@babel/core": "^7.5.4",
|
|
36
36
|
"@babel/preset-env": "^7.5.5",
|
|
37
37
|
"@babel/preset-typescript": "^7.3.3",
|
|
38
|
-
"@size-limit/preset-small-lib": "^
|
|
38
|
+
"@size-limit/preset-small-lib": "^11.0.0",
|
|
39
39
|
"@types/jest": "^24.0.15",
|
|
40
40
|
"@types/prettier": "^1.16.4",
|
|
41
41
|
"@typescript-eslint/eslint-plugin": "^2.0.0",
|
|
42
42
|
"@typescript-eslint/parser": "^2.0.0",
|
|
43
43
|
"babel-plugin-add-module-exports": "^0.2.1",
|
|
44
|
-
"convert-svg-to-png": "^0.
|
|
44
|
+
"convert-svg-to-png": "^0.6.4",
|
|
45
45
|
"cross-env": "^5.2.0",
|
|
46
46
|
"eslint": "^6.0.1",
|
|
47
47
|
"eslint-plugin-babel": "^4.1.2",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
61
61
|
"rollup-plugin-typescript2": "^0.22.0",
|
|
62
62
|
"rollup-plugin-uglify": "^6.0.2",
|
|
63
|
-
"size-limit": "^
|
|
63
|
+
"size-limit": "^11.0.0",
|
|
64
64
|
"ts-node": "^8.3.0",
|
|
65
65
|
"typescript": "^3.5.3",
|
|
66
66
|
"xml-js": "^1.6.11"
|
|
@@ -75,5 +75,8 @@
|
|
|
75
75
|
{
|
|
76
76
|
"path": "dist/umd/qrCodeGenerator.js"
|
|
77
77
|
}
|
|
78
|
-
]
|
|
78
|
+
],
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public"
|
|
81
|
+
}
|
|
79
82
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { convertSegmentsToSvgString } from './svg';
|
|
1
|
+
import { convertSegmentsToSvgString, INC_TILE_SIZE } from './svg';
|
|
2
2
|
import { QrSegment, QrCode } from './qr';
|
|
3
3
|
import { QrOptions } from './types';
|
|
4
4
|
import Ecc = QrCode.Ecc;
|
|
@@ -13,7 +13,7 @@ const BACKGROUND_COLOR_DEFAULT = '#ffffff';
|
|
|
13
13
|
const FOREGROUND_COLOR_DEFAULT = '#000000';
|
|
14
14
|
|
|
15
15
|
/** Default logo color */
|
|
16
|
-
const LOGO_COLOR_DEFAULT = '#
|
|
16
|
+
const LOGO_COLOR_DEFAULT = '#07f';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Generates SVG QR code by a text
|
|
@@ -79,6 +79,7 @@ function createQR(
|
|
|
79
79
|
suffix: options.suffix ? options.suffix.toString() : '0',
|
|
80
80
|
logoData: typeof options.logoData === 'string' ? options.logoData : null,
|
|
81
81
|
ecc: (typeof options.ecc === 'number' && eccLevels[options.ecc] ? options.ecc : 3),
|
|
82
|
+
incTileSize: typeof options.incTileSize === 'number' ? options.incTileSize : INC_TILE_SIZE,
|
|
82
83
|
};
|
|
83
84
|
|
|
84
85
|
// Code generation
|
package/src/svg.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { QrOptions } from './types';
|
|
|
4
4
|
const MULTI = 1;
|
|
5
5
|
const QR_BORDER = 7;
|
|
6
6
|
const TILE_SIZE = 96 * MULTI;
|
|
7
|
-
const INC_TILE_SIZE = 96 * MULTI;
|
|
7
|
+
export const INC_TILE_SIZE = 96 * MULTI;
|
|
8
8
|
const SMALL_QR_SIZE = 25;
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -167,7 +167,7 @@ export const convertSegmentsToSvgString = (qrCode: QrCode, options: Required<QrO
|
|
|
167
167
|
position += 50;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
const pointPosition = (qrCode.size - QR_BORDER) *
|
|
170
|
+
const pointPosition = (qrCode.size - QR_BORDER) * options.incTileSize;
|
|
171
171
|
parts.push(`<use fill-rule="evenodd" transform="translate(0,0)" xlink:href="#point-${options.suffix}"/>`);
|
|
172
172
|
parts.push(
|
|
173
173
|
`<use fill-rule="evenodd" transform="translate(${pointPosition},0)" xlink:href="#point-${options.suffix}"/>`
|
|
@@ -179,19 +179,19 @@ export const convertSegmentsToSvgString = (qrCode: QrCode, options: Required<QrO
|
|
|
179
179
|
if (options.isShowLogo) {
|
|
180
180
|
if (!options.logoData) {
|
|
181
181
|
parts.push(`
|
|
182
|
-
<use style="width: 750px; height: 750px;" width="750" height="750"
|
|
183
|
-
fill="none"
|
|
184
|
-
fill-rule="evenodd"
|
|
182
|
+
<use style="width: 750px; height: 750px;" width="750" height="750"
|
|
183
|
+
fill="none"
|
|
184
|
+
fill-rule="evenodd"
|
|
185
185
|
transform="translate(${position},${position}) ${scale}" xlink:href="#vk_logo-${options.suffix}"
|
|
186
186
|
/>
|
|
187
187
|
`);
|
|
188
188
|
} else {
|
|
189
189
|
parts.push(`
|
|
190
|
-
<image
|
|
190
|
+
<image
|
|
191
191
|
preserveAspectRatio="xMidYMid slice" clip-path="url(#logo-mask-${options.suffix})"
|
|
192
|
-
style="width: 750px; height: 750px;" width="750" height="750"
|
|
193
|
-
transform="translate(${position},${position}) ${scale}"
|
|
194
|
-
xlink:href="${options.logoData}"
|
|
192
|
+
style="width: 750px; height: 750px;" width="750" height="750"
|
|
193
|
+
transform="translate(${position},${position}) ${scale}"
|
|
194
|
+
xlink:href="${options.logoData}"
|
|
195
195
|
/>
|
|
196
196
|
`);
|
|
197
197
|
}
|
|
@@ -207,11 +207,11 @@ export const convertSegmentsToSvgString = (qrCode: QrCode, options: Required<QrO
|
|
|
207
207
|
const radius = Math.ceil(backgroundSize / (options.qrSize / 36)); // 7.11111111 = 256px/36px radius
|
|
208
208
|
|
|
209
209
|
qrBackground = `
|
|
210
|
-
<rect
|
|
211
|
-
x="0"
|
|
212
|
-
width="${backgroundSize}"
|
|
213
|
-
height="${backgroundSize}"
|
|
214
|
-
rx="${radius}"
|
|
210
|
+
<rect
|
|
211
|
+
x="0"
|
|
212
|
+
width="${backgroundSize}"
|
|
213
|
+
height="${backgroundSize}"
|
|
214
|
+
rx="${radius}"
|
|
215
215
|
fill="${options.backgroundColor}"
|
|
216
216
|
/>`;
|
|
217
217
|
qrTransform = `translate(${padding}, ${padding}) scale(${qrScale})`;
|
|
@@ -223,18 +223,18 @@ ${_84_7},${_100} 66,${_100} L0,${_100} L0,0 Z`;
|
|
|
223
223
|
const twoSides = `M0,0 L${_100},0 L${_100},66 C${_100},${_84_7} ${_84_7},${_100} 66,${_100} L0,${_100} L0,0 Z`;
|
|
224
224
|
|
|
225
225
|
return `
|
|
226
|
-
<svg
|
|
227
|
-
version="1.1"
|
|
228
|
-
viewBox="0 0 ${backgroundSize} ${backgroundSize}"
|
|
229
|
-
width="${options.qrSize}px"
|
|
226
|
+
<svg
|
|
227
|
+
version="1.1"
|
|
228
|
+
viewBox="0 0 ${backgroundSize} ${backgroundSize}"
|
|
229
|
+
width="${options.qrSize}px"
|
|
230
230
|
height="${options.qrSize}px"
|
|
231
|
-
${options.className ? `class="${options.className}"` : ''}
|
|
231
|
+
${options.className ? `class="${options.className}"` : ''}
|
|
232
232
|
xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
233
233
|
>
|
|
234
234
|
<defs>
|
|
235
235
|
<rect id="rect-${options.suffix}" width="100" height="100" fill="${options.foregroundColor}"/>
|
|
236
|
-
<path
|
|
237
|
-
id="empty-${options.suffix}"
|
|
236
|
+
<path
|
|
237
|
+
id="empty-${options.suffix}"
|
|
238
238
|
d="M0,${_28_6}v${_42_9}C0,${_87_3},${_12_8},${_100},${_28_6},${_100}h${_42_9}c${_15_9},0,${_28_6}-${_12_8},\
|
|
239
239
|
${_28_6}-${_28_6}V${_28_6}C${_100},${_12_7},${_87_2},0,${_71_4},0H${_28_6} C${_12_8},0,0,${_12_8},0,${_28_6}z"
|
|
240
240
|
fill="${options.foregroundColor}"
|
|
@@ -248,27 +248,27 @@ ${_28_6}-${_28_6}V${_28_6}C${_100},${_12_7},${_87_2},0,${_71_4},0H${_28_6} C${_1
|
|
|
248
248
|
<path id="lb-${options.suffix}" d="${twoSides}" transform="rotate(-90 50 50)" fill="${options.foregroundColor}"/>
|
|
249
249
|
<path id="rb-${options.suffix}" d="${twoSides}" transform="rotate(-180 50 50)" fill="${options.foregroundColor}"/>
|
|
250
250
|
<path id="rt-${options.suffix}" d="${twoSides}" transform="rotate(90 50 50)" fill="${options.foregroundColor}"/>
|
|
251
|
-
<path
|
|
252
|
-
id="n_lt-${options.suffix}"
|
|
253
|
-
d="M${_30_5},${_2}V0H0v${_30_5}h${_2}C${_2},${_14_7},${_14_8},${_2},${_30_5},${_2}z"
|
|
251
|
+
<path
|
|
252
|
+
id="n_lt-${options.suffix}"
|
|
253
|
+
d="M${_30_5},${_2}V0H0v${_30_5}h${_2}C${_2},${_14_7},${_14_8},${_2},${_30_5},${_2}z"
|
|
254
254
|
fill="${options.foregroundColor}"
|
|
255
255
|
/>
|
|
256
|
-
<path
|
|
256
|
+
<path
|
|
257
257
|
id="n_lb-${options.suffix}"
|
|
258
|
-
d="M${_2},${_69_5}H0V${_100}h${_30_5}v-${_2}C${_14_7},${_98},${_2},${_85_2},${_2},${_69_5}z"
|
|
258
|
+
d="M${_2},${_69_5}H0V${_100}h${_30_5}v-${_2}C${_14_7},${_98},${_2},${_85_2},${_2},${_69_5}z"
|
|
259
259
|
fill="${options.foregroundColor}"
|
|
260
260
|
/>
|
|
261
|
-
<path
|
|
262
|
-
id="n_rt-${options.suffix}"
|
|
263
|
-
d="M${_98},${_30_5}h${_2}V0H${_69_5}v${_2}C${_85_3},${_2},${_98},${_14_8},${_98},${_30_5}z"
|
|
261
|
+
<path
|
|
262
|
+
id="n_rt-${options.suffix}"
|
|
263
|
+
d="M${_98},${_30_5}h${_2}V0H${_69_5}v${_2}C${_85_3},${_2},${_98},${_14_8},${_98},${_30_5}z"
|
|
264
264
|
fill="${options.foregroundColor}"
|
|
265
265
|
/>
|
|
266
|
-
<path id="n_rb-${options.suffix}"
|
|
267
|
-
d="M${_69_5},${_98}v${_2}H${_100}V${_69_5}h-${_2}C${_98},${_85_3},${_85_2},${_98},${_69_5},${_98}z"
|
|
266
|
+
<path id="n_rb-${options.suffix}"
|
|
267
|
+
d="M${_69_5},${_98}v${_2}H${_100}V${_69_5}h-${_2}C${_98},${_85_3},${_85_2},${_98},${_69_5},${_98}z"
|
|
268
268
|
fill="${options.foregroundColor}"
|
|
269
269
|
/>
|
|
270
|
-
<path
|
|
271
|
-
id="point-${options.suffix}"
|
|
270
|
+
<path
|
|
271
|
+
id="point-${options.suffix}"
|
|
272
272
|
fill="${options.foregroundColor}"
|
|
273
273
|
d="M600.001786,457.329333 L600.001786,242.658167 C600.001786,147.372368 587.039517,124.122784 \
|
|
274
274
|
581.464617,118.535383 C575.877216,112.960483 552.627632,99.9982143 457.329333,99.9982143 \
|
|
@@ -284,34 +284,23 @@ C0,46.6616668 46.6616668,0 242.670667,0 C438.667167,0 261.332833,0 457.329333,0
|
|
|
284
284
|
C480.004166,200 500,220.008332 500,303.990835 C500,387.998334 500,312.001666 500,395.996667 \
|
|
285
285
|
C500,479.991668 480.004166,500 395.996667,500 C312.001666,500 387.998334,500 304.003333,500 C220.008332,500 \
|
|
286
286
|
200,479.991668 200,395.996667 C200,312.001666 200,350.906061 200,303.990835 C200,220.008332 220.008332,200 \
|
|
287
|
-
304.003333,200 C387.998334,200 312.001666,200 395.996667,200 Z"
|
|
287
|
+
304.003333,200 C387.998334,200 312.001666,200 395.996667,200 Z"
|
|
288
288
|
/>
|
|
289
289
|
<g id="vk_logo-${options.suffix}">
|
|
290
|
-
<path
|
|
291
|
-
fill="${options.logoColor}"
|
|
292
|
-
d="
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
243.763595,328.456052 217.730151,252.620844 C212.628223,237.881107 207.511068,231.927083 \
|
|
305
|
-
193.907178,231.927083 L140.678012,231.927083 C125.469678,231.927083 122.427826,239.08642 \
|
|
306
|
-
122.427826,246.981031 C122.427826,261.079625 140.473725,331.006546 206.452402,423.489903 \
|
|
307
|
-
C250.437874,486.648674 312.410515,520.885417 368.803012,520.885417 C402.638134,520.885417 \
|
|
308
|
-
406.823845,513.28125 406.823845,500.183098 L406.823845,452.447917 C406.823845,437.239583 \
|
|
309
|
-
410.029185,434.204421 420.743703,434.204421 C428.638315,434.204421 442.172739,438.151727 \
|
|
310
|
-
473.753063,468.603713 C509.843923,504.694573 515.79398,520.885417 536.094678,520.885417 \
|
|
311
|
-
L589.323845,520.885417 C604.532178,520.885417 612.136345,513.28125 607.749619,498.274853 \
|
|
312
|
-
C602.949226,483.318593 585.717788,461.619053 562.853283,435.89599 C550.446258,421.234166 \
|
|
313
|
-
531.837128,405.444943 526.197316,397.548454 C518.302704,387.399043 520.558441,382.88663 \
|
|
314
|
-
526.197316,373.864619 C526.197316,373.864619 591.049532,282.508661 597.816744,251.493445 Z"
|
|
290
|
+
<path
|
|
291
|
+
fill="${options.logoColor}"
|
|
292
|
+
d="M83.3334 363.333C83.3334 231.34 83.3334 165.343 124.338 124.338C165.343 83.3333 231.34 \
|
|
293
|
+
83.3333 363.333 83.3333H386.667C518.66 83.3333 584.657 83.3333 625.662 124.338C666.667 165.343 \
|
|
294
|
+
666.667 231.34 666.667 363.333V386.667C666.667 518.66 666.667 584.657 625.662 625.662C584.657 \
|
|
295
|
+
666.667 518.66 666.667 386.667 666.667H363.333C231.34 666.667 165.343 666.667 124.338 625.662C83.3334 \
|
|
296
|
+
584.657 83.3334 518.66 83.3334 386.667V363.333Z"
|
|
297
|
+
/>
|
|
298
|
+
<path
|
|
299
|
+
fill="#FFF"
|
|
300
|
+
d="M394.907 508.681C263.293 508.681 183.442 417.365 180.313 265.625H246.972C249.05 377.09 \
|
|
301
|
+
299.763 424.323 338.638 434.036V265.625H402.519V361.82C440.016 357.664 479.264 313.909 \
|
|
302
|
+
492.456 265.625H555.333C545.27 325 502.543 368.754 472.353 386.803C502.566 401.395 551.177 \
|
|
303
|
+
439.593 569.926 508.681H500.815C486.222 462.498 450.476 426.728 402.542 421.872V508.681H394.907Z"
|
|
315
304
|
/>
|
|
316
305
|
</g>
|
|
317
306
|
<clipPath id="logo-mask-${options.suffix}">
|