File Coverage

blib/lib/SVG/Barcode/DataMatrix.pm
Criterion Covered Total %
statement 40 40 100.0
branch n/a
condition 1 3 33.3
subroutine 12 12 100.0
pod 1 1 100.0
total 54 56 96.4


line stmt bran cond sub pod time code
1             package SVG::Barcode::DataMatrix;
2 2     2   140148 use parent 'SVG::Barcode';
  2         657  
  2         12  
3 2     2   24171 use strict;
  2         4  
  2         42  
4 2     2   10 use warnings;
  2         4  
  2         57  
5 2     2   13 use utf8;
  2         3  
  2         12  
6 2     2   61 use v5.24;
  2         6  
7 2     2   9 use feature 'signatures';
  2         4  
  2         155  
8 2     2   11 no warnings 'experimental::signatures';
  2         4  
  2         77  
9              
10 2     2   12 use Exporter 'import';
  2         4  
  2         88  
11             our @EXPORT_OK = qw|plot_datamatrix|;
12              
13 2     2   950 use Barcode::DataMatrix;
  2         112048  
  2         140  
14              
15             our $VERSION = '0.14';
16              
17 2         640 use constant DEFAULTS => {
18             dotsize => 1,
19             encoding_mode => 'AUTO',
20             process_tilde => 0,
21             size => 'AUTO',
22 2     2   21 };
  2         19  
23              
24             SVG::Barcode::_param(__PACKAGE__, $_, DEFAULTS->{$_}) for keys DEFAULTS->%*;
25              
26             # functions
27              
28 3     3 1 50052 sub plot_datamatrix ($text, %params) {
  2         4  
  2         46  
  2         11  
29 2         21 return __PACKAGE__->new(%params)->plot($text);
30             }
31              
32             # internal methods
33              
34 4     4   38303 sub _plot ($self, $text) {
  4         21  
  4         7  
  4         12  
35             $self->{plotter}
36 4   33     95 ||= Barcode::DataMatrix->new($self->%{qw|encoding_mode process_tilde size|});
37 4         4356 $self->_plot_2d($self->{plotter}->barcode($text), 1);
38             }
39              
40             1;
41              
42             =encoding utf8
43              
44             =head1 NAME
45              
46             SVG::Barcode::DataMatrix - Generator for SVG based Data Matrix barcodes
47              
48             =head1 SYNOPSIS
49              
50             use SVG::Barcode::DataMatrix;
51              
52             my $datamatrix = SVG::Barcode::DataMatrix->new;
53             my $svg = $datamatrix->plot('https://perldoc.pl');
54              
55             $datamatrix->dotsize; # 1
56             $datamatrix->encoding_mode; # AUTO
57             $datamatrix->process_tilde; # 0
58             $datamatrix->size; # AUTO
59             # from SVG::Barcode:
60             $datamatrix->foreground; # black
61             $datamatrix->background; # white
62             $datamatrix->margin; # 2
63             $datamatrix->id;
64             $datamatrix->class;
65             $datamatrix->width;
66             $datamatrix->height;
67             $datamatrix->scale;
68              
69             my %params = (
70             level => 'H',
71             margin => 4,
72             );
73             $datamatrix = SVG::Barcode::DataMatrix->new(%params);
74              
75             # use as function
76             use SVG::Barcode::DataMatrix 'plot_datamatrix';
77              
78             $svg = plot_datamatrix('https://perldoc.pl', %params);
79              
80             =head1 DESCRIPTION
81              
82             L is a generator for SVG based Data Matrix barcodes.
83              
84             =head1 FUNCTIONS
85              
86             =head2 plot_datamatrix
87              
88             use SVG::Barcode::DataMatrix 'plot_datamatrix';
89              
90             $svg = plot_datamatrix($text, %params);
91              
92             Returns a Data Matrix using the provided text and parameters.
93              
94             =head1 CONSTRUCTOR
95              
96             =head2 new
97              
98             $datamatrix = SVG::Barcode::DataMatrix->new; # create with defaults
99             $datamatrix = SVG::Barcode::DataMatrix->new(%params);
100              
101             Creates a new Data Matrix plotter. Inherited from L.
102              
103             =head1 METHODS
104              
105             =head2 plot
106              
107             $svg = $datamatrix->plot($text);
108              
109             Creates a SVG code. Inherited from L.
110              
111             =head1 PARAMETERS
112              
113             Inherited from L:
114             L,
115             L,
116             L,
117             L,
118             L,
119             L,
120             L,
121             L.
122              
123             =head2 dotsize
124              
125             $value = $datamatrix->dotsize;
126             $datamatrix = $datamatrix->dotsize($newvalue);
127             $datamatrix = $datamatrix->dotsize(''); # 1
128              
129             Getter and setter for the size of the dots. Default C<1>.
130              
131             =head2 encoding_mode
132              
133             $value = $datamatrix->encoding_mode;
134             $datamatrix = $datamatrix->encoding_mode($newvalue);
135             $datamatrix = $datamatrix->encoding_mode(''); # AUTO
136              
137             Getter and setter for the encoding mode.
138             One of C, C, C, C, C, or C. Default C.
139              
140             =head2 process_tilde
141              
142             $value = $datamatrix->process_tilde;
143             $datamatrix = $datamatrix->process_tilde($newvalue);
144             $datamatrix = $datamatrix->process_tilde(''); # 0
145              
146             Getter and setter for the tilde flag.
147             If set to C<1> the tilde character C<~> is being used to recognize special characters.
148             Default C<0>.
149              
150             =head2 size
151              
152             $value = $datamatrix->size;
153             $datamatrix = $datamatrix->size($newvalue);
154             $datamatrix = $datamatrix->size(''); # AUTO
155              
156             Getter and setter for the module size of the matrix. C, one of C, C<10x10>,
157             C<12x12>, C<14x14>, C<16x16>, C<18x18>, C<20x20>, C<22x22>, C<24x24>, C<26x26>, C<32x32>, C<36x36>,
158             C<40x40>, C<44x44>, C<48x48>, C<52x52>, C<64x64>, C<72x72>, C<80x80>, C<88x88>, C<96x96>,
159             C<104x104>, C<120x120>, C<132x132>, C<144x144>, C<8x18>, C<8x32>, C<12x26>, C<12x36>, C<16x36>,
160             C<16x48>. Default C.
161              
162             =head1 AUTHOR & COPYRIGHT
163              
164             © 2019–2020 by Tekki (Rolf Stöckli).
165              
166             This program is free software, you can redistribute it and/or modify it under the terms of the
167             Artistic License version 2.0.
168              
169             =head1 SEE ALSO
170              
171             L, L.
172              
173             =cut