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