line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
20
|
|
|
20
|
|
78777
|
use v5.12; |
|
20
|
|
|
|
|
87
|
|
2
|
20
|
|
|
20
|
|
99
|
use warnings; |
|
20
|
|
|
|
|
36
|
|
|
20
|
|
|
|
|
44339
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# logic of value hash keys for all color spacs |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Basis; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
74
|
|
|
74
|
0
|
2552
|
my ($pkg, $axis_names, $name_shortcuts, $prefix) = @_; |
10
|
74
|
100
|
|
|
|
295
|
return unless ref $axis_names eq 'ARRAY'; |
11
|
71
|
50
|
33
|
|
|
248
|
return if defined $name_shortcuts and (ref $name_shortcuts ne 'ARRAY' or @$axis_names != @$name_shortcuts); |
|
|
|
66
|
|
|
|
|
12
|
71
|
|
|
|
|
162
|
my @keys = map {lc} @$axis_names; |
|
222
|
|
|
|
|
560
|
|
13
|
71
|
100
|
|
|
|
207
|
my @shortcuts = map { _color_key_shortcut($_) } (defined $name_shortcuts) ? @$name_shortcuts : @keys; |
|
222
|
|
|
|
|
348
|
|
14
|
71
|
50
|
|
|
|
228
|
return unless @keys > 0; |
15
|
|
|
|
|
|
|
|
16
|
71
|
|
|
|
|
275
|
my @iterator = 0 .. $#keys; |
17
|
71
|
|
|
|
|
147
|
my %key_order = map { $keys[$_] => $_ } @iterator; |
|
222
|
|
|
|
|
633
|
|
18
|
71
|
|
|
|
|
151
|
my %shortcut_order = map { $shortcuts[$_] => $_ } @iterator; |
|
222
|
|
|
|
|
477
|
|
19
|
71
|
|
|
|
|
753
|
bless { keys => [@keys], shortcuts => [@shortcuts], |
20
|
|
|
|
|
|
|
key_order => \%key_order, shortcut_order => \%shortcut_order, |
21
|
|
|
|
|
|
|
name => uc (join('', @shortcuts)), count => int @keys, iterator => \@iterator } |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
267
|
|
|
267
|
0
|
373
|
sub keys { @{$_[0]{'keys'}} } |
|
267
|
|
|
|
|
830
|
|
25
|
26
|
|
|
26
|
0
|
33
|
sub shortcuts{ @{$_[0]{'shortcuts'}} } |
|
26
|
|
|
|
|
101
|
|
26
|
2575
|
|
|
2575
|
0
|
2995
|
sub iterator { @{$_[0]{'iterator'}} } |
|
2575
|
|
|
|
|
5293
|
|
27
|
4242
|
|
|
4242
|
0
|
12608
|
sub count { $_[0]{'count'} } |
28
|
2274
|
|
|
2274
|
0
|
6806
|
sub name { $_[0]{'name'} } |
29
|
|
|
|
|
|
|
|
30
|
87
|
50
|
|
87
|
0
|
287
|
sub key_pos { defined $_[1] ? $_[0]->{'key_order'}{ lc $_[1] } : undef} |
31
|
197
|
50
|
|
197
|
0
|
622
|
sub shortcut_pos { defined $_[1] ? $_[0]->{'shortcut_order'}{ lc $_[1] } : undef } |
32
|
538
|
100
|
100
|
538
|
0
|
2253
|
sub is_key { (defined $_[1] and exists $_[0]->{'key_order'}{ lc $_[1] }) ? 1 : 0 } |
33
|
364
|
100
|
66
|
364
|
0
|
1516
|
sub is_shortcut { (defined $_[1] and exists $_[0]->{'shortcut_order'}{ lc $_[1] }) ? 1 : 0 } |
34
|
218
|
100
|
|
218
|
0
|
345
|
sub is_key_or_shortcut { $_[0]->is_key($_[1]) or $_[0]->is_shortcut($_[1]) } |
35
|
|
|
|
|
|
|
sub is_string { |
36
|
593
|
|
|
593
|
0
|
861
|
my ($self, $string) = @_; |
37
|
593
|
100
|
66
|
|
|
2297
|
return 0 unless defined $string and not ref $string; |
38
|
104
|
|
|
|
|
183
|
$string = lc $string; |
39
|
104
|
|
|
|
|
225
|
my $name = lc $self->name; |
40
|
104
|
100
|
|
|
|
405
|
return 0 unless index($string, $name.':') == 0; |
41
|
41
|
|
|
|
|
71
|
my $nr = '\s*-?\d+(?:\.\d+)?\s*'; |
42
|
41
|
|
|
|
|
130
|
my $nrs = join(',', ('\s*-?\d+(?:\.\d+)?\s*') x $self->count); |
43
|
41
|
50
|
|
|
|
793
|
($string =~ /^$name:$nrs$/) ? 1 : 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
sub is_css_string { |
46
|
541
|
|
|
541
|
0
|
783
|
my ($self, $string) = @_; |
47
|
541
|
100
|
66
|
|
|
2124
|
return 0 unless defined $string and not ref $string; |
48
|
70
|
|
|
|
|
127
|
$string = lc $string; |
49
|
70
|
|
|
|
|
129
|
my $name = lc $self->name; |
50
|
70
|
100
|
|
|
|
318
|
return 0 unless index($string, $name.'(') == 0; |
51
|
2
|
|
|
|
|
6
|
my $nr = '\s*-?\d+(?:\.\d+)?\s*'; |
52
|
2
|
|
|
|
|
7
|
my $nrs = join(',', ('\s*-?\d+(?:\.\d+)?\s*') x $self->count); |
53
|
2
|
50
|
|
|
|
75
|
($string =~ /^$name\($nrs\)$/) ? 1 : 0; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
sub is_array { |
56
|
3035
|
|
|
3035
|
0
|
4429
|
my ($self, $value_array) = @_; |
57
|
3035
|
100
|
100
|
|
|
14138
|
(ref $value_array eq 'ARRAY' and @$value_array == $self->{'count'}) ? 1 : 0; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
sub is_named_array { |
60
|
667
|
|
|
667
|
0
|
973
|
my ($self, $value_array) = @_; |
61
|
667
|
100
|
100
|
|
|
2792
|
(ref $value_array eq 'ARRAY' and @$value_array == ($self->{'count'}+1) |
62
|
|
|
|
|
|
|
and uc $value_array->[0] eq uc $self->name) ? 1 : 0; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
sub is_hash { |
65
|
657
|
|
|
657
|
0
|
954
|
my ($self, $value_hash) = @_; |
66
|
657
|
100
|
100
|
|
|
2272
|
return 0 unless ref $value_hash eq 'HASH' and CORE::keys %$value_hash == $self->{'count'}; |
67
|
116
|
|
|
|
|
255
|
for (CORE::keys %$value_hash) { |
68
|
200
|
100
|
|
|
|
321
|
return 0 unless $self->is_key_or_shortcut($_); |
69
|
|
|
|
|
|
|
} |
70
|
38
|
|
|
|
|
164
|
return 1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
sub is_partial_hash { |
73
|
9
|
|
|
9
|
0
|
22
|
my ($self, $value_hash) = @_; |
74
|
9
|
100
|
|
|
|
54
|
return 0 unless ref $value_hash eq 'HASH'; |
75
|
8
|
|
|
|
|
21
|
my $key_count = CORE::keys %$value_hash; |
76
|
8
|
100
|
66
|
|
|
46
|
return 0 unless $key_count and $key_count <= $self->{'count'}; |
77
|
7
|
|
|
|
|
19
|
for (CORE::keys %$value_hash) { |
78
|
14
|
100
|
|
|
|
26
|
return 0 unless $self->is_key_or_shortcut($_); |
79
|
|
|
|
|
|
|
} |
80
|
6
|
|
|
|
|
25
|
return 1; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
######################################################################## |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub key_shortcut { |
86
|
22
|
|
|
22
|
0
|
41
|
my ($self, $key) = @_; |
87
|
22
|
50
|
|
|
|
37
|
return unless $self->is_key( $key ); |
88
|
22
|
|
|
|
|
54
|
($self->shortcuts)[ $self->{'key_order'}{ lc $key } ]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub list_value_from_key { |
92
|
6
|
|
|
6
|
0
|
366
|
my ($self, $key, @values) = @_; |
93
|
6
|
|
|
|
|
13
|
$key = lc $key; |
94
|
6
|
100
|
|
|
|
27
|
return unless @values == $self->{'count'}; |
95
|
4
|
100
|
|
|
|
15
|
return unless exists $self->{'key_order'}{ $key }; |
96
|
3
|
|
|
|
|
47
|
return $values[ $self->{'key_order'}{ $key } ]; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub list_value_from_shortcut { |
100
|
4
|
|
|
4
|
0
|
10
|
my ($self, $shortcut, @values) = @_; |
101
|
4
|
|
|
|
|
7
|
$shortcut = lc $shortcut; |
102
|
4
|
50
|
|
|
|
34
|
return unless @values == $self->{'count'}; |
103
|
4
|
100
|
|
|
|
13
|
return unless exists $self->{'shortcut_order'}{ $shortcut }; |
104
|
3
|
|
|
|
|
16
|
return $values[ $self->{'shortcut_order'}{ $shortcut } ]; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub list_from_hash { |
108
|
36
|
|
|
36
|
0
|
3222
|
my ($self, $value_hash) = @_; |
109
|
36
|
50
|
33
|
|
|
154
|
return undef unless ref $value_hash eq 'HASH' and CORE::keys %$value_hash == $self->{'count'}; |
110
|
36
|
|
|
|
|
105
|
my @values = (0) x $self->{'count'}; |
111
|
36
|
|
|
|
|
85
|
for my $value_key (CORE::keys %$value_hash) { |
112
|
112
|
100
|
|
|
|
172
|
if ($self->is_key( $value_key )) { $values[ $self->{'key_order'}{ lc $value_key } ] = $value_hash->{ $value_key } } |
|
15
|
100
|
|
|
|
35
|
|
113
|
96
|
|
|
|
|
202
|
elsif ($self->is_shortcut( $value_key )) { $values[ $self->{'shortcut_order'}{ lc $value_key } ] = $value_hash->{ $value_key } } |
114
|
1
|
|
|
|
|
5
|
else { return } |
115
|
|
|
|
|
|
|
} |
116
|
35
|
|
|
|
|
118
|
return @values; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub deformat_partial_hash { |
120
|
87
|
|
|
87
|
0
|
4485
|
my ($self, $value_hash) = @_; |
121
|
87
|
100
|
|
|
|
204
|
return unless ref $value_hash eq 'HASH'; |
122
|
86
|
|
|
|
|
179
|
my @keys_got = CORE::keys %$value_hash; |
123
|
86
|
100
|
100
|
|
|
289
|
return unless @keys_got and @keys_got <= $self->{'count'}; |
124
|
76
|
|
|
|
|
117
|
my $result = {}; |
125
|
76
|
|
|
|
|
110
|
for my $key (@keys_got) { |
126
|
88
|
100
|
|
|
|
188
|
if ($self->is_key( $key )) { $result->{ int $self->key_pos( $key ) } = $value_hash->{ $key } } |
|
16
|
100
|
|
|
|
38
|
|
127
|
17
|
|
|
|
|
54
|
elsif ($self->is_shortcut( $key )){ $result->{ int $self->shortcut_pos( $key ) } = $value_hash->{ $key } } |
128
|
55
|
|
|
|
|
133
|
else { return undef } |
129
|
|
|
|
|
|
|
} |
130
|
21
|
|
|
|
|
54
|
return $result; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub list_from_string { |
134
|
41
|
|
|
41
|
0
|
118
|
my ($self, $string) = @_; |
135
|
41
|
|
|
|
|
133
|
my @parts = split(/:/, $string); |
136
|
41
|
|
|
|
|
113
|
return map {$_ + 0} split(/,/, $parts[1]); |
|
125
|
|
|
|
|
453
|
|
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub list_from_css { |
140
|
2
|
|
|
2
|
0
|
8
|
my ($self, $string) = @_; |
141
|
2
|
|
|
|
|
19
|
1 until chop($string) eq ')'; |
142
|
2
|
|
|
|
|
10
|
my @parts = split(/\(/, $string); |
143
|
2
|
|
|
|
|
8
|
return map {$_ + 0} split(/,/, $parts[1]); |
|
6
|
|
|
|
|
25
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub key_hash_from_list { |
147
|
21
|
|
|
21
|
0
|
61
|
my ($self, @values) = @_; |
148
|
21
|
100
|
|
|
|
67
|
return unless @values == $self->{'count'}; |
149
|
19
|
|
|
|
|
29
|
return { map { $self->{'keys'}[$_] => $values[$_]} @{$self->{'iterator'}} }; |
|
72
|
|
|
|
|
249
|
|
|
19
|
|
|
|
|
46
|
|
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub shortcut_hash_from_list { |
153
|
8
|
|
|
8
|
0
|
19
|
my ($self, @values) = @_; |
154
|
8
|
100
|
|
|
|
30
|
return unless @values == $self->{'count'}; |
155
|
6
|
|
|
|
|
11
|
return { map {$self->{'shortcuts'}[$_] => $values[$_]} @{$self->{'iterator'}} }; |
|
18
|
|
|
|
|
77
|
|
|
6
|
|
|
|
|
15
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub named_array_from_list { |
159
|
1
|
|
|
1
|
0
|
4
|
my ($self, @values) = @_; |
160
|
1
|
50
|
|
|
|
5
|
return [lc $self->name, @values] if @values == $self->{'count'}; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub named_string_from_list { |
164
|
42
|
|
|
42
|
0
|
89
|
my ($self, @values) = @_; |
165
|
42
|
50
|
|
|
|
153
|
return unless @values == $self->{'count'}; |
166
|
42
|
|
|
|
|
158
|
lc( $self->name).': '.join(', ', @values); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub css_string_from_list { |
170
|
4
|
|
|
4
|
0
|
12
|
my ($self, @values) = @_; |
171
|
4
|
50
|
|
|
|
13
|
return unless @values == $self->{'count'}; |
172
|
4
|
|
|
|
|
12
|
lc( $self->name).'('.join(',', @values).')'; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
222
|
50
|
|
222
|
|
977
|
sub _color_key_shortcut { lc substr($_[0], 0, 1) if defined $_[0] } |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |