Color/Space/Shape.pm

filter: Statementstmt 97.2% 244 / 251 Branchbran 81.2% 190 / 234 Conditioncond 72.4% 63 / 87 MC/DCmcdc 55.5% 30 / 54 Subroutinesub 100% 32 / 32 Podpod 0.0% 0 / 28 totaltotal 81.4% 559 / 686 CC 162 SCAR 26.5
CC
162
Cov
87%
expand_range_definition
31.1
new
28.3
clamp
15.1
CRAP 14.2
« Color/Space.pm ↑ Summary Color.pm »
1  
2 # geometry of space: value range checks, normalisation and computing distance
3  
4 package Graphics::Toolkit::Color::Space::Shape;
5 50 ▶use v5.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 50 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 50 ▶use Graphics::Toolkit::Color::Space::Basis;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 50 ▶use Graphics::Toolkit::Color::Space::Util qw/round_decimals is_nr/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #### constructor #######################################################
11 583 ▶sub new {
Subroutine new: called CC=28 SCAR=33.4
Pod undocumented
12 583 my $pkg = shift;
13 583 my ($basis, $type, $range, $precision, $constraint) = @_;
14 583 ▶ return unless ref $basis eq 'Graphics::Toolkit::Color::Space::Basis';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $basis eq "Graphics::Toolkit::Color::Space::Basis" 1 582 583
15  
16 # expand axis type definition
17 582 ▶ if (not defined $type){ $type = [ (1) x $basis->axis_count ] } # set all axis as linear per default
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $type) { } 395 187 582
elsif (ref $type eq 'ARRAY' and @$type == $basis->axis_count) { } 185 2 187
18 ▶ elsif (ref $type eq 'ARRAY' and @$type == $basis->axis_count ) {
Condition100%3/3
ref $type eq "ARRAY" and @$type == $basis->axis_count
!ll&&!rl&&r
11185
MC/DC100%2/2
ref $type eq "ARRAY" and @$type == $basis->axis_count
ref $type eq "ARRAY" @$type == $basis->axis_count
Truth table100%3/3
A and B
A= ref $type eq "ARRAY"B= @$type == $basis->axis_count
ABresult
0X0
100
111
19 185 for my $i ($basis->axis_iterator) {
20 553 my $atype = $type->[$i]; # type def of this axis
21 553 ▶ return unless defined $atype;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $atype 0 553 553
22 553 ▶ if ($atype eq 'angular' or $atype eq 'circular' or $atype eq '0') { $type->[$i] = 0 }
Branch: 3 branches
BranchTrueFalseTotal
if ($atype eq 'angular' or $atype eq 'circular' or $atype eq '0') { } 187 366 553
elsif ($atype eq 'linear' or $atype eq '1') { } 360 6 366
elsif ($atype eq 'no' or $atype eq '2') { } 4 2 6
Condition100%6/6
$atype eq "angular" or $atype eq "circular" or $atype eq 0
l!l&&r!l&&!r
1852366
$atype eq "angular" or $atype eq "circular"
l!l&&r!l&&!r
1814368
MC/DC100%3/3
$atype eq "angular" or $atype eq "circular" or $atype eq 0
$atype eq "angular" $atype eq "circular" $atype eq 0
Truth table100%4/4
A or B or C
A= $atype eq "angular"B= $atype eq "circular"C= $atype eq 0
ABCresult
1XX1
01X1
0011
0000
23 360 ▶ elsif ($atype eq 'linear' or $atype eq '1') { $type->[$i] = 1 }
Condition100%3/3
$atype eq "linear" or $atype eq 1
l!l&&r!l&&!r
35916
MC/DC100%2/2
$atype eq "linear" or $atype eq 1
$atype eq "linear" $atype eq 1
Truth table100%3/3
A or B
A= $atype eq "linear"B= $atype eq 1
ABresult
1X1
011
000
24 4 ▶ elsif ($atype eq 'no' or $atype eq '2') { $type->[$i] = 2 }
Condition100%3/3
$atype eq "no" or $atype eq 2
l!l&&r!l&&!r
312
MC/DC100%2/2
$atype eq "no" or $atype eq 2
$atype eq "no" $atype eq 2
Truth table100%3/3
A or B
A= $atype eq "no"B= $atype eq 2
ABresult
1X1
011
000
25 2 else { return 'invalid axis type at element '.$i.'. It has to be "angular", "linear" or "no".' }
26 }
27 2 } else { return 'invalid axis type definition in color space '.$basis->space_name }
28  
29 578 $range = expand_range_definition(undef, $basis, $range );
30 578 ▶ return $range unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 8 570 578
31 570 $precision = expand_precision_definition( $basis, $precision );
32 570 ▶ return $precision unless ref $precision;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $precision 2 568 570
33  
34 # check constraint def
35 568 ▶ if (defined $constraint){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $constraint) { } 74 494 568
36 74 ▶ return 'color space constraint definition has to be a none empty HASH ref' if ref $constraint ne 'HASH' or not %$constraint;
Branch: 1 branch
BranchTrueFalseTotal
if ref $constraint ne "HASH" or not %$constraint 2 72 74
Condition100%3/3
ref $constraint ne "HASH" or not %$constraint
l!l&&r!l&&!r
1172
MC/DC100%2/2
ref $constraint ne "HASH" or not %$constraint
ref $constraint ne "HASH" not %$constraint
Truth table100%3/3
A or not(B)
A= ref $constraint ne "HASH"B= not %$constraint
ABresult
1X1
011
000
37 72 for my $constraint_name (keys %$constraint){
38 73 my $properties = $constraint->{$constraint_name};
39 73 ▶ return 'a color space constraint has to be a HASH ref with three keys' unless ref $properties eq 'HASH' and keys(%$properties) == 3;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $properties eq "HASH" and keys %$properties == 3 2 71 73
Condition66%2/3
ref $properties eq "HASH" and keys %$properties == 3
!ll&&!rl&&r
0271
MC/DC50%1/2
ref $properties eq "HASH" and keys %$properties == 3
ref $properties eq "HASH" keys %$properties == 3
Truth table66%2/3
A and B
A= ref $properties eq "HASH"B= keys %$properties == 3
ABresult
0X0
100
111
40 71 $properties = {%$properties};
41 71 my $error_msg = 'constraint "$constraint_name" in '.$basis->space_name.' color space';
42 71 for (qw/checker error remedy/){
43 return $error_msg." needs the string-propertiy '$_'"
44 207 ▶ unless exists $properties->{$_} and $properties->{$_} and not ref $properties->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $properties->{$_} and $properties->{$_} and not ref $properties->{$_} 3 204 207
Condition50%3/6
exists $properties->{$_} and $properties->{$_} and not ref $properties->{$_}
!ll&&!rl&&r
03204
exists $properties->{$_} and $properties->{$_}
!ll&&!rl&&r
00207
MC/DC33%1/3
exists $properties->{$_} and $properties->{$_} and not ref $properties->{$_}
exists $properties->{$_} $properties->{$_} not ref $properties->{$_}
Truth table50%2/4
A and B and not(C)
A= exists $properties->{$_}B= $properties->{$_}C= not ref $properties->{$_}
ABCresult
0XX0
10X0
1100
1111
45 }
46 68 $properties->{'checker_code'} = $properties->{'checker'};
47 68 $properties->{'checker'} = eval 'sub {'.$properties->{'checker_code'}.'}';
48 68 ▶ return 'checker code of '.$error_msg.":'$properties->{checker_code}' does not eval - $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 68 68
49 68 $properties->{'remedy_code'} = $properties->{'remedy'};
50 68 $properties->{'remedy'} = eval 'sub {'.$properties->{'remedy_code'}.'}';
51 68 ▶ return 'remedy code of '.$error_msg.":'$properties->{remedy_code}' does not eval - $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 68 68
52 68 $constraint->{ $constraint_name } = $properties;
53 }
54 494 } else { $constraint = '' }
55  
56 561 bless { basis => $basis, type => $type, range => $range, precision => $precision, constraint => $constraint }
57 }
58  
59 #### object attribute checker ##########################################
60 2300 ▶sub expand_range_definition { # check if range def is valid and eval (expand) it
Subroutine expand_range_definition: called CC=29 SCAR=34.4
Pod undocumented
61 2300 my ($self, $basis, $range) = @_;
62 2300 ▶ $basis = $basis->{'basis'} if ref $basis eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if ref $basis eq __PACKAGE__ 0 2300 2300
63 2300 my $error_msg = 'Bad value range definition!';
64 2300 ▶ $range = 1 if not defined $range or $range eq 'normal';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $range or $range eq "normal" 864 1436 2300
Condition100%3/3
not defined $range or $range eq "normal"
l!l&&r!l&&!r
2496151436
MC/DC100%2/2
not defined $range or $range eq "normal"
not defined $range $range eq "normal"
Truth table100%3/3
not(A) or B
A= not defined $rangeB= $range eq "normal"
ABresult
1X1
011
000
65 2300 ▶ $range = 100 if $range eq 'percent';
Branch: 1 branch
BranchTrueFalseTotal
if $range eq "percent" 1 2299 2300
66 2300 ▶ return $error_msg." It has to be 'normal', 'percent', a number or ARRAY of numbers (by axis position) or HASH (by axis name).'.
Branch: 1 branch
BranchTrueFalseTotal
unless not ref $range and is_nr($range) or ref $range eq "ARRAY" or ref $range eq "HASH" 0 2300 2300
Condition77%7/9
not ref $range and is_nr($range) or ref $range eq "ARRAY" or ref $range eq "HASH"
l!l&&r!l&&!r
229460
not ref $range and is_nr($range) or ref $range eq "ARRAY"
l!l&&r!l&&!r
90013946
not ref $range and is_nr($range)
!ll&&!rl&&r
14000900
MC/DC0%0/4
not ref $range and is_nr($range) or ref $range eq "ARRAY" or ref $range eq "HASH"
not ref $range is_nr($range) ref $range eq "ARRAY" ref $range eq "HASH"
Truth table42%3/7
not(A) and B or C or D
A= not ref $rangeB= is_nr($range)C= ref $range eq "ARRAY"D= ref $range eq "HASH"
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
67 ' Instead of a number you can also insert ARRAY with two number!"
68 unless (not ref $range and is_nr( $range )) or ref $range eq 'ARRAY' or ref $range eq 'HASH';
69 2300 ▶ if (ref $range eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range eq "HASH") 6 2294 2300
70 6 my $range_array = [];
71 6 for my $axis_name (keys %$range){
72 13 ▶ next unless $basis->is_axis_name( $axis_name );
Branch: 1 branch
BranchTrueFalseTotal
unless $basis->is_axis_name($axis_name) 0 13 13
73 13 $range_array->[ $basis->pos_from_axis_name($axis_name) ] = $range->{$axis_name};
74 }
75 6 for my $axis_index ($basis->axis_iterator){
76 18 ▶ next if exists $range_array->[$axis_index] and defined $range_array->[$axis_index];
Branch: 1 branch
BranchTrueFalseTotal
if exists $range_array->[$axis_index] and defined $range_array->[$axis_index] 13 5 18
Condition66%2/3
exists $range_array->[$axis_index] and defined $range_array->[$axis_index]
!ll&&!rl&&r
5013
MC/DC50%1/2
exists $range_array->[$axis_index] and defined $range_array->[$axis_index]
exists $range_array->[$axis_index] defined $range_array->[$axis_index]
Truth table66%2/3
A and B
A= exists $range_array->[$axis_index]B= defined $range_array->[$axis_index]
ABresult
0X0
100
111
77 5 ▶ next unless ref $self and ref $self->{'range'};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self and ref $self->{"range"} 3 2 5
Condition66%2/3
ref $self and ref $self->{"range"}
!ll&&!rl&&r
302
MC/DC50%1/2
ref $self and ref $self->{"range"}
ref $self ref $self->{"range"}
Truth table66%2/3
A and B
A= ref $selfB= ref $self->{"range"}
ABresult
0X0
100
111
78 2 $range_array->[$axis_index] = $self->{'range'}[$axis_index];
79 }
80 6 $range = $range_array;
81 }
82 2300 ▶ $range = [$range] unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 900 1400 2300
83 2300 ▶ $range = [(@$range) x $basis->axis_count] if @$range == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @$range == 1 903 1397 2300
84 2300 ▶ return "Range definition needs inside an ARRAY or HASH a number or pair of them in an ARRAY for each axis!"
Branch: 1 branch
BranchTrueFalseTotal
if @$range != $basis->axis_count 4 2296 2300
85 if @$range != $basis->axis_count;
86 2296 for my $axis_index ($basis->axis_iterator) {
87 6935 my $axis_range = $range->[$axis_index];
88 6935 ▶ if (not ref $axis_range){
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $axis_range) { } 3449 3486 6935
elsif (ref $axis_range eq 'ARRAY') { } 3486 0 3486
89 3449 ▶ if ($axis_range eq 'normal') {$range->[$axis_index] = [0, 1]}
Branch: 2 branches
BranchTrueFalseTotal
if ($axis_range eq 'normal') { } 3 3446 3449
elsif ($axis_range eq 'percent') { } 0 3446 3446
90 0 elsif ($axis_range eq 'percent') {$range->[$axis_index] = [0, 100]}
91 3446 else {$range->[$axis_index] = [0, $axis_range+0]}
92 } elsif (ref $axis_range eq 'ARRAY') {
93 3486 ▶ return $error_msg.' Array at axis number '.$axis_index.' has to have two elements' unless @$axis_range == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @$axis_range == 2 2 3484 3486
94 3484 ▶ return $error_msg.' None numeric value at lower bound for axis number '.$axis_index unless is_nr( $axis_range->[0] );
Branch: 1 branch
BranchTrueFalseTotal
unless is_nr($axis_range->[0]) 0 3484 3484
95 3484 ▶ return $error_msg.' None numeric value at upper bound for axis number '.$axis_index unless is_nr( $axis_range->[1] );
Branch: 1 branch
BranchTrueFalseTotal
unless is_nr($axis_range->[1]) 1 3483 3484
96 3483 ▶ return $error_msg.' Lower bound (first value) is >= than upper bound at axis number '.$axis_index if $axis_range->[0] >= $axis_range->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $axis_range->[0] >= $axis_range->[1] 1 3482 3483
97 0 } else { return "Range definitin for axis $axis_index was not an two element ARRAY!" }
98 }
99 2292 return $range;
100 }
101 4561 ▶sub try_check_range_definition { # check if range def is valid and eval (expand) it
Subroutine try_check_range_definition: called CC=2 SCAR=6.9
Pod undocumented
102 4561 my ($self, $range) = @_;
103 4561 ▶ return $self->{'range'} unless defined $range;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $range 2839 1722 4561
104 1722 return $self->expand_range_definition( $self->{'basis'}, $range );
105 }
106  
107 933 ▶sub expand_precision_definition { # check if precision def is valid and eval (exapand) it
Subroutine expand_precision_definition: called CC=6 SCAR=18.0
Pod undocumented
108 933 my ($basis, $precision) = @_;
109 933 ▶ $basis = $basis->{'basis'} if ref $basis eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if ref $basis eq __PACKAGE__ 0 933 933
110 933 ▶ $precision = -1 unless defined $precision;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $precision 77 856 933
111 933 ▶ $precision = [($precision) x $basis->axis_count] unless ref $precision;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $precision 814 119 933
112 933 ▶ return 'need an ARRAY as definition of axis value precision' unless ref $precision eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $precision eq "ARRAY" 0 933 933
113 933 ▶ return 'definition of axis value precision has to have same lengths as basis' unless @$precision == $basis->axis_count;
Branch: 1 branch
BranchTrueFalseTotal
unless @$precision == $basis->axis_count 2 931 933
114 931 return $precision;
115 }
116 1533 ▶sub try_check_precision_definition { # check if range def is valid and eval (expand) it
Subroutine try_check_precision_definition: called CC=2 SCAR=6.9
Pod undocumented
117 1533 my ($self, $precision) = @_;
118 1533 ▶ return $self->{'precision'} unless defined $precision;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $precision 1170 363 1533
119 363 return expand_precision_definition( $self->{'basis'}, $precision );
120 }
121  
122 #### getter of space object ############################################
123 12391 ▶sub basis { $_[0]{'basis'}}
Subroutine basis: called CC=1 SCAR=0.0
Pod undocumented
124 # per axis
125 13151 ▶sub is_axis_numeric {
Subroutine is_axis_numeric: called CC=4 SCAR=13.9
Pod undocumented
126 13151 my ($self, $axis_nr) = @_;
127 13151 ▶ return 0 if not defined $axis_nr or not exists $self->{'type'}[$axis_nr];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $axis_nr and exists $self->{"type"}[$axis_nr] 4 13147 13151
Condition66%2/3
defined $axis_nr and exists $self->{"type"}[$axis_nr]
!ll&&!rl&&r
0413147
MC/DC50%1/2
defined $axis_nr and exists $self->{"type"}[$axis_nr]
defined $axis_nr exists $self->{"type"}[$axis_nr]
Truth table66%2/3
A and B
A= defined $axis_nrB= exists $self->{"type"}[$axis_nr]
ABresult
0X0
100
111
128 13147 ▶ $self->{'type'}[$axis_nr] < 2 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'}[$axis_nr] < 2 ? : 13145 2 13147
129  
130 }
131 2986 ▶sub is_axis_euclidean {
Subroutine is_axis_euclidean: called CC=4 SCAR=13.9
Pod undocumented
132 2986 my ($self, $axis_nr) = @_;
133 2986 ▶ return 0 if not defined $axis_nr or not exists $self->{'type'}[$axis_nr];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $axis_nr and exists $self->{"type"}[$axis_nr] 1 2985 2986
Condition66%2/3
defined $axis_nr and exists $self->{"type"}[$axis_nr]
!ll&&!rl&&r
012985
MC/DC50%1/2
defined $axis_nr and exists $self->{"type"}[$axis_nr]
defined $axis_nr exists $self->{"type"}[$axis_nr]
Truth table66%2/3
A and B
A= defined $axis_nrB= exists $self->{"type"}[$axis_nr]
ABresult
0X0
100
111
134 2985 ▶ $self->{'type'}[$axis_nr] == 1 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'}[$axis_nr] == 1 ? : 2750 235 2985
135  
136 }
137 3052 ▶sub is_axis_angular {
Subroutine is_axis_angular: called CC=4 SCAR=13.9
Pod undocumented
138 3052 my ($self, $axis_nr) = @_;
139 3052 ▶ return 0 if not defined $axis_nr or not exists $self->{'type'}[$axis_nr];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $axis_nr and exists $self->{"type"}[$axis_nr] 1 3051 3052
Condition66%2/3
defined $axis_nr and exists $self->{"type"}[$axis_nr]
!ll&&!rl&&r
013051
MC/DC50%1/2
defined $axis_nr and exists $self->{"type"}[$axis_nr]
defined $axis_nr exists $self->{"type"}[$axis_nr]
Truth table66%2/3
A and B
A= defined $axis_nrB= exists $self->{"type"}[$axis_nr]
ABresult
0X0
100
111
140 3051 ▶ $self->{'type'}[$axis_nr] == 0 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'}[$axis_nr] == 0 ? : 245 2806 3051
141 }
142 18 ▶sub axis_value_max { # --> +value
Subroutine axis_value_max: called CC=3 SCAR=11.0
Pod undocumented
143 18 my ($self, $axis_nr, $range) = @_;
144 18 $range = $self->try_check_range_definition( $range );
145 18 ▶ return undef unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 0 18 18
146 18 ▶ return undef unless $self->is_axis_numeric($axis_nr);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_axis_numeric($axis_nr) 1 17 18
147 17 return $range->[$axis_nr][1];
148 }
149 4 ▶sub axis_value_min { # --> +value
Subroutine axis_value_min: called CC=3 SCAR=11.0
Pod undocumented
150 4 my ($self, $axis_nr, $range) = @_;
151 4 $range = $self->try_check_range_definition( $range );
152 4 ▶ return undef unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 0 4 4
153 4 ▶ return undef unless $self->is_axis_numeric($axis_nr);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_axis_numeric($axis_nr) 1 3 4
154 3 return $range->[$axis_nr][0];
155 }
156 16 ▶sub axis_value_precision { # --> +precision?
Subroutine axis_value_precision: called CC=7 SCAR=22.7
Pod undocumented
157 16 my ($self, $axis_nr, $precision) = @_;
158 16 ▶ return undef if not defined $axis_nr or not exists $self->{'type'}[$axis_nr];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $axis_nr and exists $self->{"type"}[$axis_nr] 0 16 16
Condition33%1/3
defined $axis_nr and exists $self->{"type"}[$axis_nr]
!ll&&!rl&&r
0016
MC/DC0%0/2
defined $axis_nr and exists $self->{"type"}[$axis_nr]
defined $axis_nr exists $self->{"type"}[$axis_nr]
Truth table33%1/3
A and B
A= defined $axis_nrB= exists $self->{"type"}[$axis_nr]
ABresult
0X0
100
111
159 16 ▶ return undef unless $self->is_axis_numeric($axis_nr);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_axis_numeric($axis_nr) 1 15 16
160 15 ▶ $precision //= $self->{'precision'};
Condition33%1/3
$precision //= $self->{"precision"}
l!l&&r!l&&!r
0150
MC/DC0%0/2
$precision //= $self->{"precision"}
$precision $self->{"precision"}
Truth table33%1/3
A //= B
A= $precisionB= $self->{"precision"}
ABresult
1X1
011
000
161 15 ▶ return undef unless ref $precision eq 'ARRAY' and exists $precision->[$axis_nr];
Branch: 1 branch
BranchTrueFalseTotal
unless ref $precision eq "ARRAY" and exists $precision->[$axis_nr] 0 15 15
Condition33%1/3
ref $precision eq "ARRAY" and exists $precision->[$axis_nr]
!ll&&!rl&&r
0015
MC/DC0%0/2
ref $precision eq "ARRAY" and exists $precision->[$axis_nr]
ref $precision eq "ARRAY" exists $precision->[$axis_nr]
Truth table33%1/3
A and B
A= ref $precision eq "ARRAY"B= exists $precision->[$axis_nr]
ABresult
0X0
100
111
162 15 $precision->[$axis_nr];
163 }
164  
165 # all axis
166 36 ▶sub is_euclidean { # all axis linear ?
Subroutine is_euclidean: called CC=2 SCAR=6.9
Pod undocumented
167 36 my ($self) = @_;
168 36 ▶ map { return 0 if $self->{'type'}[$_] != 1 } $self->basis->axis_iterator;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"}[$_] != 1 12 80 92
169 24 return 1;
170 }
171 36 ▶sub is_cylindrical { # one axis angular, rest linear ?
Subroutine is_cylindrical: called CC=4 SCAR=13.9
Pod undocumented
172 36 my ($self) = @_;
173 36 my $angular_axis = 0;
174 36 ▶ map { $angular_axis++ if $self->{'type'}[$_] == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"}[$_] == 0 13 96 109
175 109 ▶ return 0 if $self->{'type'}[$_] > 1; } $self->basis->axis_iterator;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"}[$_] > 1 1 108 109
176 35 ▶ return ($angular_axis == 1) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$angular_axis == 1 ? : 12 23 35
177 }
178 3 ▶sub is_int_valued { # all ranges int valued ?
Subroutine is_int_valued: called CC=2 SCAR=7.0
Pod undocumented
179 3 my ($self) = @_;
180 3 ▶ map { return 0 if $self->{'precision'}[$_] != 0 } $self->basis->axis_iterator;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"precision"}[$_] != 0 3 1 4
181 0 return 1;
182 }
183 1388 ▶sub has_constraints { my ($self) = @_; return (ref $self->{'constraint'}) ? 1 : 0 } # --> ?
Subroutine has_constraints: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{'constraint'} ? : 47 1341 1388
184  
185  
186 #### value checker #####################################################
187 373 ▶sub check_value_shape { # @tuple -- $range, $precision --> $@vals | ~!
Subroutine check_value_shape: called CC=13 SCAR=25.7
Pod undocumented
188 373 my ($self, $tuple, $range, $precision) = @_;
189 373 ▶ return 'color value tuple in '.$self->basis->space_name.' space needs to be ARRAY ref with '.$self->basis->axis_count.' elements'
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_value_tuple($tuple) 70 303 373
190 unless $self->basis->is_value_tuple( $tuple );
191 303 $range = $self->try_check_range_definition( $range );
192 303 ▶ return $range unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 0 303 303
193 303 $precision = $self->try_check_precision_definition( $precision );
194 303 ▶ return $precision unless ref $precision;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $precision 0 303 303
195 303 my @names = $self->basis->long_axis_names;
196 303 for my $axis_index ($self->basis->axis_iterator){
197 696 ▶ next unless $self->is_axis_numeric( $axis_index );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_axis_numeric($axis_index) 0 696 696
198 696 ▶ return $names[$axis_index]." value is below minimum of ".$range->[$axis_index][0]
Branch: 1 branch
BranchTrueFalseTotal
if $tuple->[$axis_index] < $range->[$axis_index][0] 100 596 696
199 if $tuple->[$axis_index] < $range->[$axis_index][0];
200 596 ▶ return $names[$axis_index]." value is above maximum of ".$range->[$axis_index][1]
Branch: 1 branch
BranchTrueFalseTotal
if $tuple->[$axis_index] > $range->[$axis_index][1] 104 492 596
201 if $tuple->[$axis_index] > $range->[$axis_index][1];
202 492 ▶ return $names[$axis_index]." value is not properly rounded "
Branch: 1 branch
BranchTrueFalseTotal
if $precision->[$axis_index] >= 0 and round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index] 19 473 492
Condition100%3/3
$precision->[$axis_index] >= 0 and round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index]
!ll&&!rl&&r
6640719
MC/DC100%2/2
$precision->[$axis_index] >= 0 and round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index]
$precision->[$axis_index] >= 0 round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index]
Truth table100%3/3
A and B
A= $precision->[$axis_index] >= 0B= round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index]
ABresult
0X0
100
111
203 if $precision->[$axis_index] >= 0
204 and round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index];
205 }
206 80 ▶ if ($self->has_constraints){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_constraints) 11 69 80
207 11 my $tuple = $self->normalize($tuple, $range);
208 11 for my $constraint (values %{$self->{'constraint'}}){
209 11 ▶ return $constraint->{'error'} unless $constraint->{'checker'}->( $tuple );
Branch: 1 branch
BranchTrueFalseTotal
unless $constraint->{"checker"}->($tuple) 2 9 11
210 }
211 }
212 78 return $tuple;
213 }
214  
215 8 ▶sub is_equal { # @tuple_a, @tuple_b -- $precision --> ?
Subroutine is_equal: called CC=5 SCAR=16.1
Pod undocumented
216 8 my ($self, $tuple_a, $tuple_b, $precision) = @_;
217 8 ▶ return 0 unless $self->basis->is_value_tuple( $tuple_a ) and $self->basis->is_value_tuple( $tuple_b );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_value_tuple($tuple_a) and $self->basis->is_value_tuple($tuple_b) 5 3 8
Condition100%3/3
$self->basis->is_value_tuple($tuple_a) and $self->basis->is_value_tuple($tuple_b)
!ll&&!rl&&r
323
MC/DC100%2/2
$self->basis->is_value_tuple($tuple_a) and $self->basis->is_value_tuple($tuple_b)
$self->basis->is_value_tuple($tuple_a) $self->basis->is_value_tuple($tuple_b)
Truth table100%3/3
A and B
A= $self->basis->is_value_tuple($tuple_a)B= $self->basis->is_value_tuple($tuple_b)
ABresult
0X0
100
111
218 3 $precision = $self->try_check_precision_definition( $precision );
219 3 for my $axis_nr ($self->basis->axis_iterator) {
220 9 ▶ return 0 if round_decimals($tuple_a->[$axis_nr], $precision->[$axis_nr])
Branch: 1 branch
BranchTrueFalseTotal
if round_decimals($tuple_a->[$axis_nr], $precision->[$axis_nr]) != round_decimals($tuple_b->[$axis_nr], $precision->[$axis_nr]) 0 9 9
221 != round_decimals($tuple_b->[$axis_nr], $precision->[$axis_nr]);
222 }
223 3 return 1;
224 }
225  
226 2 ▶sub is_in_constraints { # @tuple --> ? # normalized values only, so it works on any ranges
Subroutine is_in_constraints: called CC=5 SCAR=16.3
Pod undocumented
227 2 my ($self, $tuple) = @_;
228 2 ▶ return 0 unless $self->basis->is_number_tuple( $tuple );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_number_tuple($tuple) 0 2 2
229 2 ▶ return 1 unless $self->has_constraints;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_constraints 0 2 2
230 2 for my $constraint (values %{$self->{'constraint'}}){
231 2 ▶ return 0 unless $constraint->{'checker'}->( $tuple );
Branch: 1 branch
BranchTrueFalseTotal
unless $constraint->{"checker"}->($tuple) 1 1 2
232 }
233 1 return 1;
234 }
235  
236 2 ▶sub is_in_bounds { # @tuple --> ?
Subroutine is_in_bounds: called CC=6 SCAR=18.8
Pod undocumented
237 2 my ($self, $tuple, $range) = @_;
238 2 ▶ return 0 unless $self->is_in_linear_bounds( $tuple, $range );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_in_linear_bounds($tuple, $range) 0 2 2
239 2 $range = $self->try_check_range_definition( $range );
240 2 for my $axis_nr ($self->basis->axis_iterator) {
241 4 ▶ next if $self->{'type'}[$axis_nr]; # skip none linear axis
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"}[$axis_nr] 3 1 4
242 1 ▶ return 0 if $tuple->[$axis_nr] < $range->[$axis_nr][0]
Branch: 1 branch
BranchTrueFalseTotal
if $tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1] 1 0 1
Condition33%1/3
$tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1]
l!l&&r!l&&!r
100
MC/DC0%0/2
$tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1]
$tuple->[$axis_nr] < $range->[$axis_nr][0] $tuple->[$axis_nr] > $range->[$axis_nr][1]
Truth table33%1/3
A or B
A= $tuple->[$axis_nr] < $range->[$axis_nr][0]B= $tuple->[$axis_nr] > $range->[$axis_nr][1]
ABresult
1X1
011
000
243 or $tuple->[$axis_nr] > $range->[$axis_nr][1];
244 }
245 1 return 1;
246 }
247  
248 380 ▶sub is_in_linear_bounds { # @tuple --> ?
Subroutine is_in_linear_bounds: called CC=7 SCAR=19.5
Pod undocumented
249 380 my ($self, $tuple, $range) = @_;
250 380 ▶ return 0 unless $self->basis->is_number_tuple( $tuple );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_number_tuple($tuple) 3 377 380
251 377 $range = $self->try_check_range_definition( $range );
252 377 for my $axis_nr ($self->basis->axis_iterator) {
253 1062 ▶ next if $self->{'type'}[$axis_nr] != 1; # skip none linear axis
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"}[$axis_nr] != 1 84 978 1062
254 978 ▶ return 0 if $tuple->[$axis_nr] < $range->[$axis_nr][0]
Branch: 1 branch
BranchTrueFalseTotal
if $tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1] 79 899 978
Condition100%3/3
$tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1]
l!l&&r!l&&!r
3346899
MC/DC100%2/2
$tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1]
$tuple->[$axis_nr] < $range->[$axis_nr][0] $tuple->[$axis_nr] > $range->[$axis_nr][1]
Truth table100%3/3
A or B
A= $tuple->[$axis_nr] < $range->[$axis_nr][0]B= $tuple->[$axis_nr] > $range->[$axis_nr][1]
ABresult
1X1
011
000
255 or $tuple->[$axis_nr] > $range->[$axis_nr][1];
256 }
257 298 ▶ if ($self->has_constraints){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_constraints) 0 298 298
258 0 return $self->is_in_constraints( $self->normalize( $tuple, $range) );
259 }
260 298 return 1;
261 }
262  
263 #### value ops #########################################################
264 995 ▶sub clamp { # change values if outside of range to nearest boundary, angles get rotated into range
Subroutine clamp: called CC=15 SCAR=27.2
Pod undocumented
265 995 my ($self, $tuple, $range) = @_;
266 995 $range = $self->try_check_range_definition( $range );
267 995 ▶ return $range unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 0 995 995
268 995 ▶ $tuple = [] unless ref $tuple eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tuple eq "ARRAY" 0 995 995
269 995 ▶ pop @$tuple while @$tuple > $self->basis->axis_count;
Branch: 1 branch
BranchTrueFalseTotal
@$tuple > $self->basis->axis_count and do { pop @$tuple } 34 995 1029
270 995 $tuple = [@$tuple];
271  
272 995 for my $axis_nr ($self->basis->axis_iterator){
273 3003 ▶ next unless $self->is_axis_numeric( $axis_nr );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_axis_numeric($axis_nr) 0 3003 3003
274 3003 ▶ if (not defined $tuple->[$axis_nr]){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $tuple->[$axis_nr]) { } 80 2923 3003
275 80 my $default_value = 0;
276 80 ▶ $default_value = $range->[$axis_nr][0] if $default_value < $range->[$axis_nr][0]
Branch: 1 branch
BranchTrueFalseTotal
if $default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1] 1 79 80
Condition66%2/3
$default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1]
l!l&&r!l&&!r
1079
MC/DC50%1/2
$default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1]
$default_value < $range->[$axis_nr][0] $default_value > $range->[$axis_nr][1]
Truth table66%2/3
A or B
A= $default_value < $range->[$axis_nr][0]B= $default_value > $range->[$axis_nr][1]
ABresult
1X1
011
000
277 or $default_value > $range->[$axis_nr][1];
278 80 $tuple->[$axis_nr] = $default_value;
279 } else {
280 2923 ▶ next unless $self->is_axis_euclidean( $axis_nr );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_axis_euclidean($axis_nr) 225 2698 2923
281 2698 ▶ $tuple->[$axis_nr] = $range->[$axis_nr][0] if $tuple->[$axis_nr] < $range->[$axis_nr][0];
Branch: 1 branch
BranchTrueFalseTotal
if $tuple->[$axis_nr] < $range->[$axis_nr][0] 32 2666 2698
282 2698 ▶ $tuple->[$axis_nr] = $range->[$axis_nr][1] if $tuple->[$axis_nr] > $range->[$axis_nr][1];
Branch: 1 branch
BranchTrueFalseTotal
if $tuple->[$axis_nr] > $range->[$axis_nr][1] 48 2650 2698
283 }
284 }
285 995 $tuple = $self->rotate($tuple, $range);
286 995 ▶ if ($self->has_constraints){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_constraints) 29 966 995
287 29 $tuple = $self->normalize( $tuple, $range);
288 29 for my $constraint (values %{$self->{'constraint'}}){
289 29 ▶ $tuple = $constraint->{'remedy'}->($tuple) unless $constraint->{'checker'}->( $tuple );
Branch: 1 branch
BranchTrueFalseTotal
unless $constraint->{"checker"}->($tuple) 4 25 29
290 }
291 29 $tuple = $self->denormalize( $tuple, $range);
292 }
293 995 return $tuple;
294 }
295 1010 ▶sub rotate { # rotate values of circular dimensions into range
Subroutine rotate: called CC=11 SCAR=26.9
Pod undocumented
296 1010 my ($self, $tuple, $range) = @_;
297 1010 ▶ return unless $self->basis->is_number_tuple( $tuple );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_number_tuple($tuple) 0 1010 1010
298 1010 $range = $self->try_check_range_definition( $range );
299 1010 ▶ return $range unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 0 1010 1010
300 1010 $tuple = [@$tuple];
301 1010 for my $axis_nr ($self->basis->axis_iterator){
302 3048 ▶ next unless $self->is_axis_angular( $axis_nr );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_axis_angular($axis_nr) 2804 244 3048
303 244 ▶ if (not defined $tuple->[$axis_nr]){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $tuple->[$axis_nr]) { } 0 244 244
304 0 my $default_value = 0;
305 0 ▶ $default_value = $range->[$axis_nr][0] if $default_value < $range->[$axis_nr][0]
Branch: 1 branch
BranchTrueFalseTotal
if $default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1] 0 0 0
Condition0%0/3
$default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1]
$default_value < $range->[$axis_nr][0] $default_value > $range->[$axis_nr][1]
Truth table0%0/3
A or B
A= $default_value < $range->[$axis_nr][0]B= $default_value > $range->[$axis_nr][1]
ABresult
1X1
011
000
306 or $default_value > $range->[$axis_nr][1];
307 0 $tuple->[$axis_nr] = $default_value;
308 } else {
309 244 my $delta = $range->[$axis_nr][1] - $range->[$axis_nr][0];
310 244 ▶ $tuple->[$axis_nr] += $delta while $tuple->[$axis_nr] < $range->[$axis_nr][0];
Branch: 1 branch
BranchTrueFalseTotal
$tuple->[$axis_nr] < $range->[$axis_nr][0] and do { $tuple->[$axis_nr] += $delta } 15 244 259
311 244 ▶ $tuple->[$axis_nr] -= $delta while $tuple->[$axis_nr] > $range->[$axis_nr][1];
Branch: 1 branch
BranchTrueFalseTotal
$tuple->[$axis_nr] > $range->[$axis_nr][1] and do { $tuple->[$axis_nr] -= $delta } 16 244 260
312 244 ▶ $tuple->[$axis_nr] = $range->[$axis_nr][0] if $tuple->[$axis_nr] == $range->[$axis_nr][1];
Branch: 1 branch
BranchTrueFalseTotal
if $tuple->[$axis_nr] == $range->[$axis_nr][1] 1 243 244
313 }
314 }
315 1010 return $tuple;
316 }
317  
318 1227 ▶sub round { # $tuple -- $precision --> $tuple
Subroutine round: called CC=5 SCAR=16.5
Pod undocumented
319 1227 my ($self, $tuple, $precision) = @_;
320 1227 ▶ return unless $self->basis->is_value_tuple( $tuple );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_value_tuple($tuple) 0 1227 1227
321 1227 $precision = $self->try_check_precision_definition( $precision );
322 1227 ▶ return "round got bad precision definition" unless ref $precision;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $precision 0 1227 1227
323 1227 ▶ [ map { ($self->is_axis_numeric( $_ ) and $precision->[$_] >= 0) ? round_decimals ($tuple->[$_], $precision->[$_]) : $tuple->[$_] } $self->basis->axis_iterator ];
Branch: 1 branch
BranchTrueFalseTotal
$self->is_axis_numeric($_) && $precision->[$_] >= 0 ? : 3669 17 3686
Condition66%2/3
$self->is_axis_numeric($_) and $precision->[$_] >= 0
!ll&&!rl&&r
0173669
MC/DC50%1/2
$self->is_axis_numeric($_) and $precision->[$_] >= 0
$self->is_axis_numeric($_) $precision->[$_] >= 0
Truth table66%2/3
A and B
A= $self->is_axis_numeric($_)B= $precision->[$_] >= 0
ABresult
0X0
100
111
324 }
325  
326 # normalisation
327 762 ▶sub normalize {
Subroutine normalize: called CC=4 SCAR=14.5
Pod undocumented
328 762 my ($self, $tuple, $range) = @_;
329 762 ▶ return unless $self->basis->is_value_tuple( $tuple );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_value_tuple($tuple) 0 762 762
330 762 $range = $self->try_check_range_definition( $range );
331 762 ▶ return $range unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 0 762 762
332 762 ▶ [ map { ($self->is_axis_numeric( $_ )) ? (($tuple->[$_] - $range->[$_][0]) / ($range->[$_][1]-$range->[$_][0]))
Branch: 1 branch
BranchTrueFalseTotal
$self->is_axis_numeric($_) ? : 2294 0 2294
333 : $tuple->[$_] } $self->basis->axis_iterator ];
334 }
335  
336 1053 ▶sub denormalize {
Subroutine denormalize: called CC=4 SCAR=14.5
Pod undocumented
337 1053 my ($self, $tuple, $range) = @_;
338 1053 ▶ return unless $self->basis->is_value_tuple( $tuple );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_value_tuple($tuple) 0 1053 1053
339 1053 $range = $self->try_check_range_definition( $range );
340 1053 ▶ return $range unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 0 1053 1053
341 1053 ▶ return [ map { ($self->is_axis_numeric( $_ )) ? ($tuple->[$_] * ($range->[$_][1]-$range->[$_][0]) + $range->[$_][0])
Branch: 1 branch
BranchTrueFalseTotal
$self->is_axis_numeric($_) ? : 3166 0 3166
342 : $tuple->[$_] } $self->basis->axis_iterator ];
343 }
344  
345 30 ▶sub denormalize_delta {
Subroutine denormalize_delta: called CC=4 SCAR=14.5
Pod undocumented
346 30 my ($self, $delta_values, $range) = @_;
347 30 ▶ return unless $self->basis->is_value_tuple( $delta_values );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_value_tuple($delta_values) 0 30 30
348 30 $range = $self->try_check_range_definition( $range );
349 30 ▶ return $range unless ref $range;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $range 0 30 30
350 30 ▶ [ map { ($self->is_axis_numeric( $_ ))
Branch: 1 branch
BranchTrueFalseTotal
$self->is_axis_numeric($_) ? : 91 0 91
351 ? ($delta_values->[$_] * ($range->[$_][1]-$range->[$_][0]))
352 : $delta_values->[$_] } $self->basis->axis_iterator ];
353 }
354  
355 62 ▶sub delta { # @normal_tuple_a, @normal_tuple_b --> @delta_tuple
Subroutine delta: called CC=7 SCAR=19.5
Pod undocumented
356 62 my ($self, $tuple1, $tuple2) = @_;
357 62 ▶ return unless $self->basis->is_value_tuple( $tuple1 ) and $self->basis->is_value_tuple( $tuple2 );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->basis->is_value_tuple($tuple1) and $self->basis->is_value_tuple($tuple2) 6 56 62
Condition100%3/3
$self->basis->is_value_tuple($tuple1) and $self->basis->is_value_tuple($tuple2)
!ll&&!rl&&r
4256
MC/DC100%2/2
$self->basis->is_value_tuple($tuple1) and $self->basis->is_value_tuple($tuple2)
$self->basis->is_value_tuple($tuple1) $self->basis->is_value_tuple($tuple2)
Truth table100%3/3
A and B
A= $self->basis->is_value_tuple($tuple1)B= $self->basis->is_value_tuple($tuple2)
ABresult
0X0
100
111
358 # ignore none numeric dimensions
359 56 ▶ my @delta = map { $self->is_axis_numeric($_) ? ($tuple2->[$_] - $tuple1->[$_]) : 0 } $self->basis->axis_iterator;
Branch: 1 branch
BranchTrueFalseTotal
$self->is_axis_numeric($_) ? : 169 0 169
360 56 ▶ [ map { $self->{'type'}[$_] ? $delta[$_] : # adapt to circular dimensions
Branch: 3 branches
BranchTrueFalseTotal
$self->{'type'}[$_] ? : 150 19 169
$delta[$_] < -0.5 ? : 8 11 19
$delta[$_] > 0.5 ? : 3 8 11
361 $delta[$_] < -0.5 ? ($delta[$_]+1) :
362 $delta[$_] > 0.5 ? ($delta[$_]-1) : $delta[$_] } $self->basis->axis_iterator ];
363 }
364  
365 50 1;
« Color/Space.pm ↑ Summary Color.pm »