Discord

Preparing your files

Please wait until the download is ready.

Luka's Scripting Utilities

Luka's Scripting Utilities

by Luka S.J.

A pack full of various scripting utilities to ease your development!

v4.1.135,194
Download144 KB

Barcode Generator

BarcodeGenerator renders a UPC-A barcode to a Bitmap from a numeric
value of up to 11 digits. The 12th check digit is calculated for you, and the
input is zero-padded to the full width.

bmp = BarcodeGenerator.new(12345).generate
sprite.bitmap = bmp

Usage

BarcodeGenerator.new(number, height: 96, unit: 4, color_white: ..., color_black: ...)

  • number the value to encode (Integer, ≤ 11 digits)
  • height bar height in pixels (default 96)
  • unit bar unit width in pixels (default 4)
  • color_white / color_black the two bar colours (default white / black)

Then:

  • generator.generate the full UPC-A barcode bitmap — guards, both digit halves and the check digit
  • generator.generate_trimmed a trimmed bitmap containing only the right-hand 5 digits, for tight layouts

Errors

  • BarcodeGenerator::TypeError — the input was not an Integer
  • BarcodeGenerator::SizeError — the input had more than 11 digits

Both generate and generate_trimmed return a standard Bitmap you can
assign to any sprite.