line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
18
|
|
|
18
|
|
75142
|
use v5.12; |
|
18
|
|
|
|
|
72
|
|
2
|
18
|
|
|
18
|
|
86
|
use warnings; |
|
18
|
|
|
|
|
38
|
|
|
18
|
|
|
|
|
40063
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# logic of value hash keys for all color spacs |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Basis; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
72
|
|
|
72
|
0
|
2392
|
my ($pkg, $axis_names, $name_shortcuts, $prefix) = @_; |
10
|
72
|
100
|
|
|
|
266
|
return unless ref $axis_names eq 'ARRAY'; |
11
|
69
|
50
|
33
|
|
|
221
|
return if defined $name_shortcuts and (ref $name_shortcuts ne 'ARRAY' or @$axis_names != @$name_shortcuts); |
|
|
|
66
|
|
|
|
|
12
|
69
|
|
|
|
|
156
|
my @keys = map {lc} @$axis_names; |
|
216
|
|
|
|
|
520
|
|
13
|
69
|
100
|
|
|
|
176
|
my @shortcuts = map { _color_key_shortcut($_) } (defined $name_shortcuts) ? @$name_shortcuts : @keys; |
|
216
|
|
|
|
|
354
|
|
14
|
69
|
50
|
|
|
|
171
|
return unless @keys > 0; |
15
|
|
|
|
|
|
|
|
16
|
69
|
|
|
|
|
174
|
my @iterator = 0 .. $#keys; |
17
|
69
|
|
|
|
|
113
|
my %key_order = map { $keys[$_] => $_ } @iterator; |
|
216
|
|
|
|
|
549
|
|
18
|
69
|
|
|
|
|
138
|
my %shortcut_order = map { $shortcuts[$_] => $_ } @iterator; |
|
216
|
|
|
|
|
457
|
|
19
|
69
|
|
|
|
|
763
|
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
|
242
|
|
|
242
|
0
|
319
|
sub keys { @{$_[0]{'keys'}} } |
|
242
|
|
|
|
|
739
|
|
25
|
22
|
|
|
22
|
0
|
26
|
sub shortcuts{ @{$_[0]{'shortcuts'}} } |
|
22
|
|
|
|
|
86
|
|
26
|
2498
|
|
|
2498
|
0
|
2781
|
sub iterator { @{$_[0]{'iterator'}} } |
|
2498
|
|
|
|
|
5100
|
|
27
|
4044
|
|
|
4044
|
0
|
12073
|
sub count { $_[0]{'count'} } |
28
|
2168
|
|
|
2168
|
0
|
6460
|
sub name { $_[0]{'name'} } |
29
|
|
|
|
|
|
|
|
30
|
83
|
50
|
|
83
|
0
|
274
|
sub key_pos { defined $_[1] ? $_[0]->{'key_order'}{ lc $_[1] } : undef} |
31
|
182
|
50
|
|
182
|
0
|
578
|
sub shortcut_pos { defined $_[1] ? $_[0]->{'shortcut_order'}{ lc $_[1] } : undef } |
32
|
513
|
100
|
100
|
513
|
0
|
2140
|
sub is_key { (defined $_[1] and exists $_[0]->{'key_order'}{ lc $_[1] }) ? 1 : 0 } |
33
|
347
|
100
|
66
|
347
|
0
|
1521
|
sub is_shortcut { (defined $_[1] and exists $_[0]->{'shortcut_order'}{ lc $_[1] }) ? 1 : 0 } |
34
|
214
|
100
|
|
214
|
0
|
328
|
sub is_key_or_shortcut { $_[0]->is_key($_[1]) or $_[0]->is_shortcut($_[1]) } |
35
|
|
|
|
|
|
|
sub is_string { |
36
|
581
|
|
|
581
|
0
|
826
|
my ($self, $string) = @_; |
37
|
581
|
100
|
66
|
|
|
2326
|
return 0 unless defined $string and not ref $string; |
38
|
90
|
|
|
|
|
159
|
$string = lc $string; |
39
|
90
|
|
|
|
|
167
|
my $name = lc $self->name; |
40
|
90
|
100
|
|
|
|
330
|
return 0 unless index($string, $name.':') == 0; |
41
|
37
|
|
|
|
|
61
|
my $nr = '\s*-?\d+(?:\.\d+)?\s*'; |
42
|
37
|
|
|
|
|
70
|
my $nrs = join(',', ('\s*-?\d+(?:\.\d+)?\s*') x $self->count); |
43
|
37
|
50
|
|
|
|
791
|
($string =~ /^$name:$nrs$/) ? 1 : 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
sub is_css_string { |
46
|
558
|
|
|
558
|
0
|
791
|
my ($self, $string) = @_; |
47
|
558
|
100
|
66
|
|
|
2166
|
return 0 unless defined $string and not ref $string; |
48
|
79
|
|
|
|
|
126
|
$string = lc $string; |
49
|
79
|
|
|
|
|
127
|
my $name = lc $self->name; |
50
|
79
|
100
|
|
|
|
337
|
return 0 unless index($string, $name.'(') == 0; |
51
|
2
|
|
|
|
|
5
|
my $nr = '\s*-?\d+(?:\.\d+)?\s*'; |
52
|
2
|
|
|
|
|
4
|
my $nrs = join(',', ('\s*-?\d+(?:\.\d+)?\s*') x $self->count); |
53
|
2
|
50
|
|
|
|
74
|
($string =~ /^$name\($nrs\)$/) ? 1 : 0; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
sub is_array { |
56
|
2930
|
|
|
2930
|
0
|
4114
|
my ($self, $value_array) = @_; |
57
|
2930
|
100
|
100
|
|
|
12932
|
(ref $value_array eq 'ARRAY' and @$value_array == $self->{'count'}) ? 1 : 0; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
sub is_named_array { |
60
|
629
|
|
|
629
|
0
|
869
|
my ($self, $value_array) = @_; |
61
|
629
|
100
|
100
|
|
|
2532
|
(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
|
564
|
|
|
564
|
0
|
856
|
my ($self, $value_hash) = @_; |
66
|
564
|
100
|
100
|
|
|
1921
|
return 0 unless ref $value_hash eq 'HASH' and CORE::keys %$value_hash == $self->{'count'}; |
67
|
116
|
|
|
|
|
246
|
for (CORE::keys %$value_hash) { |
68
|
199
|
100
|
|
|
|
313
|
return 0 unless $self->is_key_or_shortcut($_); |
69
|
|
|
|
|
|
|
} |
70
|
38
|
|
|
|
|
167
|
return 1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
sub is_partial_hash { |
73
|
7
|
|
|
7
|
0
|
15
|
my ($self, $value_hash) = @_; |
74
|
7
|
100
|
|
|
|
25
|
return 0 unless ref $value_hash eq 'HASH'; |
75
|
6
|
|
|
|
|
15
|
my $key_count = CORE::keys %$value_hash; |
76
|
6
|
100
|
66
|
|
|
31
|
return 0 unless $key_count and $key_count <= $self->{'count'}; |
77
|
5
|
|
|
|
|
12
|
for (CORE::keys %$value_hash) { |
78
|
11
|
100
|
|
|
|
22
|
return 0 unless $self->is_key_or_shortcut($_); |
79
|
|
|
|
|
|
|
} |
80
|
4
|
|
|
|
|
15
|
return 1; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
######################################################################## |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub key_shortcut { |
86
|
18
|
|
|
18
|
0
|
32
|
my ($self, $key) = @_; |
87
|
18
|
50
|
|
|
|
31
|
return unless $self->is_key( $key ); |
88
|
18
|
|
|
|
|
47
|
($self->shortcuts)[ $self->{'key_order'}{ lc $key } ]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub list_value_from_key { |
92
|
6
|
|
|
6
|
0
|
368
|
my ($self, $key, @values) = @_; |
93
|
6
|
|
|
|
|
12
|
$key = lc $key; |
94
|
6
|
100
|
|
|
|
24
|
return unless @values == $self->{'count'}; |
95
|
4
|
100
|
|
|
|
17
|
return unless exists $self->{'key_order'}{ $key }; |
96
|
3
|
|
|
|
|
19
|
return $values[ $self->{'key_order'}{ $key } ]; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub list_value_from_shortcut { |
100
|
4
|
|
|
4
|
0
|
11
|
my ($self, $shortcut, @values) = @_; |
101
|
4
|
|
|
|
|
7
|
$shortcut = lc $shortcut; |
102
|
4
|
50
|
|
|
|
12
|
return unless @values == $self->{'count'}; |
103
|
4
|
100
|
|
|
|
12
|
return unless exists $self->{'shortcut_order'}{ $shortcut }; |
104
|
3
|
|
|
|
|
14
|
return $values[ $self->{'shortcut_order'}{ $shortcut } ]; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub list_from_hash { |
108
|
36
|
|
|
36
|
0
|
3151
|
my ($self, $value_hash) = @_; |
109
|
36
|
50
|
33
|
|
|
149
|
return undef unless ref $value_hash eq 'HASH' and CORE::keys %$value_hash == $self->{'count'}; |
110
|
36
|
|
|
|
|
126
|
my @values = (0) x $self->{'count'}; |
111
|
36
|
|
|
|
|
81
|
for my $value_key (CORE::keys %$value_hash) { |
112
|
112
|
100
|
|
|
|
165
|
if ($self->is_key( $value_key )) { $values[ $self->{'key_order'}{ lc $value_key } ] = $value_hash->{ $value_key } } |
|
16
|
100
|
|
|
|
47
|
|
113
|
95
|
|
|
|
|
209
|
elsif ($self->is_shortcut( $value_key )) { $values[ $self->{'shortcut_order'}{ lc $value_key } ] = $value_hash->{ $value_key } } |
114
|
1
|
|
|
|
|
7
|
else { return } |
115
|
|
|
|
|
|
|
} |
116
|
35
|
|
|
|
|
137
|
return @values; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub deformat_partial_hash { |
120
|
79
|
|
|
79
|
0
|
4336
|
my ($self, $value_hash) = @_; |
121
|
79
|
100
|
|
|
|
179
|
return unless ref $value_hash eq 'HASH'; |
122
|
78
|
|
|
|
|
162
|
my @keys_got = CORE::keys %$value_hash; |
123
|
78
|
100
|
100
|
|
|
316
|
return unless @keys_got and @keys_got <= $self->{'count'}; |
124
|
68
|
|
|
|
|
94
|
my $result = {}; |
125
|
68
|
|
|
|
|
102
|
for my $key (@keys_got) { |
126
|
75
|
100
|
|
|
|
117
|
if ($self->is_key( $key )) { $result->{ int $self->key_pos( $key ) } = $value_hash->{ $key } } |
|
16
|
100
|
|
|
|
37
|
|
127
|
10
|
|
|
|
|
55
|
elsif ($self->is_shortcut( $key )){ $result->{ int $self->shortcut_pos( $key ) } = $value_hash->{ $key } } |
128
|
49
|
|
|
|
|
136
|
else { return undef } |
129
|
|
|
|
|
|
|
} |
130
|
19
|
|
|
|
|
58
|
return $result; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub list_from_string { |
134
|
37
|
|
|
37
|
0
|
94
|
my ($self, $string) = @_; |
135
|
37
|
|
|
|
|
119
|
my @parts = split(/:/, $string); |
136
|
37
|
|
|
|
|
107
|
return map {$_ + 0} split(/,/, $parts[1]); |
|
113
|
|
|
|
|
325
|
|
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub list_from_css { |
140
|
2
|
|
|
2
|
0
|
6
|
my ($self, $string) = @_; |
141
|
2
|
|
|
|
|
9
|
1 until chop($string) eq ')'; |
142
|
2
|
|
|
|
|
7
|
my @parts = split(/\(/, $string); |
143
|
2
|
|
|
|
|
6
|
return map {$_ + 0} split(/,/, $parts[1]); |
|
6
|
|
|
|
|
23
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub key_hash_from_list { |
147
|
21
|
|
|
21
|
0
|
47
|
my ($self, @values) = @_; |
148
|
21
|
100
|
|
|
|
65
|
return unless @values == $self->{'count'}; |
149
|
19
|
|
|
|
|
29
|
return { map { $self->{'keys'}[$_] => $values[$_]} @{$self->{'iterator'}} }; |
|
72
|
|
|
|
|
261
|
|
|
19
|
|
|
|
|
39
|
|
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub shortcut_hash_from_list { |
153
|
8
|
|
|
8
|
0
|
22
|
my ($self, @values) = @_; |
154
|
8
|
100
|
|
|
|
29
|
return unless @values == $self->{'count'}; |
155
|
6
|
|
|
|
|
10
|
return { map {$self->{'shortcuts'}[$_] => $values[$_]} @{$self->{'iterator'}} }; |
|
18
|
|
|
|
|
73
|
|
|
6
|
|
|
|
|
15
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub named_array_from_list { |
159
|
1
|
|
|
1
|
0
|
3
|
my ($self, @values) = @_; |
160
|
1
|
50
|
|
|
|
4
|
return [lc $self->name, @values] if @values == $self->{'count'}; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub named_string_from_list { |
164
|
38
|
|
|
38
|
0
|
90
|
my ($self, @values) = @_; |
165
|
38
|
50
|
|
|
|
123
|
return unless @values == $self->{'count'}; |
166
|
38
|
|
|
|
|
114
|
lc( $self->name).': '.join(', ', @values); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub css_string_from_list { |
170
|
2
|
|
|
2
|
0
|
5
|
my ($self, @values) = @_; |
171
|
2
|
50
|
|
|
|
17
|
return unless @values == $self->{'count'}; |
172
|
2
|
|
|
|
|
4
|
lc( $self->name).'('.join(',', @values).')'; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
216
|
50
|
|
216
|
|
822
|
sub _color_key_shortcut { lc substr($_[0], 0, 1) if defined $_[0] } |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |