Skip to content

EAN-13 Barcode

EAN-13 barcode generation and rendering addon for Godot. Provides a EAN13Rect node that can be used to display EAN-13 barcodes, as well as utility classes for encoding and rendering EAN-13 codes.

Download

Compatibility

Godot Version
4.6 all
4.5 all
4.4 all

Screenshot

EAN13-Rect node inspector screenshot

Example

/examples/ean13/

Interface

EAN13Rect

extendsTextureRect

res://addons/kenyoni/ean13/ean13_rect.gd

TextureRect like node. The texture updates automatically. Texture generation takes one frame, so changes to the number or other properties become visible one frame later.

Properties

Name Type Description
add_quiet_zone bool Add a quiet zone around the code.
auto_module_size bool Automatically set the module pixel size based on the size. Do not use expand mode KEEP_SIZE when using it.
Turn this off when the EAN-13 Code is resized often, as it impacts the performance quite heavily.
auto_update bool Automatically update the barcode when a property changes.
background_color Color Background color.
bar_color Color Bar color.
module_size int Use that many pixel for one module.
number String The number to generate the EAN-13 code for. Must be 12 or 13 digits long. If 12 digits are given, the checksum digit is calculated automatically. Non-digit characters are automatically removed.
show_quiet_zone_indicator bool Show an arrow indicator for the right quiet zone. Requires quiet zone to be enabled.
show_text bool Show the number as text below the bars. Requires quiet zone to be enabled.
text_font Font Font for the text. If null, the default project font is used.

Methods

String ean13() const
The effective number used to generate the EAN-13 code, including the checksum digit. Only set if update was called.
void update()
Updates the EAN-13 code and texture based on the current properties.

EAN13

extendsObject

res://addons/kenyoni/ean13/ean13.gd

EAN-13 encoding class.

Methods

int checksum(number: int) static
Calculate the EAN-13 check digit for the given number.
String ean13(number: String) static
Get the EAN-13 number including the check digit.
number must be a string of 12 digits; all non-digit characters are removed automatically.
String ean13_int(number: int) static
Get the EAN-13 number including the check digit from an integer.
PackedByteArray encode(number: String) static
Encode the given EAN-13 number and return the encoded data as a byte array. The returned array has a size of 95 bytes; each byte represents a module (0 for light, 1 for dark).
bool validate(number: String) static
Validate the given EAN-13 number.
bool validate_int(number: int) static
Validate the given EAN-13 number.

Ean13Renderer

extendsObject

res://addons/kenyoni/ean13/renderer.gd

EAN-13 code renderer class.

Properties

Name Type Description
add_quiet_zone bool Add a quiet zone around the code.
background_color Color Background color.
bar_color Color Bar color.
show_quiet_zone_indicator bool Show an arrow indicator for the right quiet zone.
show_text bool Show the number as text below the bars.
text_font Font Font for the text. If null, the default project font is used.

Methods

Image generate_image(ean13: String, encoded_data: PackedByteArray) const
Generates an Image of the EAN-13 barcode based on the provided encoded data. Asynchronous method. For a synchronous version without text rendering call generate_image_no_text. Returns null if rendering failed.
Image generate_image_no_text(ean13: String, encoded_data: PackedByteArray) const
Generates an Image of the EAN-13 barcode based on the provided encoded data, without rendering the text.

Changelog

1.0.0

  • Initial release.