line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FuseBead::From::PNG::View::HTML; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
721
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
16
|
$FuseBead::From::PNG::VERSION = '0.02'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use parent qw(FuseBead::From::PNG::View); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
49
|
use FuseBead::From::PNG::Const qw(:all); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
816
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
7
|
use Data::Debug; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
570
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub print { |
17
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
18
|
0
|
0
|
|
|
|
|
my %args = ref $_[0] eq 'HASH' ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my @styles; |
21
|
|
|
|
|
|
|
my @bead_list; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $bead_diameter = FuseBead::From::PNG::Bead->new({ color => [ FuseBead::From::PNG::Const->BEAD_COLORS ]->[0] })->diameter; |
24
|
0
|
|
|
|
|
|
my $border_width = 1; |
25
|
0
|
|
|
|
|
|
my $pixel_size = $bead_diameter * FuseBead::From::PNG::Const->MILLIMETER_TO_PIXEL - $border_width * 2; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
push @styles, ".picture { border-collapse: collapse; page-break-before: always; }"; |
28
|
0
|
|
|
|
|
|
push @styles, ".picture td { height: ${pixel_size}px; width: ${pixel_size}px; border: solid black ${border_width}px; padding: 0; }"; |
29
|
0
|
|
|
|
|
|
push @styles, ".bead_display { margin-top: 1em; }"; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $bead_total = 0; |
32
|
0
|
|
|
|
|
|
for my $color (sort { $a->{'color'} cmp $b->{'color'} } values %{$args{'beads'}}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $cid = $color->{'color'}; |
34
|
0
|
|
|
|
|
|
my $bead_color = $self->png->bead_colors->{$cid}; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
push @styles, '.'.lc($cid).' { background: #'.$bead_color->{'hex_color'}.'; }'; |
37
|
0
|
|
|
|
|
|
push @bead_list, ' |
'.$bead_color->{'name'}.' | '.$color->{'quantity'}.' |
';
38
|
0
|
|
|
|
|
|
$bead_total += $color->{'quantity'}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $html; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Styles |
44
|
0
|
|
|
|
|
|
$html .= qq{\n\n}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Info |
49
|
0
|
|
|
|
|
|
my $rows = $args{'info'}{'rows'}; |
50
|
0
|
|
|
|
|
|
my $cols = $args{'info'}{'cols'}; |
51
|
|
|
|
|
|
|
my $length = $args{'info'}{'metric'}{'length'} |
52
|
|
|
|
|
|
|
. ' ' |
53
|
|
|
|
|
|
|
. FuseBead::From::PNG::Const->METRIC_SUFFIX |
54
|
|
|
|
|
|
|
. ' (' |
55
|
0
|
|
|
|
|
|
. $args{'info'}{'imperial'}{'length'} |
56
|
|
|
|
|
|
|
. ' ' |
57
|
|
|
|
|
|
|
. FuseBead::From::PNG::Const->IMPERIAL_SUFFIX |
58
|
|
|
|
|
|
|
. ')'; |
59
|
|
|
|
|
|
|
my $height = $args{'info'}{'metric'}{'height'} |
60
|
|
|
|
|
|
|
. ' ' |
61
|
|
|
|
|
|
|
. FuseBead::From::PNG::Const->METRIC_SUFFIX |
62
|
|
|
|
|
|
|
. ' (' |
63
|
0
|
|
|
|
|
|
. $args{'info'}{'imperial'}{'height'} |
64
|
|
|
|
|
|
|
. ' ' |
65
|
|
|
|
|
|
|
. FuseBead::From::PNG::Const->IMPERIAL_SUFFIX |
66
|
|
|
|
|
|
|
. ')'; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$html .= qq{ |
69
|
0
|
|
|
|
|
|
$html .= qq{Info\n}; |
70
|
0
|
|
|
|
|
|
$html .= qq{\n};
71
|
0
|
|
|
|
|
|
$html .= qq{ | Rows: | $rows | \n};
72
|
0
|
|
|
|
|
|
$html .= qq{ | Cols: | $cols | \n};
73
|
0
|
|
|
|
|
|
$html .= qq{ | Length: | $length | \n};
74
|
0
|
|
|
|
|
|
$html .= qq{ | Height: | $height | \n};
75
|
0
|
|
|
|
|
|
$html .= qq{ | \n}; |
76
|
0
|
|
|
|
|
|
$html .= qq{\n\n}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Bead List |
79
|
0
|
|
|
|
|
|
$html .= qq{ |
80
|
0
|
|
|
|
|
|
$html .= qq{Bead List\n}; |
81
|
0
|
|
|
|
|
|
$html .= qq{ Total Beads - $bead_total \n}; |
82
|
0
|
|
|
|
|
|
$html .= qq{Bead | Quantity | \n};
83
|
0
|
|
|
|
|
|
$html .= $_."\n" for @bead_list; |
84
|
0
|
|
|
|
|
|
$html .= qq{ | \n}; |
85
|
0
|
|
|
|
|
|
$html .= qq{\n\n}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Picture |
88
|
0
|
|
|
|
|
|
$html .= qq{ |
89
|
0
|
|
|
|
|
|
$html .= qq{\n};
90
|
0
|
|
|
|
|
|
$html .= qq{ | }; # first
91
|
0
|
|
|
|
|
|
my $y = 0; |
92
|
0
|
|
|
|
|
|
for my $color (@{$args{'plan'}}) { |
|
0
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my ($class, $name) = (lc($color->{'color'}), $self->png->bead_colors->{$color->{'color'}}{'name'}); |
94
|
0
|
0
|
|
|
|
|
if($y != $color->{'meta'}{'y'}) { |
95
|
0
|
|
|
|
|
|
$html .= qq{ | \n};
96
|
0
|
|
|
|
|
|
$y = $color->{'meta'}{'y'}; |
97
|
|
|
|
|
|
|
} |
98
|
0
|
|
|
|
|
|
$html .= qq[ | | ];
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
$html .= qq{ | \n}; # last
101
|
0
|
|
|
|
|
|
$html .= qq{ | \n}; |
102
|
0
|
|
|
|
|
|
$html .= qq{\n}; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return $html; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=pod |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 NAME |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
FuseBead::From::PNG::View::HTML - Format data returned from FuseBead::From::PNG |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SYNOPSIS |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
use FuseBead::From::PNG; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $object = FuseBead::From::PNG->new({ filename => 'my_png.png' }); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$object->process(view => 'HTML'); # Data is returned as HTML |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DESCRIPTION |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Class to returned processed data in HTML format |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 USAGE |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 new |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Usage : ->new() |
130
|
|
|
|
|
|
|
Purpose : Returns FuseBead::From::PNG::View::HTML object |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Returns : FuseBead::From::PNG::View::HTML object |
133
|
|
|
|
|
|
|
Argument : |
134
|
|
|
|
|
|
|
Throws : |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Comment : |
137
|
|
|
|
|
|
|
See Also : |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 print |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Usage : ->print({}) or ->print(key1 => val1, key2 => val2) |
142
|
|
|
|
|
|
|
Purpose : Returns HTML formated data (in utf8 and pretty format) |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Returns : Returns HTML formated data (in utf8 and pretty format) |
145
|
|
|
|
|
|
|
Argument : |
146
|
|
|
|
|
|
|
Throws : |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Comment : |
149
|
|
|
|
|
|
|
See Also : |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 BUGS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SUPPORT |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHOR |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Travis Chase |
158
|
|
|
|
|
|
|
CPAN ID: GAUDEON |
159
|
|
|
|
|
|
|
gaudeon@cpan.org |
160
|
|
|
|
|
|
|
https://github.com/gaudeon/FuseBead-From-Png |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 COPYRIGHT |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This program is free software licensed under the... |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The MIT License |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
The full text of the license can be found in the |
169
|
|
|
|
|
|
|
LICENSE file included with this module. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 SEE ALSO |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
perl(1). |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |