ruby-zint-es 1.3.0
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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.standard.yml +5 -0
- data/.yardopts +9 -0
- data/Gemfile +18 -0
- data/LICENSE.txt +21 -0
- data/README.md +114 -0
- data/Rakefile +20 -0
- data/ext/ruby-zint/extconf.rb +86 -0
- data/lib/ruby-zint.rb +1 -0
- data/lib/zint/aus_post.rb +8 -0
- data/lib/zint/aus_redirect.rb +8 -0
- data/lib/zint/aus_reply.rb +8 -0
- data/lib/zint/aus_route.rb +8 -0
- data/lib/zint/azrune.rb +8 -0
- data/lib/zint/aztec.rb +8 -0
- data/lib/zint/barcode.rb +498 -0
- data/lib/zint/bc_412.rb +8 -0
- data/lib/zint/bitmap.rb +4 -0
- data/lib/zint/bitmap_pixel.rb +4 -0
- data/lib/zint/c25iata.rb +8 -0
- data/lib/zint/c25ind.rb +8 -0
- data/lib/zint/c25inter.rb +8 -0
- data/lib/zint/c25logic.rb +8 -0
- data/lib/zint/c25matrix.rb +8 -0
- data/lib/zint/c25standard.rb +8 -0
- data/lib/zint/cep_net.rb +8 -0
- data/lib/zint/channel.rb +8 -0
- data/lib/zint/codabar.rb +8 -0
- data/lib/zint/codablock_f.rb +8 -0
- data/lib/zint/code11.rb +8 -0
- data/lib/zint/code128.rb +8 -0
- data/lib/zint/code128ab.rb +8 -0
- data/lib/zint/code128b.rb +5 -0
- data/lib/zint/code16k.rb +8 -0
- data/lib/zint/code32.rb +8 -0
- data/lib/zint/code39.rb +8 -0
- data/lib/zint/code49.rb +8 -0
- data/lib/zint/code93.rb +8 -0
- data/lib/zint/code_one.rb +8 -0
- data/lib/zint/constants/capability_flags.rb +21 -0
- data/lib/zint/constants/debug_flags.rb +9 -0
- data/lib/zint/constants/errors.rb +19 -0
- data/lib/zint/constants/input_data_types.rb +15 -0
- data/lib/zint/constants/output_options.rb +21 -0
- data/lib/zint/constants/specific_options.rb +12 -0
- data/lib/zint/constants/symbologies.rb +137 -0
- data/lib/zint/constants/warn_levels.rb +9 -0
- data/lib/zint/constants/warnings.rb +12 -0
- data/lib/zint/daft.rb +8 -0
- data/lib/zint/data_matrix.rb +19 -0
- data/lib/zint/dbarexp.rb +8 -0
- data/lib/zint/dbarexpstk.rb +8 -0
- data/lib/zint/dbarltd.rb +8 -0
- data/lib/zint/dbaromn.rb +8 -0
- data/lib/zint/dbaromnstk.rb +8 -0
- data/lib/zint/dbarstk.rb +8 -0
- data/lib/zint/dependencies.rb +7 -0
- data/lib/zint/dot_code.rb +8 -0
- data/lib/zint/dpd.rb +8 -0
- data/lib/zint/dpident.rb +8 -0
- data/lib/zint/dpleit.rb +8 -0
- data/lib/zint/ean128.rb +8 -0
- data/lib/zint/ean14.rb +8 -0
- data/lib/zint/eanx.rb +8 -0
- data/lib/zint/eanxchk.rb +8 -0
- data/lib/zint/excode39.rb +8 -0
- data/lib/zint/fim.rb +8 -0
- data/lib/zint/flat.rb +8 -0
- data/lib/zint/grid_matrix.rb +8 -0
- data/lib/zint/gs1_128.rb +10 -0
- data/lib/zint/hanxin.rb +8 -0
- data/lib/zint/hibc128.rb +8 -0
- data/lib/zint/hibc39.rb +8 -0
- data/lib/zint/hibcaztec.rb +8 -0
- data/lib/zint/hibcblockf.rb +8 -0
- data/lib/zint/hibcdm.rb +8 -0
- data/lib/zint/hibcmicpdf.rb +8 -0
- data/lib/zint/hibcpdf.rb +8 -0
- data/lib/zint/hibcqr.rb +8 -0
- data/lib/zint/isbnx.rb +8 -0
- data/lib/zint/itf14.rb +8 -0
- data/lib/zint/japan_post.rb +8 -0
- data/lib/zint/kix.rb +8 -0
- data/lib/zint/korea_post.rb +8 -0
- data/lib/zint/logmars.rb +8 -0
- data/lib/zint/mailmark.rb +8 -0
- data/lib/zint/mailmark_2d.rb +8 -0
- data/lib/zint/mailmark_4s.rb +8 -0
- data/lib/zint/maxi_code.rb +8 -0
- data/lib/zint/micro_pdf417.rb +8 -0
- data/lib/zint/micro_qr.rb +8 -0
- data/lib/zint/msiplessey.rb +8 -0
- data/lib/zint/native.rb +87 -0
- data/lib/zint/nve18.rb +8 -0
- data/lib/zint/one_code.rb +8 -0
- data/lib/zint/pdf417.rb +8 -0
- data/lib/zint/pdf417comp.rb +8 -0
- data/lib/zint/pdf417trunc.rb +8 -0
- data/lib/zint/pharma.rb +8 -0
- data/lib/zint/pharmatwo.rb +8 -0
- data/lib/zint/planet.rb +8 -0
- data/lib/zint/plessey.rb +8 -0
- data/lib/zint/postnet.rb +8 -0
- data/lib/zint/pzn.rb +8 -0
- data/lib/zint/qr.rb +18 -0
- data/lib/zint/rmqr.rb +8 -0
- data/lib/zint/rss14.rb +8 -0
- data/lib/zint/rss14stack.rb +8 -0
- data/lib/zint/rss14stackomni.rb +8 -0
- data/lib/zint/rssexp.rb +8 -0
- data/lib/zint/rssexpstack.rb +8 -0
- data/lib/zint/rssltd.rb +8 -0
- data/lib/zint/structs/structapp.rb +25 -0
- data/lib/zint/structs/symbol.rb +49 -0
- data/lib/zint/structs/vector.rb +54 -0
- data/lib/zint/structs/vector_circle.rb +32 -0
- data/lib/zint/structs/vector_hexagon.rb +31 -0
- data/lib/zint/structs/vector_rect.rb +37 -0
- data/lib/zint/structs/vector_string.rb +50 -0
- data/lib/zint/telepen.rb +8 -0
- data/lib/zint/telepennum.rb +8 -0
- data/lib/zint/ultra.rb +8 -0
- data/lib/zint/upc_a.rb +8 -0
- data/lib/zint/upc_a_chk.rb +8 -0
- data/lib/zint/upc_e.rb +8 -0
- data/lib/zint/upc_e_chk.rb +8 -0
- data/lib/zint/upnqr.rb +8 -0
- data/lib/zint/upu_s10.rb +8 -0
- data/lib/zint/uspsimail.rb +8 -0
- data/lib/zint/version.rb +3 -0
- data/lib/zint/vin.rb +8 -0
- data/lib/zint/zint_recipe.rb +27 -0
- data/lib/zint.rb +168 -0
- data/ports/archives/zint-2.12.0-src.tar.gz +0 -0
- data/ruby-zint.gemspec +40 -0
- metadata +326 -0
data/lib/zint/native.rb
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module Zint
|
|
2
|
+
module Native
|
|
3
|
+
extend FFI::Library
|
|
4
|
+
|
|
5
|
+
root_path = File.expand_path("../../..", __FILE__)
|
|
6
|
+
prefix = FFI::Platform::LIBPREFIX.empty? ? "lib" : FFI::Platform::LIBPREFIX
|
|
7
|
+
bundled_dll = File.join(root_path, "lib/#{prefix}zint.#{FFI::Platform::LIBSUFFIX}")
|
|
8
|
+
ffi_lib [bundled_dll, "libzint.so.2.12", "libzint", "zint"]
|
|
9
|
+
|
|
10
|
+
# Error codes (API return values)
|
|
11
|
+
enum :error_code, [Constants::Warnings::WARNINGS, Constants::Errors::ERRORS].map { |h| h.to_a }.flatten
|
|
12
|
+
|
|
13
|
+
# Aliases for better method signatures
|
|
14
|
+
typedef Structs::Symbol.by_ref, :zint_symbol
|
|
15
|
+
typedef :pointer, :filename
|
|
16
|
+
typedef :int32, :length
|
|
17
|
+
typedef :int32, :rotate_angle
|
|
18
|
+
typedef :int32, :symbol_id
|
|
19
|
+
typedef :uint32, :cap_flag
|
|
20
|
+
typedef :string, :source
|
|
21
|
+
|
|
22
|
+
# Create and initialize a symbol structure
|
|
23
|
+
attach_function(:ZBarcode_Create, [], :zint_symbol)
|
|
24
|
+
|
|
25
|
+
# Free any output buffers that may have been created and initialize output fields
|
|
26
|
+
attach_function(:ZBarcode_Clear, [:zint_symbol], :void)
|
|
27
|
+
|
|
28
|
+
# Free a symbol structure, including any output buffers
|
|
29
|
+
#
|
|
30
|
+
# For use with ruby's garbage collector ZBarcode_Delete must be called with a plain :pointer and not an :zint_symbol.
|
|
31
|
+
attach_function(:ZBarcode_Delete, [:pointer], :void)
|
|
32
|
+
|
|
33
|
+
# Encode a barcode. If `length` is 0, `source` must be NUL-terminated.
|
|
34
|
+
attach_function(:ZBarcode_Encode, [:zint_symbol, :source, :length], :error_code)
|
|
35
|
+
|
|
36
|
+
# Encode a barcode using input data from file `filename`
|
|
37
|
+
attach_function(:ZBarcode_Encode_File, [:zint_symbol, :filename], :error_code)
|
|
38
|
+
|
|
39
|
+
# Output a previously encoded symbol to file `symbol->outfile`
|
|
40
|
+
attach_function(:ZBarcode_Print, [:zint_symbol, :rotate_angle], :error_code)
|
|
41
|
+
|
|
42
|
+
# Encode and output a symbol to file `symbol->outfile`
|
|
43
|
+
attach_function(:ZBarcode_Encode_and_Print, [:zint_symbol, :source, :length, :rotate_angle], :error_code)
|
|
44
|
+
|
|
45
|
+
# Encode a symbol using input data from file `filename` and output to file `symbol->outfile`
|
|
46
|
+
attach_function(:ZBarcode_Encode_File_and_Print, [:zint_symbol, :filename, :rotate_angle], :error_code)
|
|
47
|
+
|
|
48
|
+
# Output a previously encoded symbol to memory as raster (`symbol->bitmap`)
|
|
49
|
+
attach_function(:ZBarcode_Buffer, [:zint_symbol, :rotate_angle], :error_code)
|
|
50
|
+
|
|
51
|
+
# Encode and output a symbol to memory as raster (`symbol->bitmap`)
|
|
52
|
+
attach_function(:ZBarcode_Encode_and_Buffer, [:zint_symbol, :source, :length, :rotate_angle], :error_code)
|
|
53
|
+
|
|
54
|
+
# Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`)
|
|
55
|
+
attach_function(:ZBarcode_Encode_File_and_Buffer, [:zint_symbol, :filename, :rotate_angle], :error_code)
|
|
56
|
+
|
|
57
|
+
# Output a previously encoded symbol to memory as vector (`symbol->vector`)
|
|
58
|
+
attach_function(:ZBarcode_Buffer_Vector, [:zint_symbol, :rotate_angle], :error_code)
|
|
59
|
+
|
|
60
|
+
# Encode and output a symbol to memory as vector (`symbol->vector`)
|
|
61
|
+
attach_function(:ZBarcode_Encode_and_Buffer_Vector, [:zint_symbol, :source, :length, :rotate_angle], :error_code)
|
|
62
|
+
|
|
63
|
+
# Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`)
|
|
64
|
+
attach_function(:ZBarcode_Encode_File_and_Buffer_Vector, [:zint_symbol, :filename, :rotate_angle], :error_code)
|
|
65
|
+
|
|
66
|
+
# Is `symbol_id` a recognized symbology?
|
|
67
|
+
attach_function(:ZBarcode_ValidID, [:symbol_id], :bool)
|
|
68
|
+
|
|
69
|
+
# Return the capability flags for symbology `symbol_id` that match `cap_flag`
|
|
70
|
+
attach_function(:ZBarcode_Cap, [:symbol_id, :cap_flag], :uint32)
|
|
71
|
+
|
|
72
|
+
# Return the version of Zint linked to
|
|
73
|
+
attach_function(:ZBarcode_Version, [], :int32)
|
|
74
|
+
|
|
75
|
+
# Raises specific error for API return code
|
|
76
|
+
#
|
|
77
|
+
# @param res [Symbol, Integer] API return code
|
|
78
|
+
# @param text [String] error text
|
|
79
|
+
# @raise [Error]
|
|
80
|
+
def self.raise_error(res, text)
|
|
81
|
+
klass = ERROR_CLASS_FOR_RESULT[res.is_a?(Symbol) ? Zint::ERRORS[res] : res]
|
|
82
|
+
raise klass, text
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
private_constant :Native
|
|
87
|
+
end
|
data/lib/zint/nve18.rb
ADDED
data/lib/zint/pdf417.rb
ADDED
data/lib/zint/pharma.rb
ADDED
data/lib/zint/planet.rb
ADDED
data/lib/zint/plessey.rb
ADDED
data/lib/zint/postnet.rb
ADDED
data/lib/zint/pzn.rb
ADDED
data/lib/zint/qr.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Zint
|
|
2
|
+
# QR Code
|
|
3
|
+
class Qr < Barcode
|
|
4
|
+
# ECC Levels
|
|
5
|
+
ECC_LEVEL_L = 1
|
|
6
|
+
ECC_LEVEL_M = 2
|
|
7
|
+
ECC_LEVEL_Q = 3
|
|
8
|
+
ECC_LEVEL_H = 4
|
|
9
|
+
|
|
10
|
+
# Current ECC level of QR code
|
|
11
|
+
attr_reader :ecc_level
|
|
12
|
+
|
|
13
|
+
def initialize(value: nil, input_file: nil, ecc_level: ECC_LEVEL_L, **kwargs)
|
|
14
|
+
super(value: value, input_file: input_file, symbology: Zint::BARCODE_QRCODE, **kwargs.merge(option_1: ecc_level))
|
|
15
|
+
@ecc_level = ecc_level
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/zint/rmqr.rb
ADDED
data/lib/zint/rss14.rb
ADDED
data/lib/zint/rssexp.rb
ADDED
data/lib/zint/rssltd.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Zint
|
|
2
|
+
module Structs
|
|
3
|
+
# Structured Append info - ignored unless `zint_structapp.count` is set to non-zero value
|
|
4
|
+
class Structapp < FFI::Struct
|
|
5
|
+
layout :index, :int, # Position in Structured Append sequence, 1-based. Must be <= `count`
|
|
6
|
+
:count, :int, # Number of symbols in Structured Append sequence. Set >= 2 to add SA Info
|
|
7
|
+
:id, [:char, 32] # Optional ID to distinguish sequence, ASCII, NUL-terminated unless max 32 long
|
|
8
|
+
|
|
9
|
+
# Position in Structured Append sequence, 1-based. Must be <= `count`
|
|
10
|
+
def index
|
|
11
|
+
self[:index]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Number of symbols in Structured Append sequence. Set >= 2 to add SA Info
|
|
15
|
+
def count
|
|
16
|
+
self[:count]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Optional ID to distinguish sequence, ASCII, NUL-terminated unless max 32 long
|
|
20
|
+
def id
|
|
21
|
+
self[:id]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Zint
|
|
2
|
+
module Structs
|
|
3
|
+
class Symbol < FFI::ManagedStruct
|
|
4
|
+
layout :symbology, :int, # Symbol to use (see BARCODE_XXX below)
|
|
5
|
+
:height, :float, # Barcode height in X-dimensions (ignored for fixed-width barcodes)
|
|
6
|
+
:scale, :float, # Scale factor when printing barcode, i.e. adjusts X-dimension. Default 1
|
|
7
|
+
:whitespace_width, :int, # Width in X-dimensions of whitespace to left & right of barcode
|
|
8
|
+
:whitespace_height, :int, # Height in X-dimensions of whitespace above & below the barcode
|
|
9
|
+
:border_width, :int, # Size of border in X-dimensions
|
|
10
|
+
:output_options, :int, # Various output parameters (bind, box etc, see below)
|
|
11
|
+
:fgcolour, [:char, 10], # Foreground as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
|
|
12
|
+
:bgcolour, [:char, 10], # Background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
|
|
13
|
+
:fgcolor, :pointer, # Pointer to fgcolour (alternate spelling)
|
|
14
|
+
:bgcolor, :pointer, # Pointer to bgcolour (alternate spelling)
|
|
15
|
+
:outfile, [:char, 256], # Name of file to output to, NUL-terminated. Default "out.png" ("out.gif" if NO_PNG)
|
|
16
|
+
:primary, [:char, 128], # Primary message data (MaxiCode, Composite), NUL-terminated
|
|
17
|
+
:option_1, :int, # Symbol-specific options (see "../docs/manual.txt")
|
|
18
|
+
:option_2, :int, # Symbol-specific options
|
|
19
|
+
:option_3, :int, # Symbol-specific options
|
|
20
|
+
:show_hrt, :int, # Show (1) or hide (0) Human Readable Text (HRT). Default 1
|
|
21
|
+
:fontsize, :int, # Unused
|
|
22
|
+
:input_mode, :int, # Encoding of input data (see DATA_MODE etc below). Default DATA_MODE
|
|
23
|
+
:eci, :int, # Extended Channel Interpretation. Default 0 (none)
|
|
24
|
+
:dpmm, :float, # Resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)
|
|
25
|
+
:dot_size, :float, # Size of dots used in BARCODE_DOTTY_MODE. Default 0.8
|
|
26
|
+
:guard_descent, :float, # Height in X-dimensions that EAN/UPC guard bars descend. Default 5
|
|
27
|
+
:structapp, Structapp, # Structured Append info. Default structapp.count 0 (none)
|
|
28
|
+
:warn_level, :int, # Affects error/warning value returned by Zint API (see WARN_XXX below)
|
|
29
|
+
:debug, :int, # Debugging flags
|
|
30
|
+
:text, [:uchar, 128], # Human Readable Text (if any), UTF-8, NUL-terminated (output only)
|
|
31
|
+
:rows, :int, # Number of rows used by the symbol (output only)
|
|
32
|
+
:width, :int, # Width of the generated symbol (output only)
|
|
33
|
+
:encoded_data, [:uchar, 200 * 144], # Encoded data (output only). Allows for rows of 1152 modules
|
|
34
|
+
:row_height, [:float, 200], # Heights of rows (output only). Allows for 200 row DotCode
|
|
35
|
+
:errtxt, [:char, 100], # Error message if an error or warning occurs, NUL-terminated (output only)
|
|
36
|
+
:bitmap, :pointer, # Stored bitmap image (raster output only)
|
|
37
|
+
:bitmap_width, :int, # Width of bitmap image (raster output only)
|
|
38
|
+
:bitmap_height, :int, # Height of bitmap image (raster output only)
|
|
39
|
+
:alphamap, :pointer, # Array of alpha values used (raster output only)
|
|
40
|
+
:bitmap_byte_length, :uchar, # Size of BMP bitmap data (raster output only)
|
|
41
|
+
:vector, Vector.by_ref # Pointer to vector header (vector output only)
|
|
42
|
+
|
|
43
|
+
# @private
|
|
44
|
+
def self.release(ptr)
|
|
45
|
+
Native.ZBarcode_Delete(ptr)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Zint
|
|
2
|
+
module Structs
|
|
3
|
+
class Vector < FFI::Struct
|
|
4
|
+
layout :width, :float, # Width, height of barcode image (including text, whitespace)
|
|
5
|
+
:height, :float,
|
|
6
|
+
:rectangles, VectorRect.by_ref, # Pointer to first rectangle
|
|
7
|
+
:hexagons, VectorHexagon.by_ref, # Pointer to first hexagon
|
|
8
|
+
:strings, VectorString.by_ref, # Pointer to first string
|
|
9
|
+
:circles, VectorCircle.by_ref # Pointer to first circle
|
|
10
|
+
|
|
11
|
+
# Height of barcode image (including text, whitespace)
|
|
12
|
+
def height
|
|
13
|
+
self[:height]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Width of barcode image (including text, whitespace)
|
|
17
|
+
def width
|
|
18
|
+
self[:width]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Calls the given block and passes a VectorRect object for each rectangle to be printed.
|
|
22
|
+
def each_rectangle(&block)
|
|
23
|
+
each_vector(:rectangles, &block)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Calls the given block and passes a VectorHexagon object for each hexagon to be printed.
|
|
27
|
+
def each_hexagon(&block)
|
|
28
|
+
each_vector(:hexagons, &block)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Calls the given block and passes a VectorString object for each text string to be printed.
|
|
32
|
+
def each_string(&block)
|
|
33
|
+
each_vector(:strings, &block)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Calls the given block and passes a VectorCircle object for each circle to be printed.
|
|
37
|
+
def each_circle(&block)
|
|
38
|
+
each_vector(:circles, &block)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private def each_vector(attr)
|
|
42
|
+
return to_enum(:each_vector, attr) unless block_given?
|
|
43
|
+
|
|
44
|
+
o = self[attr]
|
|
45
|
+
until o.null?
|
|
46
|
+
# Avoid garbage collection of Vector (and hence Barcode) before Vector*, since all memory is freed by ZBarcode_Delete()
|
|
47
|
+
o.instance_variable_set(:@vector, self)
|
|
48
|
+
yield o
|
|
49
|
+
o = o[:next]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Zint
|
|
2
|
+
module Structs
|
|
3
|
+
class VectorCircle < FFI::Struct
|
|
4
|
+
layout :x, :float,
|
|
5
|
+
:y, :float,
|
|
6
|
+
:diameter, :float, # Circle diameter. Does not include width (if any)
|
|
7
|
+
:width, :float, # Width of circle perimeter (circumference). 0 for fill (disc)
|
|
8
|
+
:colour, :int, # Non-zero for draw with background colour (else draw with foreground colour)
|
|
9
|
+
:next, VectorCircle.by_ref # Pointer to next circle
|
|
10
|
+
|
|
11
|
+
# x position
|
|
12
|
+
def x
|
|
13
|
+
self[:x]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# y position
|
|
17
|
+
def y
|
|
18
|
+
self[:y]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# diameter
|
|
22
|
+
def diameter
|
|
23
|
+
self[:diameter]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Non-zero for draw with background colour
|
|
27
|
+
def colour
|
|
28
|
+
self[:colour]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Zint
|
|
2
|
+
module Structs
|
|
3
|
+
class VectorHexagon < FFI::Struct
|
|
4
|
+
layout :x, :float,
|
|
5
|
+
:y, :float,
|
|
6
|
+
:diameter, :float,
|
|
7
|
+
:rotation, :int, # 0, 90, 180, 270 degrees
|
|
8
|
+
:next, VectorHexagon.by_ref # Pointer to next hexagon
|
|
9
|
+
|
|
10
|
+
# x position
|
|
11
|
+
def x
|
|
12
|
+
self[:x]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# y position
|
|
16
|
+
def y
|
|
17
|
+
self[:y]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# diameter
|
|
21
|
+
def diameter
|
|
22
|
+
self[:diameter]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# 0, 90, 180, 270 degrees
|
|
26
|
+
def rotation
|
|
27
|
+
self[:rotation]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Zint
|
|
2
|
+
module Structs
|
|
3
|
+
class VectorRect < FFI::Struct
|
|
4
|
+
layout :x, :float,
|
|
5
|
+
:y, :float,
|
|
6
|
+
:height, :float,
|
|
7
|
+
:width, :float,
|
|
8
|
+
:colour, :int, # -1 for foreground, 1-8 for Cyan, Blue, Magenta, Red, Yellow, Green, Black, White
|
|
9
|
+
:next, VectorRect.by_ref # Pointer to next rectangle
|
|
10
|
+
|
|
11
|
+
# x position
|
|
12
|
+
def x
|
|
13
|
+
self[:x]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# y position
|
|
17
|
+
def y
|
|
18
|
+
self[:y]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# height
|
|
22
|
+
def height
|
|
23
|
+
self[:height]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# width
|
|
27
|
+
def width
|
|
28
|
+
self[:width]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# -1 for foreground, 1-8 for Cyan, Blue, Magenta, Red, Yellow, Green, Black, White
|
|
32
|
+
def colour
|
|
33
|
+
self[:colour]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Zint
|
|
2
|
+
module Structs
|
|
3
|
+
class VectorString < FFI::Struct
|
|
4
|
+
layout :x, :float, # x, y position relative to halign
|
|
5
|
+
:y, :float,
|
|
6
|
+
:fsize, :float, # font size
|
|
7
|
+
:width, :float, # Suggested string width, may be 0 if none recommended
|
|
8
|
+
:length, :int, # Number of characters
|
|
9
|
+
:rotation, :int, # 0, 90, 180, 270 degrees
|
|
10
|
+
:halign, :int, # Horizontal alignment: 0 for centre, 1 for left, 2 for right (end)
|
|
11
|
+
:text, :pointer, # the text string to be printed
|
|
12
|
+
:next, VectorString.by_ref # Pointer to next string
|
|
13
|
+
|
|
14
|
+
# x position relative to halign
|
|
15
|
+
def x
|
|
16
|
+
self[:x]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# y position
|
|
20
|
+
def y
|
|
21
|
+
self[:y]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# font size
|
|
25
|
+
def fsize
|
|
26
|
+
self[:fsize]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Suggested string width, may be 0 if none recommended
|
|
30
|
+
def width
|
|
31
|
+
self[:width]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# 0, 90, 180, 270 degrees
|
|
35
|
+
def rotation
|
|
36
|
+
self[:rotation]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Horizontal alignment: 0 for centre, 1 for left, 2 for right (end)
|
|
40
|
+
def halign
|
|
41
|
+
self[:halign]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# the text string to be printed
|
|
45
|
+
def text
|
|
46
|
+
self[:text].read_bytes(self[:length])
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/zint/telepen.rb
ADDED