| 1 | package CXC::Gnuplot::V0::ColorSpec; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use v5.38; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use experimental 'declared_refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Feature::Compat::Class; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | our $VERSION = 'v0.29.3'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | class CXC::Gnuplot::V0::ColorSpec; | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | no namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Ref::Util 'is_ref', 'is_plain_hashref'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use CXC::Gnuplot::V0::Types -lexical, 'is_PositiveOrZeroInt', 'is_RGBColor', 'Palette'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | use CXC::Gnuplot::V0::Util | ||||||||||||||||||||||||||||
| 20 | 1 | -lexical => 'assert_coerce_object', | |||||||||||||||||||||||||||
| 21 | 'pvalidate', | ||||||||||||||||||||||||||||
| 22 | 1 | ▶ | 'clone_object', 'gnuplot_color', 'to_hash_r', 'quote'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | my sub croak { | ||||||||||||||||||||||||||||
| 25 | 0 | ▶ | require Carp; | ||||||||||||||||||||||||||
|
Subroutine
croak: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 26 | 0 | goto \&Carp::croak; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | #<<< no tidy | ||||||||||||||||||||||||||||
| 30 | 1 | field $rgbcolor :param :reader = undef; | |||||||||||||||||||||||||||
| 31 | 1 | field $palette :param :reader = undef; | |||||||||||||||||||||||||||
| 32 | 1 | field $_color; | |||||||||||||||||||||||||||
| 33 | #>>> | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | ADJUST { | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | defined $rgbcolor | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=11 SCAR=48.8
Branch: 1 branch
Condition0%0/3
defined $rgbcolor and defined $palette
MC/DC0%0/2
defined $rgbcolor and defined $palette
defined $rgbcolor
defined $palette
Truth table0%0/3
A and B
A= defined $rgbcolorB= defined $palette
| |||||||||||||||||||||||||||||
| 51 | and defined $palette | ||||||||||||||||||||||||||||
| 52 | and croak( 'specify only one of "rgbcolor" or "palette"' ); | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | pvalidate( palette => Palette, \$palette ); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # take this time to convert $rgbcolor while it's being validated. | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ( defined $rgbcolor ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ( length $rgbcolor ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | ## no critic( ControlStructures::ProhibitCascadingIfElse ) | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( $_color = gnuplot_color( $rgbcolor ) ) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 63 | 0 | $_color = [ rgbcolor => quote( $_color->name ) ]; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | elsif ( is_RGBColor( $rgbcolor ) ) { | ||||||||||||||||||||||||||||
| 66 | 0 | $_color = [ rgbcolor => quote( $rgbcolor ) ]; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | ▶ | elsif ( is_PositiveOrZeroInt( $rgbcolor ) || $rgbcolor eq 'variable' ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
is_PositiveOrZeroInt $rgbcolor or $rgbcolor eq "variable"
MC/DC0%0/2
is_PositiveOrZeroInt $rgbcolor or $rgbcolor eq "variable"
is_PositiveOrZeroInt $rgbcolor
$rgbcolor eq "variable"
Truth table0%0/3
A or B
A= is_PositiveOrZeroInt $rgbcolorB= $rgbcolor eq "variable"
| |||||||||||||||||||||||||||||
| 69 | 0 | $_color = [ rgbcolor => $rgbcolor ]; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | elsif ( $rgbcolor eq 'bgnd' ) { | ||||||||||||||||||||||||||||
| 72 | 0 | $_color = $rgbcolor; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | defined $_color | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | or croak( "unrecognized color: $rgbcolor" ); | ||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | ▶ | method to_hash ( %args ) { | |||||||||||||||||||||||||||
|
Subroutine
to_hash: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | return to_hash_r( { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 87 | ( defined $rgbcolor ? ( rgbcolor => $rgbcolor ) : () ), # | ||||||||||||||||||||||||||||
| 88 | ( defined $palette ? ( palette => $palette ) : () ), | ||||||||||||||||||||||||||||
| 89 | } ); | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | ▶ | sub coerce_attrs ( $class, @attrs ) { | |||||||||||||||||||||||||||
|
Subroutine
coerce_attrs: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | return @attrs == 1 && !is_ref( $attrs[0] ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@attrs == 1 and not Ref::Util::XS::is_ref($attrs[0])
MC/DC0%0/2
@attrs == 1 and not Ref::Util::XS::is_ref($attrs[0])
@attrs == 1
not Ref::Util::XS::is_ref($attrs[0])
Truth table0%0/3
A and not(B)
A= @attrs == 1B= not Ref::Util::XS::is_ref($attrs[0])
| |||||||||||||||||||||||||||||
| 98 | ? { rgbcolor => $attrs[0] } | ||||||||||||||||||||||||||||
| 99 | : undef; | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | ▶ | sub assert_coerce( $class, $args ) { | |||||||||||||||||||||||||||
|
Subroutine
assert_coerce: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 0 | assert_coerce_object( $class, $args ); | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | ▶ | method clone ( %args ) { | |||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 115 | 0 | return clone_object( $self, \%args ); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | method opts { | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | my @opts; | ||||||||||||||||||||||||||
|
Subroutine
opts: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # palette will only ever have one key. | ||||||||||||||||||||||||||||
| 127 | 0 | ▶ | defined $palette | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 128 | and push @opts, [ palette => is_plain_hashref( $palette ) ? [ $palette->%* ] : $palette ]; | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | defined $_color | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | and push @opts, $_color; | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | return @opts; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 1 | 1; | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | # | ||||||||||||||||||||||||||||
| 139 | # This file is part of CXC-Gnuplot | ||||||||||||||||||||||||||||
| 140 | # | ||||||||||||||||||||||||||||
| 141 | # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory. | ||||||||||||||||||||||||||||
| 142 | # | ||||||||||||||||||||||||||||
| 143 | # This is free software, licensed under: | ||||||||||||||||||||||||||||
| 144 | # | ||||||||||||||||||||||||||||
| 145 | # The GNU General Public License, Version 3, June 2007 | ||||||||||||||||||||||||||||
| 146 | # | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | __END__ | ||||||||||||||||||||||||||||