blib/lib/PGPLOTx/Constants.pm

filter: Statementstmt 100% 50 / 50 Branchbran 100% 10 / 10 Conditioncond 66.6% 10 / 15 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 100% 11 / 11 Podpod 100% 2 / 2 totaltotal 89.5% 86 / 96 CC 11 SCAR 10.7
CC
11
Cov
93%
_exporter_merge_opts
5.0
_exporter_validate_opts
4.1
coerce_constant
3.0
CRAP 2.9
↑ Summary
1 package PGPLOTx::Constants;
2  
3 # ABSTRACT: Constants for use with PGPLOT
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use CXC::Exporter::Util ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use parent 'Exporter::Tiny';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #<<<
12 2 our $VERSION = '0.03';
13 #>>>
14  
15 my %Constants = (
16 ARROWHEAD_FILL_STYLES => {
17 SOLID => 1,
18 FILLED => 1,
19 OUTLINE => 2,
20 },
21  
22 COLORS => {
23 BACKGROUND => 0,
24 BLACK => 0,
25 FOREGROUND => 1,
26 WHITE => 1,
27 RED => 2,
28 GREEN => 3,
29 BLUE => 4,
30 CYAN => 5,
31 MAGENTA => 6,
32 YELLOW => 7,
33 ORANGE => 8,
34 GREEN_YELLOW => 9,
35 GREEN_CYAN => 10,
36 BLUE_CYAN => 11,
37 BLUE_MAGENTA => 12,
38 RED_MAGENTA => 13,
39 DARK_GRAY => 14,
40 LIGHT_GRAY => 15,
41 DARKGRAY => 14,
42 LIGHTGRAY => 15,
43 },
44  
45 AREA_FILL_STYLES => {
46 SOLID => 1,
47 FILLED => 1,
48 OUTLINE => 2,
49 HATCHED => 3,
50 CROSS_HATCHED => 4,
51 },
52  
53 FONTS => {
54 NORMAL => 1,
55 ROMAN => 2,
56 ITALIC => 3,
57 SCRIPT => 4,
58 },
59  
60 LINE_STYLES => {
61 FULL => 1,
62 DASHED => 2,
63 DOT_DASH_DOT_DASH => 3,
64 DOTTED => 4,
65 DASH_DOT_DOT_DOT => 5,
66 },
67  
68 PLOT_UNITS => {
69 NORMALIZED_DEVICE_COORDINATES => 0,
70 NDC => 0,
71 INCHES => 1,
72 IN => 1,
73 MILLIMETERS => 2,
74 MM => 2,
75 PIXELS => 3,
76 WORLD_COORDINATES => 4,
77 WC => 4,
78 },
79  
80 SYMBOLS => {
81 DOICOSAGON => -22,
82 HENICOSAGON => -21,
83 ICOSAGON => -20,
84 ENNEADECAGON => -19,
85 OCTADECAGON => -18,
86 HEPTADECAGON => -17,
87 HEXADECAGON => -16,
88 PENTADECAGON => -15,
89 TETRADECAGON => -14,
90 TRIDECAGON => -13,
91 DODECAGON => -12,
92 HENDECAGON => -11,
93 DECAGON => -10,
94 NONAGON => -9,
95 ENNEAGON => -9,
96 OCTAGON => -8,
97 HEPTAGON => -7,
98 HEXAGON => -6,
99 PENTAGON => -5,
100 DIAMOND => -4,
101 TRIANGLE => -3,
102 DOT0 => -2,
103 DOT1 => -1,
104 OPENSQUARE => 0,
105 DOT => 1,
106 PLUS => 2,
107 ASTERISK => 3,
108 OPENCIRCLE => 4,
109 CROSS => 5,
110 OPENSQUARE1 => 6,
111 OPENTRIANGLE => 7,
112 EARTH => 8,
113 SUN => 9,
114 CURVESQUARE => 10,
115 OPENDIAMOND => 11,
116 OPENSTAR => 12,
117 TRIANGLE1 => 13,
118 OPENPLUS => 14,
119 STARDAVID => 15,
120 SQUARE => 16,
121 CIRCLE => 17,
122 STAR => 18,
123 BIGOSQUARE => 19,
124 OPENCIRC0 => 20,
125 OPENCIRC1 => 21,
126 OPENCIRC2 => 22,
127 OPENCIRC3 => 23,
128 OPENCIRC4 => 24,
129 OPENCIRC5 => 25,
130 OPENCIRC6 => 26,
131 OPENCIRC7 => 27,
132 BACKARROW => 28,
133 FWDARROW => 29,
134 UPARROW => 30,
135 DOWNARROW => 31
136 },
137  
138 22 XAXIS_OPTIONS => { map { ( "XAXIS_OPT_$_" => $_ ) } qw( A B C G I L N P M T S ) },
139  
140 2 YAXIS_OPTIONS => { map { ( "YAXIS_OPT_$_" => $_ ) } qw( A B C G I L N P M T S V ) },
141 );
142  
143 2 install_CONSTANTS( \%Constants );
144 2 install_EXPORTS( { subs => [qw(coerce_constant list_constants)] } );
145  
146 18 ▶sub _croak {
Subroutine _croak: called CC=1 SCAR=0.0
147 18 require Carp;
148 18 goto \&Carp::croak;
149 }
150  
151 2 my %Coerce;
152  
153 2 for my $tag ( keys %Constants ) {
154  
155 18 my $coerce = $Coerce{ lc $tag } = {};
156 18 for my $const ( keys %{ $Constants{$tag} } ) {
157 248 my $ref = \$Constants{$tag}{$const};
158 248 $coerce->{$const} = $coerce->{ lc $const } = $ref;
159 248 $const =~ s/_/-/g;
160 248 $coerce->{$const} = $coerce->{ lc $const } = $ref;
161 }
162  
163 }
164  
165 22 ▶sub _exporter_validate_opts {
Subroutine _exporter_validate_opts: called CC=4 SCAR=14.0
166 22 my ( $class, $globals ) = @_;
167  
168 22 ▶ if ( exists $globals->{as} && !ref $globals->{as} && $globals->{as} eq 'lc' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $globals->{"as"} and not ref $globals->{"as"} and $globals->{"as"} eq "lc") 1 21 22
Condition66%4/6
exists $globals->{"as"} and not ref $globals->{"as"} and $globals->{"as"} eq "lc"
!ll&&!rl&&r
2101
exists $globals->{"as"} and not ref $globals->{"as"}
!ll&&!rl&&r
2101
MC/DC33%1/3
exists $globals->{"as"} and not ref $globals->{"as"} and $globals->{"as"} eq "lc"
exists $globals->{"as"} not ref $globals->{"as"} $globals->{"as"} eq "lc"
Truth table50%2/4
A and not(B) and C
A= exists $globals->{"as"}B= not ref $globals->{"as"}C= $globals->{"as"} eq "lc"
ABCresult
0XX0
10X0
1100
1111
169 20 ▶ $globals->{as} = sub { lc $_[0] }
Subroutine __ANON__: called CC=1 SCAR=0.0
170 1 }
171 }
172  
173 11 ▶sub _exporter_merge_opts {
Subroutine _exporter_merge_opts: called CC=5 SCAR=16.2
174 11 my $class = shift;
175 11 my $tag_opts = shift;
176  
177 11 ▶ $tag_opts = {} unless ref( $tag_opts ) eq q(HASH);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tag_opts eq "HASH" 10 1 11
178 11 ▶ if ( exists $tag_opts->{-as} && !ref $tag_opts->{-as} && $tag_opts->{-as} eq 'lc' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tag_opts->{"-as"} and not ref $tag_opts->{"-as"} and $tag_opts->{"-as"} eq "lc") 1 10 11
Condition66%4/6
exists $tag_opts->{"-as"} and not ref $tag_opts->{"-as"} and $tag_opts->{"-as"} eq "lc"
!ll&&!rl&&r
1001
exists $tag_opts->{"-as"} and not ref $tag_opts->{"-as"}
!ll&&!rl&&r
1001
MC/DC33%1/3
exists $tag_opts->{"-as"} and not ref $tag_opts->{"-as"} and $tag_opts->{"-as"} eq "lc"
exists $tag_opts->{"-as"} not ref $tag_opts->{"-as"} $tag_opts->{"-as"} eq "lc"
Truth table50%2/4
A and not(B) and C
A= exists $tag_opts->{"-as"}B= not ref $tag_opts->{"-as"}C= $tag_opts->{"-as"} eq "lc"
ABCresult
0XX0
10X0
1100
1111
179 1 ▶ $tag_opts = { %{$tag_opts}, -as => sub { lc $_[0] } };
Subroutine __ANON__: called CC=1 SCAR=0.0
180 }
181  
182 11 return $class->SUPER::_exporter_merge_opts( $tag_opts, @_ );
183 }
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202 327 ▶sub coerce_constant {
Subroutine coerce_constant: called CC=3 SCAR=11.0
Pod documented
203 327 my ( $tag, $label ) = @_;
204  
205 _croak( "unknown constant '$tag:$label'" )
206 unless exists $Coerce{$tag}
207 327 ▶ && exists $Coerce{$tag}{$label};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Coerce{$tag} and exists $Coerce{$tag}{$label} 9 318 327
Condition66%2/3
exists $Coerce{$tag} and exists $Coerce{$tag}{$label}
!ll&&!rl&&r
09318
MC/DC50%1/2
exists $Coerce{$tag} and exists $Coerce{$tag}{$label}
exists $Coerce{$tag} exists $Coerce{$tag}{$label}
Truth table66%2/3
A and B
A= exists $Coerce{$tag}B= exists $Coerce{$tag}{$label}
ABresult
0X0
100
111
208  
209 318 return ${ $Coerce{$tag}{$label} };
210 }
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221 18 ▶sub list_constants {
Subroutine list_constants: called CC=2 SCAR=6.9
Pod documented
222 18 my ( $tag ) = @_;
223  
224 _croak( "unknown constant tag '$tag'" )
225 18 ▶ unless exists $Coerce{$tag};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Coerce{$tag} 9 9 18
226  
227 9 return ( sort keys %{ $Coerce{$tag} } );
228 }
229  
230 2 1;
231  
232 #
233 # This file is part of PGPLOTx-Constants
234 #
235 # This software is Copyright (c) 2026 by Smithsonian Astrophysical Observatory.
236 #
237 # This is free software, licensed under:
238 #
239 # The GNU General Public License, Version 3, June 2007
240 #
241  
242 __END__
↑ Summary