| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FuseBead::From::PNG::View::HTML; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
645
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
66
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
27
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
|
7
|
1
|
|
|
1
|
|
13
|
$FuseBead::From::PNG::VERSION = '0.02'; |
|
8
|
|
|
|
|
|
|
} |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
3
|
use parent qw(FuseBead::From::PNG::View); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
3
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
54
|
use FuseBead::From::PNG::Const qw(:all); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
754
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
4
|
use Data::Debug; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
499
|
|
|
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
|
|
|
|
|
|
$html .= qq{ |
|
50
|
0
|
|
|
|
|
|
$html .= qq{Info\n}; |
|
51
|
0
|
|
|
|
|
|
for my $type(qw/metric imperial/) { |
|
52
|
0
|
0
|
|
|
|
|
if (exists $args{'info'}{$type}) { |
|
53
|
0
|
|
|
|
|
|
my $suffix_key = uc($type) . '_SUFFIX'; |
|
54
|
0
|
|
|
|
|
|
my $suffix = FuseBead::From::PNG::Const->$suffix_key; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my ($length, $height) = @{$args{'info'}{$type}}{qw/length height/}; |
|
|
0
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$html .= qq{\n};
|
58
|
0
|
|
|
|
|
|
$html .= qq{ | | Length: | $length $suffix | \n};
|
59
|
0
|
|
|
|
|
|
$html .= qq{ | | Height: | $height $suffix | \n};
|
60
|
0
|
|
|
|
|
|
$html .= qq{ | \n}; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} |
|
63
|
0
|
|
|
|
|
|
$html .= qq{\n\n}; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Bead List |
|
66
|
0
|
|
|
|
|
|
$html .= qq{ |
|
67
|
0
|
|
|
|
|
|
$html .= qq{Bead List\n}; |
|
68
|
0
|
|
|
|
|
|
$html .= qq{ Total Beads - $bead_total \n}; |
|
69
|
0
|
|
|
|
|
|
$html .= qq{| Bead | Quantity | \n};
|
70
|
0
|
|
|
|
|
|
$html .= $_."\n" for @bead_list; |
|
71
|
0
|
|
|
|
|
|
$html .= qq{ | \n}; |
|
72
|
0
|
|
|
|
|
|
$html .= qq{\n\n}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Picture |
|
75
|
0
|
|
|
|
|
|
$html .= qq{ |
|
76
|
0
|
|
|
|
|
|
$html .= qq{\n};
|
77
|
0
|
|
|
|
|
|
$html .= qq{ | }; # first
|
78
|
0
|
|
|
|
|
|
my $y = 0; |
|
79
|
0
|
|
|
|
|
|
for my $color (@{$args{'plan'}}) { |
|
|
0
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my ($class, $name) = (lc($color->{'color'}), $self->png->bead_colors->{$color->{'color'}}{'name'}); |
|
81
|
0
|
0
|
|
|
|
|
if($y != $color->{'meta'}{'y'}) { |
|
82
|
0
|
|
|
|
|
|
$html .= qq{ | \n};
|
83
|
0
|
|
|
|
|
|
$y = $color->{'meta'}{'y'}; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
0
|
|
|
|
|
|
$html .= qq[ | | ];
|
86
|
|
|
|
|
|
|
} |
|
87
|
0
|
|
|
|
|
|
$html .= qq{ | \n}; # last
|
88
|
0
|
|
|
|
|
|
$html .= qq{ | \n}; |
|
89
|
0
|
|
|
|
|
|
$html .= qq{\n}; |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return $html; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
FuseBead::From::PNG::View::HTML - Format data returned from FuseBead::From::PNG |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
use FuseBead::From::PNG; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $object = FuseBead::From::PNG->new({ filename => 'my_png.png' }); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$object->process(view => 'HTML'); # Data is returned as HTML |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Class to returned processed data in HTML format |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 USAGE |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 new |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Usage : ->new() |
|
117
|
|
|
|
|
|
|
Purpose : Returns FuseBead::From::PNG::View::HTML object |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Returns : FuseBead::From::PNG::View::HTML object |
|
120
|
|
|
|
|
|
|
Argument : |
|
121
|
|
|
|
|
|
|
Throws : |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Comment : |
|
124
|
|
|
|
|
|
|
See Also : |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 print |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Usage : ->print({}) or ->print(key1 => val1, key2 => val2) |
|
129
|
|
|
|
|
|
|
Purpose : Returns HTML formated data (in utf8 and pretty format) |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Returns : Returns HTML formated data (in utf8 and pretty format) |
|
132
|
|
|
|
|
|
|
Argument : |
|
133
|
|
|
|
|
|
|
Throws : |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Comment : |
|
136
|
|
|
|
|
|
|
See Also : |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 BUGS |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SUPPORT |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Travis Chase |
|
145
|
|
|
|
|
|
|
CPAN ID: GAUDEON |
|
146
|
|
|
|
|
|
|
gaudeon@cpan.org |
|
147
|
|
|
|
|
|
|
https://github.com/gaudeon/FuseBead-From-Png |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This program is free software licensed under the... |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
The MIT License |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
156
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
perl(1). |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |