QR Code¶
QR Code generation either with the included QRCodeRect node or use the encoding result of the QRCode class.
Compatibility¶
| Godot | Version |
|---|---|
| 4.6 | >= 1.2.0 |
| 4.5 | >= 1.2.0 |
| 4.4 | >= 1.2.0 |
| 4.3 | 1.1.0 - 1.1.3 |
| 4.2 | 1.1.0 - 1.1.3 |
| 4.1 | <= 1.0.0 |
Screenshot¶

Example¶
Interface¶
QRCodeRect¶
extendsTextureRect
res://addons/kenyoni/qr_code/qr_code_rect.gd
TextureRect like node. The texture is updated by itself. When using byte encoding you can also pass strings for specific ECI values (ISO 8859-1, Shift JIS, UTF-8, UTF-16, US ASCII), the input string will be automatically converted to an byte array.
Properties¶
| Name | Type | Description |
|---|---|---|
| auto_mask_pattern | bool | Use automatically the best mask pattern. |
| auto_module_size | bool | Automatically set the module pixel size based on the size. Do not use expand mode KEEP_SIZE when using it. If auto_module_size is set, this value might by only occasionally updated. In this case do not rely on it.Turn this off when the QR Code is resized often, as it impacts the performance quite heavily. |
| auto_update | bool | Automatically update the QR Code when a property changes. |
| auto_version | bool | Use automatically the smallest QR Code version. |
| dark_module_color | Color | Color of the dark modules. |
| data | Variant | Type varies based on the encoding mode. |
| eci_value | String | Extended Channel Interpretation (ECI) Value |
| error_correction | QRCode.ErrorCorrection | Error correction value. |
| light_module_color | Color | Color of the light modules. |
| mask_pattern | int | QR Code mask pattern. |
| mode | QRCode.Mode | QR Code mode |
| module_size | int | Use that many pixel for one module. |
| quiet_zone_size | int | Use that many modules for the quiet zone. A value of 4 is recommended. |
| use_eci | String | Use Extended Channel Interpretation (ECI) |
| version | int | QR Code version (size). |
Methods¶
- void update()
- Update the QR Code.
QRCode¶
extendsRefCounted
res://addons/kenyoni/qr_code/qr_code.gd
QRCode class to generate QR Codes.
Properties¶
| Name | Type | Description |
|---|---|---|
| auto_mask_pattern | bool | Use automatically the best mask pattern. |
| auto_version | bool | Use automatically the smallest QR Code version. |
| eci_value | String | Extended Channel Interpretation (ECI) Value |
| error_correction | QRCode.ErrorCorrection | Error correction value. |
| mask_pattern | int | QR Code mask pattern. |
| mode | QRCode.Mode | QR Code mode. |
| use_eci | String | Use Extended Channel Interpretation (ECI) |
| version | int | QR Code version (size). |
Methods¶
- int calc_min_version() const
- Return the minimal version required to encode the data.
- PackedByteArray encode()
- Get the QR Code row by row in one array. To get the row size use
get_dimension. - Image generate_image(module_size: int=1, light_module_color: Color=Color.WHITE, dark_module_color: Color=Color.BLACK)
- Generate an image. This method can be called repeatedly, as encoding will only happens once and the result is cached.
- int get_dimension() const
- Returns the dimension for the current version.
- void put_alphanumeric(text: String)
- Put a alphanumeric text. Invalid characters are removed. Will change the encoding mode to
Mode.ALPHANUMERIC. - void put_byte(data: PackedByteArray)
- Put a bytes. Will change the encoding mode to
Mode.BYTE. - void put_kanji(data: String)
- Put a kanji text. Invalid characters are removed. Will change the encoding mode to
Mode.KANJI. - void put_numeric(number: String)
- Put a numeric text. Invalid characters are removed. Will change the encoding mode to
Mode.NUMERIC.
QRCode.Mode¶
res://addons/kenyoni/qr_code/qr_code.gd
Encoding mode enum.
| Name | Value |
|---|---|
| NUMERIC | 1 |
| ALPHANUMERIC | 2 |
| BYTE | 4 |
| KANJI | 8 |
QRCode.ErrorCorrection¶
res://addons/kenyoni/qr_code/qr_code.gd
Error correction enum.
| Name | Value |
|---|---|
| LOW | 1 |
| MEDIUM | 0 |
| QUARTILE | 3 |
| HIGH | 2 |
QRCode.ECI¶
res://addons/kenyoni/qr_code/qr_code.gd
ECI values. See source code for available values.
ShiftJIS¶
res://addons/kenyoni/qr_code/shift_jis.gd
Shift JIS encoding utility.
Methods¶
- String get_string_from_jis_8(arr: PackedByteArray) static
- Get text from JIS 8 encoded bytes. Requires an u8 int array. Unknown characters are skipped.
- String get_string_from_shift_jis_2004(arr: PackedByteArray) static
- Get text from Shift JIS 2004 encoded bytes. Requires an u16 int array. Unknown characters are skipped.
- PackedByteArray to_jis_8_buffer(text: String) static
- Convert text to JIS 8 encoded bytes. Returns u8 int array. Unknown characters are skipped.
- PackedByteArray to_shift_jis_2004_buffer(text: String) static
- Convert text to Shift JIS 2004 encoded bytes. Returns u16 int array. Unknown characters are skipped.
Changelog¶
2.0.0¶
- Breaking Changes:
- Moved to
res://addons/kenyoni/qr_code - Renamed
QRCode.get_module_counttoQRCode.get_dimension QRCodeis no longer caching the encoding resultQRCode.generate_imageis now static- Renamed
QRCodeRect.module_px_sizetoQRCodeRect.module_size - Renamed
QRCodeRect.auto_module_px_sizetoQRCodeRect.auto_module_size QRCodeRectnow caches the encoding result, changing appearance properties will not encode againQRCodeRectno longer saves the texture to the scene file
- Moved to
- Added
auto_updateproperty toQRCodeRect - Added
updatemethod toQRCodeRect - Various bug fixes and code improvements
1.3.1¶
- Fix various bugs, which could lead to crashes and too large versions being selected
- Performance improvements
1.3.0¶
- Upgrade
.imports to Godot 4.6
1.2.0¶
- Require Godot 4.4
- Add UIDs for Godot 4.4
- Update static typing
1.1.3¶
- Code improvements
1.1.2¶
- Use absolute paths in preloads
1.1.1¶
- Code optimizing
1.1.0¶
- Require Godot 4.2
- Add more values to plugin.cfg
- Add static typing in for loops
1.0.0¶
- Renamed
get_string_from_jis_2004toget_string_from_shift_jis_2004
0.3.1¶
- Improve inspector properties
- Improve input handling of byte data based on ECI usage
0.3.0¶
- Make ECI value optional
0.2.0¶
- Added quiet zone size property