@qr-platform/qr-code.js 0.8.17
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/.github/workflows/publish.yml +18 -0
- package/CHANGELOG.md +233 -0
- package/LICENSE.md +77 -0
- package/README.md +188 -0
- package/docs/advanced-examples.md +523 -0
- package/docs/api-reference-guide.md +254 -0
- package/docs/documentation.md +1592 -0
- package/docs/examples.md +322 -0
- package/docs/license-management.md +501 -0
- package/docs/typescript-types-definitions.md +372 -0
- package/docs/usage-guide.md +622 -0
- package/lib/core/qr-code-js.d.ts +48 -0
- package/lib/core/qr-constant.d.ts +9 -0
- package/lib/core/qr-options-validation.d.ts +13 -0
- package/lib/core/qr-svg.d.ts +76 -0
- package/lib/core/qr-templates.d.ts +6 -0
- package/lib/figures/corner-dot.d.ts +24 -0
- package/lib/figures/corner-square.d.ts +24 -0
- package/lib/figures/dot.d.ts +31 -0
- package/lib/index.d.ts +52 -0
- package/lib/lib/image/GIFImage.d.ts +19 -0
- package/lib/lib/io/Base64.d.ts +10 -0
- package/lib/lib/io/Base64DecodeInputStream.d.ts +15 -0
- package/lib/lib/io/Base64EncodeOutputStream.d.ts +17 -0
- package/lib/lib/io/ByteArrayInputStream.d.ts +12 -0
- package/lib/lib/io/ByteArrayOutputStream.d.ts +12 -0
- package/lib/lib/io/InputStream.d.ts +10 -0
- package/lib/lib/io/OutputStream.d.ts +12 -0
- package/lib/lib/qr-code.d.ts +5 -0
- package/lib/lib/qrcode/BitBuffer.d.ts +11 -0
- package/lib/lib/qrcode/ErrorCorrectLevel.d.ts +23 -0
- package/lib/lib/qrcode/MaskPattern.d.ts +39 -0
- package/lib/lib/qrcode/Mode.d.ts +23 -0
- package/lib/lib/qrcode/Polynomial.d.ts +15 -0
- package/lib/lib/qrcode/QR8BitByte.d.ts +13 -0
- package/lib/lib/qrcode/QRAlphaNum.d.ts +13 -0
- package/lib/lib/qrcode/QRCode.d.ts +22 -0
- package/lib/lib/qrcode/QRCodeMinimal.d.ts +58 -0
- package/lib/lib/qrcode/QRData.d.ts +17 -0
- package/lib/lib/qrcode/QRKanji.d.ts +13 -0
- package/lib/lib/qrcode/QRMath.d.ts +13 -0
- package/lib/lib/qrcode/QRNumber.d.ts +14 -0
- package/lib/lib/qrcode/QRUtil.d.ts +25 -0
- package/lib/lib/qrcode/RSBlock.d.ts +16 -0
- package/lib/lib/text/createStringToBytes.d.ts +9 -0
- package/lib/lib/text/stringToBytes_SJIS.d.ts +8 -0
- package/lib/lib/text/stringToBytes_UTF8.d.ts +7 -0
- package/lib/lib/zbar-wasm/index.d.ts +1 -0
- package/lib/lib/zxing-js/src/browser/BrowserCodeReader.d.ts +410 -0
- package/lib/lib/zxing-js/src/browser/BrowserQRCodeReader.d.ts +29 -0
- package/lib/lib/zxing-js/src/browser/BrowserQRCodeSvgWriter.d.ts +46 -0
- package/lib/lib/zxing-js/src/browser/BrowserSvgCodeWriter.d.ts +49 -0
- package/lib/lib/zxing-js/src/browser/DecodeContinuouslyCallback.d.ts +6 -0
- package/lib/lib/zxing-js/src/browser/HTMLCanvasElementLuminanceSource.d.ts +27 -0
- package/lib/lib/zxing-js/src/browser/HTMLVisualMediaElement.d.ts +4 -0
- package/lib/lib/zxing-js/src/browser/VideoInputDevice.d.ts +22 -0
- package/lib/lib/zxing-js/src/browser.d.ts +3 -0
- package/lib/lib/zxing-js/src/core/ArgumentException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/ArithmeticException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/ArrayIndexOutOfBoundsException.d.ts +10 -0
- package/lib/lib/zxing-js/src/core/BarcodeFormat.d.ts +42 -0
- package/lib/lib/zxing-js/src/core/Binarizer.d.ts +53 -0
- package/lib/lib/zxing-js/src/core/BinaryBitmap.d.ts +78 -0
- package/lib/lib/zxing-js/src/core/ChecksumException.d.ts +8 -0
- package/lib/lib/zxing-js/src/core/DecodeHintType.d.ts +91 -0
- package/lib/lib/zxing-js/src/core/Dimension.d.ts +13 -0
- package/lib/lib/zxing-js/src/core/EncodeHintType.d.ts +99 -0
- package/lib/lib/zxing-js/src/core/Exception.d.ts +17 -0
- package/lib/lib/zxing-js/src/core/FormatException.d.ts +8 -0
- package/lib/lib/zxing-js/src/core/HighContrastLuminanceSource.d.ts +27 -0
- package/lib/lib/zxing-js/src/core/IllegalArgumentException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/IllegalStateException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/IndexOutOfBoundsException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/InvertedLuminanceSource.d.ts +22 -0
- package/lib/lib/zxing-js/src/core/LuminanceSource.d.ts +84 -0
- package/lib/lib/zxing-js/src/core/NodeLuminanceSource.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/NotFoundException.d.ts +8 -0
- package/lib/lib/zxing-js/src/core/NullPointerException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/OutOfMemoryError.d.ts +6 -0
- package/lib/lib/zxing-js/src/core/PlanarYUVLuminanceSource.d.ts +35 -0
- package/lib/lib/zxing-js/src/core/RGBLuminanceSource.d.ts +21 -0
- package/lib/lib/zxing-js/src/core/Reader.d.ts +49 -0
- package/lib/lib/zxing-js/src/core/ReaderException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/ReedSolomonException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/Result.d.ts +52 -0
- package/lib/lib/zxing-js/src/core/ResultMetadataType.d.ts +68 -0
- package/lib/lib/zxing-js/src/core/ResultPoint.d.ts +34 -0
- package/lib/lib/zxing-js/src/core/ResultPointCallback.d.ts +11 -0
- package/lib/lib/zxing-js/src/core/UniversalLuminanceSource.d.ts +46 -0
- package/lib/lib/zxing-js/src/core/UnsupportedOperationException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/Writer.d.ts +30 -0
- package/lib/lib/zxing-js/src/core/WriterException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/common/BitArray.d.ts +111 -0
- package/lib/lib/zxing-js/src/core/common/BitMatrix.d.ts +98 -0
- package/lib/lib/zxing-js/src/core/common/BitSource.d.ts +38 -0
- package/lib/lib/zxing-js/src/core/common/CharacterSetECI.d.ts +89 -0
- package/lib/lib/zxing-js/src/core/common/DecoderResult.d.ts +64 -0
- package/lib/lib/zxing-js/src/core/common/DefaultGridSampler.d.ts +10 -0
- package/lib/lib/zxing-js/src/core/common/DetectorResult.d.ts +16 -0
- package/lib/lib/zxing-js/src/core/common/ECIEncoderSet.d.ts +37 -0
- package/lib/lib/zxing-js/src/core/common/ECIInput.d.ts +79 -0
- package/lib/lib/zxing-js/src/core/common/GlobalHistogramBinarizer.d.ts +29 -0
- package/lib/lib/zxing-js/src/core/common/GridSampler.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/common/GridSamplerInstance.d.ts +18 -0
- package/lib/lib/zxing-js/src/core/common/HybridBinarizer.d.ts +54 -0
- package/lib/lib/zxing-js/src/core/common/MinimalECIInput.d.ts +123 -0
- package/lib/lib/zxing-js/src/core/common/PerspectiveTransform.d.ts +26 -0
- package/lib/lib/zxing-js/src/core/common/StringUtils.d.ts +48 -0
- package/lib/lib/zxing-js/src/core/common/detector/CornerDetector.d.ts +35 -0
- package/lib/lib/zxing-js/src/core/common/detector/MathUtils.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/common/detector/WhiteRectangleDetector.d.ts +71 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGF.d.ts +34 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGFPoly.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/GenericGF.d.ts +58 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/GenericGFPoly.d.ts +47 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonDecoder.d.ts +40 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonEncoder.d.ts +41 -0
- package/lib/lib/zxing-js/src/core/qrcode/QRCodeReader.d.ts +35 -0
- package/lib/lib/zxing-js/src/core/qrcode/QRCodeWriter.d.ts +13 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/BitMatrixParser.d.ts +58 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/DataBlock.d.ts +28 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/DataMask.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/DecodedBitStreamParser.d.ts +30 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/Decoder.d.ts +44 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/ECB.d.ts +12 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/ECBlocks.d.ts +16 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/ErrorCorrectionLevel.d.ts +38 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/FormatInformation.d.ts +33 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/Mode.d.ts +56 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/QRCodeDecoderMetaData.d.ts +21 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/Version.d.ts +44 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/AlignmentPattern.d.ts +21 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/AlignmentPatternFinder.d.ts +82 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/Detector.d.ts +87 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/FinderPattern.d.ts +26 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/FinderPatternFinder.d.ts +114 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/FinderPatternInfo.d.ts +16 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/BlockPair.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/ByteMatrix.d.ts +24 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/Encoder.d.ts +85 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/MaskUtil.d.ts +47 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/MatrixUtil.d.ts +37 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/QRCode.d.ts +29 -0
- package/lib/lib/zxing-js/src/core/util/Arrays.d.ts +45 -0
- package/lib/lib/zxing-js/src/core/util/ByteArrayOutputStream.d.ts +174 -0
- package/lib/lib/zxing-js/src/core/util/Charset.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/util/Collections.d.ts +11 -0
- package/lib/lib/zxing-js/src/core/util/Float.d.ts +14 -0
- package/lib/lib/zxing-js/src/core/util/Formatter.d.ts +28 -0
- package/lib/lib/zxing-js/src/core/util/Integer.d.ts +19 -0
- package/lib/lib/zxing-js/src/core/util/Long.d.ts +12 -0
- package/lib/lib/zxing-js/src/core/util/OutputStream.d.ts +106 -0
- package/lib/lib/zxing-js/src/core/util/StandardCharsets.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/util/StringBuilder.d.ts +21 -0
- package/lib/lib/zxing-js/src/core/util/StringEncoding.d.ts +51 -0
- package/lib/lib/zxing-js/src/core/util/System.d.ts +10 -0
- package/lib/lib/zxing-js/src/customTypings.d.ts +16 -0
- package/lib/lib/zxing-js/src/index.d.ts +5 -0
- package/lib/lib/zxing-js/src/node.d.ts +1 -0
- package/lib/license/LicenseManager.d.ts +69 -0
- package/lib/license/LicenseManagerNode.d.ts +64 -0
- package/lib/node.d.ts +37 -0
- package/lib/options-demo.d.ts +239 -0
- package/lib/plugins/QRBorderHelpers.d.ts +32 -0
- package/lib/plugins/QRBorderPlugin.d.ts +35 -0
- package/lib/plugins/QRValidatorZbar.d.ts +38 -0
- package/lib/plugins/QRValidatorZbarNode.d.ts +60 -0
- package/lib/plugins/QRValidatorZbarNodeSharp.d.ts +83 -0
- package/lib/qr-code-js-node.js +1 -0
- package/lib/qr-code-js.js +1 -0
- package/lib/templates/borders-inner-outter.d.ts +129 -0
- package/lib/templates/borders-inner-scale-offset.d.ts +497 -0
- package/lib/templates/borders-inner.d.ts +129 -0
- package/lib/templates/borders-no-license.d.ts +129 -0
- package/lib/templates/borders-outter.d.ts +129 -0
- package/lib/templates/borders-text-auto-curved.d.ts +129 -0
- package/lib/templates/borders-text-full-curved.d.ts +133 -0
- package/lib/templates/borders.d.ts +129 -0
- package/lib/templates/scales.d.ts +130 -0
- package/lib/templates/scan-validators/index.d.ts +1 -0
- package/lib/templates/scan-validators/tests/cases/basic-inverted.d.ts +9 -0
- package/lib/templates/scan-validators/tests/cases/basic-no-license.d.ts +3 -0
- package/lib/templates/scan-validators/tests/cases/basic.d.ts +3 -0
- package/lib/templates/scan-validators/tests/cases/colors-inverted.d.ts +2 -0
- package/lib/templates/scan-validators/tests/cases/colors.d.ts +58 -0
- package/lib/templates/scan-validators/tests/cases/out-of-borders-inverted.d.ts +9 -0
- package/lib/templates/scan-validators/tests/cases/out-of-borders.d.ts +9 -0
- package/lib/templates/scan-validators/tests/cases/position-inverted.d.ts +9 -0
- package/lib/templates/scan-validators/tests/cases/position.d.ts +3 -0
- package/lib/templates/scan-validators/tests/index.d.ts +27 -0
- package/lib/tools/browser-image-tools.d.ts +7 -0
- package/lib/tools/browser-utils.d.ts +18 -0
- package/lib/types/helper.d.ts +23 -0
- package/lib/utils/canvas-options.d.ts +7 -0
- package/lib/utils/color.d.ts +4 -0
- package/lib/utils/gradient.d.ts +26 -0
- package/lib/utils/image.d.ts +16 -0
- package/lib/utils/merge.d.ts +5 -0
- package/lib/utils/options.d.ts +220 -0
- package/lib/utils/qrcode.d.ts +8 -0
- package/lib/utils/scan-validator-node.d.ts +15 -0
- package/lib/utils/scan-validators/abstract-scan-validator.d.ts +43 -0
- package/lib/utils/scan-validators/zbar-scan-validator.d.ts +8 -0
- package/lib/utils/scan-validators/zxing-canvas-scan-validator.d.ts +10 -0
- package/lib/utils/scan-validators/zxing-scan-validator.d.ts +8 -0
- package/lib/utils/svg.d.ts +2 -0
- package/lib/utils/token-validator.d.ts +19 -0
- package/package.json +80 -0
@@ -0,0 +1,622 @@
|
|
1
|
+
# QRCode.js Usage Guide
|
2
|
+
<a id="start"></a>
|
3
|
+
|
4
|
+
## Introduction
|
5
|
+
|
6
|
+
QRCode.js is a powerful JavaScript library for creating highly customizable QR codes in both browser and Node.js environments. It allows you to control aspects like shape, colors, dot styles, corner styles, embedded images, borders, gradients, text, and more. This guide provides a complete overview of all available options to help you create the perfect QR code for your needs. QRCode.js is part of QR-Platform: All-in-One QR Codes Management Solution.
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
```bash
|
13
|
+
# Using npm
|
14
|
+
npm install @qr-platform/qr-code.js
|
15
|
+
|
16
|
+
# Using yarn
|
17
|
+
yarn add @qr-platform/qr-code.js
|
18
|
+
|
19
|
+
# Using pnpm
|
20
|
+
pnpm add @qr-platform/qr-code.js
|
21
|
+
```
|
22
|
+
|
23
|
+
## Basic Usage
|
24
|
+
|
25
|
+
```typescript
|
26
|
+
import { QRCodeJs } from '@qr-platform/qr-code.js';
|
27
|
+
|
28
|
+
// Create a basic QR code
|
29
|
+
const qrCode = new QRCodeJs({
|
30
|
+
data: 'https://example.com',
|
31
|
+
});
|
32
|
+
|
33
|
+
// Render the QR code to a container
|
34
|
+
qrCode.append(document.getElementById('qr-container'));
|
35
|
+
```
|
36
|
+
|
37
|
+
## QRCode.js Options
|
38
|
+
|
39
|
+
The following sections detail all configuration options for generating QR codes with QRCode.js, grouped by functionality.
|
40
|
+
|
41
|
+
### Core Options
|
42
|
+
|
43
|
+
These options define the essential properties for generating a QR code, including the data to encode and the algorithm settings.
|
44
|
+
|
45
|
+
| Option | Type | Default | Description |
|
46
|
+
| :--------------------- | :------------------------------------- | :------------- | :-------------------------------------------------------------------------- |
|
47
|
+
| `data` | `string` | - | Specifies the text, URL, or other data to encode into the QR code. **Required option** |
|
48
|
+
| `shape` | `'square' \| 'circle'` | `'square'` | The overall shape of the QR code's boundary. |
|
49
|
+
| `qrOptions` | `object` | `{...}` | Options related to the underlying QR code generation algorithm. |
|
50
|
+
| `qrOptions.typeNumber` | `number` (0-40) | `0` | Specifies the QR code version (size/capacity). `0` means automatic detection. |
|
51
|
+
| `qrOptions.mode` | `Mode` enum | Auto-detected | The encoding mode (e.g., `Byte`, `Numeric`, `Kanji`). Usually auto-detected. |
|
52
|
+
| `qrOptions.errorCorrectionLevel` | `'L' \| 'M' \| 'Q' \| 'H'` | `'Q'` | The error correction level, determining redundancy. |
|
53
|
+
|
54
|
+
##### Example: Core Options
|
55
|
+
|
56
|
+
```javascript
|
57
|
+
const qrCode = new QRCodeJs({
|
58
|
+
data: 'This QR code uses High error correction',
|
59
|
+
shape: 'circle',
|
60
|
+
qrOptions: {
|
61
|
+
errorCorrectionLevel: 'H' // L, M, Q, H
|
62
|
+
}
|
63
|
+
});
|
64
|
+
```
|
65
|
+
---
|
66
|
+
|
67
|
+
### Layout Options
|
68
|
+
|
69
|
+
These options control the positioning, scaling, and responsiveness of the QR code within its container or border.
|
70
|
+
|
71
|
+
| Option | Type | Default | Description |
|
72
|
+
| :----------------- | :------- | :------ | :-------------------------------------------------------------------------- |
|
73
|
+
| `margin` | `number` | `0` | The quiet zone (empty space) around the QR code in pixels. |
|
74
|
+
| `isResponsive` | `boolean`| `false` | When `true`, the QR code SVG resizes dynamically to fill the width or height of the parent container, with no internal size dimensions applied. |
|
75
|
+
| `scale` | `number` | `1` | Scales the QR code size relative to its container or border (0 to 1.5). |
|
76
|
+
| `offset` | `number` | `0` | Applies a vertical offset (positive moves down, negative moves up) relative to the center. |
|
77
|
+
| `verticalOffset` | `number` | `0` | Applies an absolute vertical offset in pixels. |
|
78
|
+
| `horizontalOffset` | `number` | `0` | Applies an absolute horizontal offset in pixels. |
|
79
|
+
|
80
|
+
##### Example: Layout Options
|
81
|
+
|
82
|
+
```javascript
|
83
|
+
const qrCode = new QRCodeJs({
|
84
|
+
data: 'Scaled and Offset QR Code',
|
85
|
+
scale: 0.8, // 80% of the available space
|
86
|
+
offset: -10, // Move QR code 10px up relative to center
|
87
|
+
verticalOffset: 5, // Absolute 5px down
|
88
|
+
horizontalOffset: -5 // Absolute 5px left
|
89
|
+
});
|
90
|
+
```
|
91
|
+
---
|
92
|
+
|
93
|
+
### Styling Options
|
94
|
+
|
95
|
+
These options allow customization of the QR code’s visual appearance, covering dots, corner squares, corner dots, background, gradients, and image embedding. Each option is an `object` with properties that define the appearance of specific elements within the QR code.
|
96
|
+
|
97
|
+
#### Dots
|
98
|
+
|
99
|
+
`dotsOptions` is an `object` that defines the appearance of individual data modules (dots) within the QR code.
|
100
|
+
|
101
|
+
| Option | Type | Default | Description |
|
102
|
+
| :------------------ | :------------ | :------------- | :--------------------------------------------------------------------------------------------------------- |
|
103
|
+
| `dotsOptions.type` | `DotType` enum | `'square'` | The shape of the dots. |
|
104
|
+
| `dotsOptions.color` | `string` | `'#000000'` | The color of the dots. Accepts any valid CSS color string (e.g., `'#FF0000'`, `'red'`, `'rgba(255, 0, 0, 0.5)'`). |
|
105
|
+
| `dotsOptions.size` | `number` | `10` | The size of each dot in pixels. |
|
106
|
+
| `dotsOptions.gradient` | `Gradient` object | `undefined` | Apply a gradient fill to the dots. See [Gradients](#gradients) for configuration details. |
|
107
|
+
|
108
|
+
**`DotType` Enum Values:** `dot`, `randomDot`, `rounded`, `extraRounded`, `verticalLine`, `horizontalLine`, `classy`, `classyRounded`, `square`, `smallSquare`, `tinySquare`, `star`, `plus`, `diamond`.
|
109
|
+
|
110
|
+
##### Example: Dot Styling
|
111
|
+
|
112
|
+
```javascript
|
113
|
+
const qrCode = new QRCodeJs({
|
114
|
+
data: 'Styled Dots Example',
|
115
|
+
dotsOptions: {
|
116
|
+
type: 'rounded', // Use rounded dots
|
117
|
+
color: '#ff0000', // Red dots
|
118
|
+
size: 12 // Slightly larger dots
|
119
|
+
}
|
120
|
+
});
|
121
|
+
```
|
122
|
+
---
|
123
|
+
|
124
|
+
#### Corner Squares
|
125
|
+
|
126
|
+
`cornersSquareOptions` is an `object` that defines the appearance of the three large corner squares.
|
127
|
+
|
128
|
+
| Option | Type | Default | Description |
|
129
|
+
| :----------------------------- | :------------------- | :------------- | :--------------------------------------------------------------------------------------------------------------- |
|
130
|
+
| `cornersSquareOptions.type` | `CornerSquareType` enum | Inherits | The shape of the corner squares. |
|
131
|
+
| `cornersSquareOptions.color` | `string` | Inherits | The color of the corner squares. Accepts any valid CSS color string. |
|
132
|
+
| `cornersSquareOptions.gradient` | `Gradient` object | `undefined` | Apply a gradient fill to the corner squares. See [Gradients](#gradients) for configuration details. |
|
133
|
+
|
134
|
+
**`CornerSquareType` Enum Values:** `dot`, `square`, `rounded`, `classy`, `outpoint`, `inpoint`.
|
135
|
+
|
136
|
+
##### Example: Corner Square Styling
|
137
|
+
|
138
|
+
```javascript
|
139
|
+
const qrCode = new QRCodeJs({
|
140
|
+
data: 'Styled Corners Example',
|
141
|
+
dotsOptions: {
|
142
|
+
type: 'square',
|
143
|
+
color: '#0000ff' // Blue dots
|
144
|
+
},
|
145
|
+
cornersSquareOptions: {
|
146
|
+
type: 'dot', // Use dot shape for corners
|
147
|
+
color: '#00ff00' // Green corners
|
148
|
+
}
|
149
|
+
});
|
150
|
+
```
|
151
|
+
---
|
152
|
+
|
153
|
+
#### Corner Dots
|
154
|
+
|
155
|
+
`cornersDotOptions` is an `object` that defines the appearance of the smaller dots inside the corner squares.
|
156
|
+
|
157
|
+
| Option | Type | Default | Description |
|
158
|
+
| :-------------------------- | :---------------- | :------------- | :--------------------------------------------------------------------------------------------------------------- |
|
159
|
+
| `cornersDotOptions.type` | `CornerDotType` enum | Inherits | The shape of the corner dots. |
|
160
|
+
| `cornersDotOptions.color` | `string` | Inherits | The color of the corner dots. Accepts any valid CSS color string. |
|
161
|
+
| `cornersDotOptions.gradient` | `Gradient` object | `undefined` | Apply a gradient fill to the corner dots. See [Gradients](#gradients) for configuration details. |
|
162
|
+
|
163
|
+
**`CornerDotType` Enum Values:** `dot`, `square`, `heart`, `rounded`, `classy`, `outpoint`, `inpoint`.
|
164
|
+
|
165
|
+
*\*Note: Defaults inherit from `cornersSquareOptions` first, then `dotsOptions`. Templates might set explicit defaults.*
|
166
|
+
|
167
|
+
#### Example: Corner Dot Styling
|
168
|
+
|
169
|
+
```javascript
|
170
|
+
const qrCode = new QRCodeJs({
|
171
|
+
data: 'Styled Corner Dots Example',
|
172
|
+
dotsOptions: {
|
173
|
+
type: 'square',
|
174
|
+
color: '#333333' // Dark grey dots
|
175
|
+
},
|
176
|
+
cornersSquareOptions: {
|
177
|
+
type: 'square',
|
178
|
+
color: '#aaaaaa' // Light grey corner squares
|
179
|
+
},
|
180
|
+
cornersDotOptions: {
|
181
|
+
type: 'dot', // Dot shape for inner corner dots
|
182
|
+
color: '#ff00ff' // Magenta inner corner dots
|
183
|
+
}
|
184
|
+
});
|
185
|
+
```
|
186
|
+
|
187
|
+
---
|
188
|
+
|
189
|
+
#### Background
|
190
|
+
|
191
|
+
`backgroundOptions` is an `object` or `false` that defines the appearance of the background layer of the QR code.
|
192
|
+
|
193
|
+
| Option | Type | Default | Description |
|
194
|
+
| :---------------------------- | :------------------- | :------------- | :------------------------------------------------------------------------------------------------------ |
|
195
|
+
| `backgroundOptions.color` | `string` | `'#FFFFFF'` | The background color. Accepts any valid CSS color string. |
|
196
|
+
| `backgroundOptions.round` | `number \| string` | `0` | Rounds the corners of the background (0-1 or percentage). |
|
197
|
+
| `backgroundOptions.gradient`| `Gradient` object | `undefined` | Apply a gradient fill to the background. See [Gradients](#gradients) for configuration details. |
|
198
|
+
|
199
|
+
##### Example: Background Styling
|
200
|
+
|
201
|
+
```javascript
|
202
|
+
const qrCode = new QRCodeJs({
|
203
|
+
data: 'Styled Background Example',
|
204
|
+
dotsOptions: {
|
205
|
+
color: '#ffffff' // White dots to contrast
|
206
|
+
},
|
207
|
+
backgroundOptions: {
|
208
|
+
color: '#000080', // Navy blue background
|
209
|
+
round: 0.5 // Rounded background corners
|
210
|
+
}
|
211
|
+
});
|
212
|
+
// Example: Transparent Background
|
213
|
+
const qrCodeTransparent = new QRCodeJs({
|
214
|
+
data: 'Transparent Background',
|
215
|
+
backgroundOptions: false // Disable background
|
216
|
+
});
|
217
|
+
```
|
218
|
+
|
219
|
+
---
|
220
|
+
|
221
|
+
#### Gradients
|
222
|
+
|
223
|
+
Options for applying gradient fills to various QR code elements (dots, corner squares, corner dots, background, image fill).
|
224
|
+
|
225
|
+
| Option | Type | Default | Description |
|
226
|
+
| :---------- | :------------------------------------- | :------ | :-------------------------------------------------------------------------- |
|
227
|
+
| `type` | `'linear' \| 'radial'` | - | Specifies the gradient type: `'linear'` or `'radial'`. |
|
228
|
+
| `rotation` | `number` | - | Rotation angle in radians for linear gradients. |
|
229
|
+
| `colorStops`| `Array<{ offset: number, color: string }>` | - | Array of color stops defining the gradient (offset: 0-1, color: CSS string). At least two stops recommended. |
|
230
|
+
|
231
|
+
**Where to Apply Gradients:**
|
232
|
+
Add a `gradient` property to: `dotsOptions`, `cornersSquareOptions`, `cornersDotOptions`, `backgroundOptions`, and `imageOptions.fill`.
|
233
|
+
|
234
|
+
*Note: If both `color` and `gradient` are set, `gradient` takes precedence.*
|
235
|
+
|
236
|
+
##### Example: Gradient Usage
|
237
|
+
|
238
|
+
```javascript
|
239
|
+
const qrCodeWithGradient = new QRCodeJs({
|
240
|
+
data: 'QR Code with Gradient Dots',
|
241
|
+
dotsOptions: {
|
242
|
+
type: 'rounded',
|
243
|
+
gradient: {
|
244
|
+
type: 'linear',
|
245
|
+
rotation: Math.PI / 4, // 45°
|
246
|
+
colorStops: [
|
247
|
+
{ offset: 0, color: '#0000ff' }, // Blue
|
248
|
+
{ offset: 1, color: '#00ff00' } // Green
|
249
|
+
]
|
250
|
+
}
|
251
|
+
},
|
252
|
+
backgroundOptions: {
|
253
|
+
gradient: {
|
254
|
+
type: 'radial',
|
255
|
+
colorStops: [
|
256
|
+
{ offset: 0, color: '#ffffff' }, // White center
|
257
|
+
{ offset: 1, color: '#dddddd' } // Grey edge
|
258
|
+
]
|
259
|
+
}
|
260
|
+
}
|
261
|
+
});
|
262
|
+
```
|
263
|
+
|
264
|
+
---
|
265
|
+
|
266
|
+
#### Image Embedding
|
267
|
+
|
268
|
+
`imageOptions` is an `object` that defines the appearance of an image (e.g., a logo) within the QR code. `imageOptions` is only applicable when `image` is set.
|
269
|
+
|
270
|
+
| Option | Type | Default | Description |
|
271
|
+
| :------------------------ | :----------------------------- | :------------- | :---------------------------------------------------------------------------------------------------------------------------------------- |
|
272
|
+
| `image` | `string \| Buffer \| Blob` | `undefined` | URL, Buffer, or Blob of an image to embed in the QR code. |
|
273
|
+
| `imageOptions.mode` | `ImageMode` enum | `'center'` | How the image is embedded. |
|
274
|
+
| `imageOptions.imageSize` | `number` | `0.4` | Relative size of the image (0-1). |
|
275
|
+
| `imageOptions.margin` | `number` | `0` | Margin around the image in dot units. |
|
276
|
+
| `imageOptions.crossOrigin`| `string` | `undefined` | CORS setting for the image (e.g., `'anonymous'`, `'use-credentials'`). |
|
277
|
+
| `imageOptions.fill` | `object` | `{...}` | Fill options for transparent areas (used in `'center'` mode). |
|
278
|
+
| `imageOptions.fill.color` | `string` | `'rgba(255,255,255,1)'` | Fill color for transparent areas. |
|
279
|
+
| `imageOptions.fill.gradient`| `Gradient` object | `undefined` | Apply a gradient fill to transparent areas. See [Gradients](#gradients) for configuration details. |
|
280
|
+
|
281
|
+
**`ImageMode` Enum Values:** `center`, `overlay`, `background`.
|
282
|
+
|
283
|
+
**Important Considerations:**
|
284
|
+
- Embedding an image reduces scannability. Use higher error correction levels (`Q` or `H`).
|
285
|
+
- Keep `imageSize` small (e.g., < 0.5) to maintain readability.
|
286
|
+
- Ensure contrast between dots and the image, especially in `'overlay'` mode.
|
287
|
+
|
288
|
+
##### Example: Image Embedding
|
289
|
+
|
290
|
+
```javascript
|
291
|
+
const qrCodeWithLogo = new QRCodeJs({
|
292
|
+
data: 'https://mybrand.com',
|
293
|
+
qrOptions: {
|
294
|
+
errorCorrectionLevel: 'H' // High error correction
|
295
|
+
},
|
296
|
+
image: 'https://mybrand.com/logo.png', // URL or data URI
|
297
|
+
imageOptions: {
|
298
|
+
imageSize: 0.3, // 30% size
|
299
|
+
margin: 2 // 2 block margin
|
300
|
+
}
|
301
|
+
});
|
302
|
+
```
|
303
|
+
---
|
304
|
+
|
305
|
+
#### Borders (Premium Feature, Requires License)
|
306
|
+
|
307
|
+
`borderOptions` is an `object` that defines the appearance of decorative borders around the QR code.
|
308
|
+
|
309
|
+
**Note:** This is a premium feature requiring a license. See [License Management](#license-management) for details.
|
310
|
+
|
311
|
+
| Option | Type | Default | Description |
|
312
|
+
| :---------------------------- | :------------------- | :------------- | :---------------------------------------------------------------------------------------------------------------------------------------- |
|
313
|
+
| `borderOptions.hasBorder` | `boolean` | `false` | Enables/disables all border features. Must be `true` to use other options. |
|
314
|
+
| `borderOptions.thickness` | `number` | `0` | Thickness of the main border frame in pixels. |
|
315
|
+
| `borderOptions.color` | `string` | `'#000000'` | Color of the main border frame. Accepts any valid CSS color string. |
|
316
|
+
| `borderOptions.radius` | `string` | `'0%'` | Corner radius of the main border (e.g., `'10px'`, `'50%'`). |
|
317
|
+
| `borderOptions.noBorderThickness` | `number` | `thickness / 4`| Thickness for border sides with disabled decorations. |
|
318
|
+
| `borderOptions.background` | `string` | `undefined` | Background color for the border area. Accepts any valid CSS color string. |
|
319
|
+
| `borderOptions.inner` | `object` | `undefined` | Adjusts the inner content area relative to the border. |
|
320
|
+
| `borderOptions.inner.radius` | `string` | `'0%'` | Corner radius for the inner content area. |
|
321
|
+
| `borderOptions.inner.scale` | `number` | `1` | Scales the inner content area (0 to 1.5). |
|
322
|
+
| `borderOptions.inner.horizontalOffset` | `number` | `0` | Shifts the inner content horizontally within the border. |
|
323
|
+
| `borderOptions.inner.verticalOffset` | `number` | `0` | Shifts the inner content vertically within the border. |
|
324
|
+
| `borderOptions.borderOuter` | `object` | `undefined` | Adds an outer border outside the main border. |
|
325
|
+
| `borderOptions.borderOuter.color` | `string` | `'#000000'` | Color of the outer border. |
|
326
|
+
| `borderOptions.borderOuter.thickness` | `number` | `10` | Thickness of the outer border in pixels. |
|
327
|
+
| `borderOptions.borderInner` | `object` | `undefined` | Adds an inner border inside the main border. |
|
328
|
+
| `borderOptions.borderInner.color` | `string` | `'#000000'` | Color of the inner border. |
|
329
|
+
| `borderOptions.borderInner.thickness` | `number` | `5` | Thickness of the inner border in pixels. |
|
330
|
+
| `borderOptions.decorations` | `object` | `undefined` | Adds text or images to border sides (`top`, `right`, `bottom`, `left`). See **Border Decorations**. |
|
331
|
+
|
332
|
+
#### Border Decorations
|
333
|
+
|
334
|
+
`decorations` is an `object` that defines the appearance of text or images to specific border sides (`top`, `right`, `bottom`, `left`).
|
335
|
+
|
336
|
+
| Option | Type | Default | Description |
|
337
|
+
| :--------------------- | :------------------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------- |
|
338
|
+
| `type` | `'text' \| 'image'` | `'text'` | Specifies text or image decoration. |
|
339
|
+
| `value` | `string` | `''` | The text content or image URL/data URI. |
|
340
|
+
| `enableText` | `boolean` | `false` | Enables the decoration for this side. |
|
341
|
+
| `disabled` | `boolean` | `false` | Disables the decoration for this side. |
|
342
|
+
| `style` | `object` | `{}` | Text styling options (`fontFace`, `fontSize`, `fontColor`, `letterSpacing`, `fontWeight`). |
|
343
|
+
| `style.fontFace` | `string` | `'Helvetica'` | The font face for the text. |
|
344
|
+
| `style.fontSize` | `number` | `28` | The font size for the text in pixels. |
|
345
|
+
| `style.fontColor` | `string` | `'#ffffff'` | The color of the text. |
|
346
|
+
| `style.letterSpacing` | `number` | `0` | The letter spacing for the text in pixels. |
|
347
|
+
| `style.fontWeight` | `'normal' \| 'bold'` | `'normal'` | The font weight for the text. |
|
348
|
+
| `offset` | `number` | `0` | Vertical (top/bottom) or horizontal (left/right) offset from the border center. |
|
349
|
+
| `curveDisabled` | `boolean` | `false` | If `true`, text is drawn straight instead of curved along the border. |
|
350
|
+
| `curveRadius` | `string` | `'50%'` | Overrides the curve radius for text (e.g., `'50%'`). Defaults to `borderOptions.radius`. |
|
351
|
+
| `curveAdjustment` | `number` | `0` | Fine-tunes text curve positioning. |
|
352
|
+
|
353
|
+
---
|
354
|
+
|
355
|
+
#### Notes
|
356
|
+
- **Required Option**: The `data` option is the only mandatory option, marked as **Required option** in its description.
|
357
|
+
- **Premium Feature**: The `borderOptions` and its sub-options (including decorations) require a license, as indicated by **Premium option**.
|
358
|
+
- **Links to Enums and Sections**: References like `[ShapeType](#enums-shapetype)` and `[Gradients](#gradients)` assume corresponding documentation sections exist. Adjust these to match your actual document structure.
|
359
|
+
- **Default Values**: Some defaults (e.g., `borderOptions.decorations.style`) are inferred from typical usage; verify with the library’s behavior if needed.
|
360
|
+
|
361
|
+
##### Example: Borders with Decorations
|
362
|
+
|
363
|
+
```javascript
|
364
|
+
// Ensure license is activated first!
|
365
|
+
// await QRCodeJs.license('YOUR-LICENSE-KEY');
|
366
|
+
|
367
|
+
const qrCodeWithBorder = new QRCodeJs({
|
368
|
+
data: 'QR Code with Fancy Border',
|
369
|
+
borderOptions: {
|
370
|
+
hasBorder: true,
|
371
|
+
thickness: 20,
|
372
|
+
color: '#663399', // Rebeccapurple
|
373
|
+
radius: '20%',
|
374
|
+
borderOuter: { color: '#FFD700', thickness: 2 }, // Gold outer line
|
375
|
+
decorations: {
|
376
|
+
top: {
|
377
|
+
type: 'text',
|
378
|
+
value: 'SCAN ME',
|
379
|
+
style: { fontColor: '#FFFFFF', fontSize: 16, fontWeight: 'bold' },
|
380
|
+
offset: -2 // Slightly up
|
381
|
+
},
|
382
|
+
bottom: {
|
383
|
+
type: 'text',
|
384
|
+
value: 'My Website',
|
385
|
+
style: { fontColor: '#FFFFFF', fontSize: 14 },
|
386
|
+
curveDisabled: false // Follow curve
|
387
|
+
}
|
388
|
+
}
|
389
|
+
}
|
390
|
+
});
|
391
|
+
```
|
392
|
+
|
393
|
+
### Node.js Usage
|
394
|
+
|
395
|
+
To use QRCode.js in a Node.js environment:
|
396
|
+
|
397
|
+
- **Import the library**:
|
398
|
+
```javascript
|
399
|
+
import { QRCodeJs } from '@qr-platform/qr-code.js/node'; // Use the Node.js-specific entry
|
400
|
+
```
|
401
|
+
|
402
|
+
- **Generate and serialize the QR code**:
|
403
|
+
Since Node.js lacks a DOM, serialize the QR code to an SVG string and save it to a file:
|
404
|
+
```javascript
|
405
|
+
const qrCode = new QRCodeJs({ data: 'https://example.com' });
|
406
|
+
const svgString = await qrCode.serialize();
|
407
|
+
require('fs').writeFileSync('qrcode.svg', svgString);
|
408
|
+
```
|
409
|
+
|
410
|
+
- **Key considerations**:
|
411
|
+
- Use `serialize()` to obtain the SVG as a string for further processing.
|
412
|
+
|
413
|
+
---
|
414
|
+
<a id="license-management"></a>
|
415
|
+
### License Management
|
416
|
+
|
417
|
+
Premium features like Borders and Scan Validation require a valid license. To activate:
|
418
|
+
|
419
|
+
- **Using a License Key**:
|
420
|
+
```javascript
|
421
|
+
await QRCodeJs.license('YOUR-LICENSE-KEY');
|
422
|
+
```
|
423
|
+
|
424
|
+
- **Using a JWT Token**:
|
425
|
+
```javascript
|
426
|
+
await QRCodeJs.token('YOUR-JWT');
|
427
|
+
```
|
428
|
+
|
429
|
+
For detailed instructions, refer to the [License Management Documentation](./license-management.md#introduction).
|
430
|
+
|
431
|
+
---
|
432
|
+
|
433
|
+
## Scan Validation (Premium Feature, Requires License)
|
434
|
+
|
435
|
+
Validate that a QR code is scannable and decodes correctly.
|
436
|
+
|
437
|
+
**Note:** Requires a license. See [License Management](#license-management).
|
438
|
+
|
439
|
+
**Usage:**
|
440
|
+
|
441
|
+
```javascript
|
442
|
+
// Ensure license is activated
|
443
|
+
// await QRCodeJs.license('YOUR-LICENSE-KEY');
|
444
|
+
|
445
|
+
const qrCode = new QRCodeJs({
|
446
|
+
data: 'Data to validate'
|
447
|
+
});
|
448
|
+
|
449
|
+
const validationResult = await qrCode.validateScanning();
|
450
|
+
|
451
|
+
if (validationResult.isValid) {
|
452
|
+
console.log('QR Code is valid! Decoded:', validationResult.data);
|
453
|
+
// document.body.appendChild(qrCode.svgElement);
|
454
|
+
} else {
|
455
|
+
console.error('Validation failed:', validationResult.error, validationResult.errorCode);
|
456
|
+
}
|
457
|
+
```
|
458
|
+
|
459
|
+
**Return Value (`validationResult`):**
|
460
|
+
|
461
|
+
| Property | Type | Description |
|
462
|
+
| :----------- | :-------- | :-------------------------------------------------------------------------- |
|
463
|
+
| `isValid` | `boolean` | `true` if scannable and correct, `false` otherwise. |
|
464
|
+
| `data` | `string` | Decoded data (if `isValid` is `true`). |
|
465
|
+
| `format` | `string` | Barcode format (e.g., `'QR-Code'`) (if `isValid` is `true`). |
|
466
|
+
| `attempts` | `number` | Number of decoding attempts. |
|
467
|
+
| `isInverted` | `boolean` | Whether an inverted image was needed for scanning. |
|
468
|
+
| `error` | `string` | Error message (if `isValid` is `false`). |
|
469
|
+
| `errorCode` | `string` | Error code (e.g., `NO_BARCODE_DETECTED`, `MAX_RETRIES_EXCEEDED`). |
|
470
|
+
|
471
|
+
---
|
472
|
+
|
473
|
+
#### Methods
|
474
|
+
|
475
|
+
- **`append(container: HTMLElement): void`**
|
476
|
+
Appends the QR code to a specified container element.
|
477
|
+
|
478
|
+
- **`serialize(): Promise<string | undefined>`**
|
479
|
+
Converts the QR code to an SVG string.
|
480
|
+
|
481
|
+
- **`download(options?: { name?: string; extension: 'svg' | 'png' | 'jpeg' | 'webp' }, canvasOptions?: CanvasOptions): Promise<void>`**
|
482
|
+
Downloads the QR code as a file.
|
483
|
+
|
484
|
+
- **`update(options: Partial<QRCodeJsOptions>): void`**
|
485
|
+
Updates the QR code with new options.
|
486
|
+
|
487
|
+
- **`validateScanning(): Promise<{ isValid: boolean; decodedText?: string; message?: string }>`**
|
488
|
+
Validates that the QR code is scannable (Premium feature).
|
489
|
+
|
490
|
+
#### Static Methods
|
491
|
+
|
492
|
+
- **`QRCodeJs.license(licenseKey: string): Promise<ValidationResult>`**
|
493
|
+
Activates a license using a license key.
|
494
|
+
|
495
|
+
- **`QRCodeJs.token(token: string | null): Promise<ValidationResult>`**
|
496
|
+
Activates a license using a pre-fetched JWT token.
|
497
|
+
|
498
|
+
- **`QRCodeJs.getLicenseDetails(): DecodedLicenseToken | null`**
|
499
|
+
Retrieves current license information.
|
500
|
+
|
501
|
+
- **`QRCodeJs.setLicenseUrl(url: string): void`**
|
502
|
+
Sets the URL endpoint for license key validation.
|
503
|
+
|
504
|
+
- **`QRCodeJs.configureLicenseFetcher(fetcher: (licenseKey: string) => Promise<string>): void`**
|
505
|
+
Configures a custom function for fetching license tokens.
|
506
|
+
|
507
|
+
|
508
|
+
## FAQ
|
509
|
+
|
510
|
+
### How do I handle CORS issues with embedded images?
|
511
|
+
|
512
|
+
Set `crossOrigin` in `imageOptions`:
|
513
|
+
```javascript
|
514
|
+
imageOptions: {
|
515
|
+
crossOrigin: 'anonymous'
|
516
|
+
}
|
517
|
+
```
|
518
|
+
Ensure the image server allows cross-origin requests.
|
519
|
+
|
520
|
+
### What are best practices for scannability?
|
521
|
+
|
522
|
+
- Keep `imageSize` below 0.5.
|
523
|
+
- Maintain high contrast between dots and background/image.
|
524
|
+
|
525
|
+
---
|
526
|
+
|
527
|
+
### Examples
|
528
|
+
|
529
|
+
##### Example 1: Classy Style with Gradient and Logo
|
530
|
+
|
531
|
+
```javascript
|
532
|
+
const qrCodeClassy = new QRCodeJs({
|
533
|
+
data: 'https://stylish-qr.codes',
|
534
|
+
qrOptions: { errorCorrectionLevel: 'H' },
|
535
|
+
dotsOptions: {
|
536
|
+
type: 'classyRounded',
|
537
|
+
gradient: {
|
538
|
+
type: 'linear',
|
539
|
+
rotation: Math.PI / 3,
|
540
|
+
colorStops: [{ offset: 0, color: '#3366FF' }, { offset: 1, color: '#66CCFF' }]
|
541
|
+
}
|
542
|
+
},
|
543
|
+
cornersSquareOptions: {
|
544
|
+
type: 'classy',
|
545
|
+
gradient: {
|
546
|
+
type: 'linear',
|
547
|
+
rotation: Math.PI / 3,
|
548
|
+
colorStops: [{ offset: 0, color: '#3366FF' }, { offset: 1, color: '#66CCFF' }]
|
549
|
+
}
|
550
|
+
},
|
551
|
+
cornersDotOptions: {
|
552
|
+
type: 'classy',
|
553
|
+
gradient: {
|
554
|
+
type: 'linear',
|
555
|
+
rotation: Math.PI / 3,
|
556
|
+
colorStops: [{ offset: 0, color: '#3366FF' }, { offset: 1, color: '#66CCFF' }]
|
557
|
+
}
|
558
|
+
},
|
559
|
+
backgroundOptions: { color: '#FFFFFF' },
|
560
|
+
image: 'logo.svg',
|
561
|
+
imageOptions: { imageSize: 0.25, margin: 1 }
|
562
|
+
});
|
563
|
+
```
|
564
|
+
|
565
|
+
##### Example 2: Circle Shape with Star Dots and Transparent Background
|
566
|
+
|
567
|
+
```javascript
|
568
|
+
const qrCodeCircleStar = new QRCodeJs({
|
569
|
+
data: 'Circle with Stars',
|
570
|
+
shape: 'circle',
|
571
|
+
dotsOptions: {
|
572
|
+
type: 'star',
|
573
|
+
color: '#FF6600' // Orange stars
|
574
|
+
},
|
575
|
+
cornersSquareOptions: { type: 'rounded', color: '#FF6600' },
|
576
|
+
cornersDotOptions: { type: 'dot', color: '#FF6600' },
|
577
|
+
backgroundOptions: false // Transparent
|
578
|
+
});
|
579
|
+
```
|
580
|
+
|
581
|
+
##### Example 3: Premium Border with Text and Inner/Outer Borders
|
582
|
+
|
583
|
+
```javascript
|
584
|
+
// Ensure license is activated
|
585
|
+
// await QRCodeJs.license('YOUR-LICENSE-KEY');
|
586
|
+
|
587
|
+
const qrCodePremium = new QRCodeJs({
|
588
|
+
data: 'Premium Features Showcase',
|
589
|
+
qrOptions: { errorCorrectionLevel: 'Q' },
|
590
|
+
dotsOptions: { type: 'square', color: '#006400' }, // Dark green
|
591
|
+
cornersSquareOptions: { type: 'square', color: '#006400' },
|
592
|
+
cornersDotOptions: { type: 'square', color: '#006400' },
|
593
|
+
backgroundOptions: { color: '#F0FFF0' }, // Honeydew
|
594
|
+
borderOptions: {
|
595
|
+
hasBorder: true,
|
596
|
+
thickness: 25,
|
597
|
+
color: '#556B2F', // Dark Olive Green
|
598
|
+
radius: '10px',
|
599
|
+
borderOuter: { color: '#BDB76B', thickness: 3 }, // Dark Khaki
|
600
|
+
borderInner: { color: '#9ACD32', thickness: 1 }, // Yellow Green
|
601
|
+
decorations: {
|
602
|
+
bottom: {
|
603
|
+
type: 'text',
|
604
|
+
value: 'LICENSED FEATURE',
|
605
|
+
style: { fontColor: '#FFFFFF', fontSize: 18, fontWeight: '500' },
|
606
|
+
curveDisabled: true // Straight text
|
607
|
+
}
|
608
|
+
}
|
609
|
+
}
|
610
|
+
});
|
611
|
+
```
|
612
|
+
|
613
|
+
---
|
614
|
+
|
615
|
+
### See Also
|
616
|
+
- [QRCode.js Documentation](./documentation.md#start)
|
617
|
+
- [Quick References Guide](./quick-references-guide.md#start)
|
618
|
+
- [API Reference Guide](./api-reference-guide.md#start)
|
619
|
+
- [TypeScript Types and Definitions](./typescript-types-definitions.md#start)
|
620
|
+
- [License Management](./license-management.md#start)
|
621
|
+
- [Basic Examples](./examples.md#start)
|
622
|
+
- [Advanced Examples](./advanced-examples.md#start)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { CanvasOptions } from '~/utils/canvas-options';
|
2
|
+
import { RecursivePartial } from '../types/helper';
|
3
|
+
import { Options } from '../utils/options';
|
4
|
+
export declare enum FileExtension {
|
5
|
+
svg = "svg",
|
6
|
+
png = "png",
|
7
|
+
jpeg = "jpeg",
|
8
|
+
webp = "webp"
|
9
|
+
}
|
10
|
+
export type ExtensionFunction = (svg: SVGElement, options: RecursivePartial<Options>) => void;
|
11
|
+
export declare class QRCodeJs {
|
12
|
+
private options;
|
13
|
+
private container?;
|
14
|
+
private qr?;
|
15
|
+
private extension?;
|
16
|
+
private svgDrawingPromise?;
|
17
|
+
private qrSVG?;
|
18
|
+
get size(): {
|
19
|
+
width: number;
|
20
|
+
height: number;
|
21
|
+
} | undefined;
|
22
|
+
constructor(options: RecursivePartial<Options>);
|
23
|
+
update(options?: RecursivePartial<Options>): Promise<void>;
|
24
|
+
append(
|
25
|
+
/** This container will be used for appending of the QR code */
|
26
|
+
container?: HTMLElement): QRCodeJs | undefined;
|
27
|
+
applyExtension(extension: ExtensionFunction): Promise<void>;
|
28
|
+
deleteExtension(): Promise<void>;
|
29
|
+
serialize(inverted?: boolean): Promise<string | undefined>;
|
30
|
+
private _setupSvgAsync;
|
31
|
+
protected _drawToCanvasForValidation(options?: RecursivePartial<CanvasOptions>): Promise<HTMLCanvasElement>;
|
32
|
+
protected drawToCanvas(options?: RecursivePartial<CanvasOptions>): Promise<{
|
33
|
+
canvas: HTMLCanvasElement;
|
34
|
+
canvasDrawingPromise: Promise<void> | undefined;
|
35
|
+
} | undefined>;
|
36
|
+
private downloadURI;
|
37
|
+
download(downloadOptions?: {
|
38
|
+
name?: string;
|
39
|
+
extension: `${FileExtension}`;
|
40
|
+
}, canvasOptions?: RecursivePartial<CanvasOptions>): Promise<void>;
|
41
|
+
protected createOptimizedQRCanvas(options?: RecursivePartial<CanvasOptions>): Promise<HTMLCanvasElement>;
|
42
|
+
/**
|
43
|
+
* Apply thresholding to enhance QR code contrast
|
44
|
+
*/
|
45
|
+
private applyQRThreshold;
|
46
|
+
protected _hls(): boolean;
|
47
|
+
private _logValidationWarnings;
|
48
|
+
}
|