lib/ChordPro/lib/SVGPDF/Rect.pm

filter: Statementstmt 26.4% 14 / 53 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 19.5% 18 / 92 CC 13 SCAR 49.0
CC
13
Cov
18%
process
174.5
BEGIN
1.0
BEGIN
1.0
CRAP 133.7
« lib/ChordPro/Output/PDF/StringDiagram.pm ↑ Summary lib/ChordPro/Output/PDF/Writer.pm »
1 #! perl
2  
3 12 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 class SVGPDF::Rect :isa(SVGPDF::Element);
9  
10 0 ▶method process () {
Subroutine process: not called CC=13 SCAR=51.6
Pod undocumented
11 0 my $atts = $self->atts;
12 0 my $xo = $self->xo;
13 0 ▶ return if $atts->{omit}; # for testing/debugging.
Branch: 1 branch
BranchTrueFalseTotal
if $atts->{"omit"} 0 0 0
14  
15 0 my ( $x, $y, $w, $h, $rx, $ry, $tf ) =
16 $self->get_params( $atts, qw( x:H y:V width:H height:V rx:U ry:U transform:s ) );
17  
18 0 $self->_dbg( $self->name, " x=$x y=$y w=$w h=$h" );
19 0 $self->_dbg( "+ xo save" );
20 0 $xo->save;
21  
22 0 $self->set_graphics;
23 0 ▶ $self->set_transform($tf) if $tf;
Branch: 1 branch
BranchTrueFalseTotal
if $tf 0 0 0
24  
25 0 ▶ unless ( $rx || $ry ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx or $ry) { } 0 0 0
Condition0%0/3
$rx or $ry
l!l&&r!l&&!r
000
MC/DC0%0/2
$rx or $ry
$rx $ry
Truth table0%0/3
A or B
A= $rxB= $ry
ABresult
1X1
011
000
26 0 $xo->rectangle( $x, $y, $x+$w, $y+$h );
27 }
28 else {
29 # https://svgwg.org/svg2-draft/shapes.html#RectElement
30 # Resolve percentages.
31 0 ▶ if ( $rx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx) 0 0 0
32 0 ▶ $rx = $1 * $w if $rx =~ /^([-+,\d]+)\%$/;
Branch: 1 branch
BranchTrueFalseTotal
if $rx =~ /^([-+,\d]+)\%$/u 0 0 0
33 }
34 0 ▶ if ( $ry ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ry) 0 0 0
35 0 ▶ $ry = $1 * $h if $ry =~ /^([-+,\d]+)\%$/;
Branch: 1 branch
BranchTrueFalseTotal
if $ry =~ /^([-+,\d]+)\%$/u 0 0 0
36 }
37 # Default one to the other.
38 0 ▶ $rx ||= $ry; $ry ||= $rx;
Condition0%0/6
$rx ||= $ry
l!l&&r!l&&!r
000
$ry ||= $rx
l!l&&r!l&&!r
000
MC/DC0%0/2
$rx ||= $ry
$rx $ry
MC/DC0%0/2
$ry ||= $rx
$ry $rx
Truth table0%0/3
A ||= B
A= $rxB= $ry
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $ryB= $rx
ABresult
1X1
011
000
39 # Maximize to half of the width/height.
40 0 ▶ if ( $rx > $w/2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx > $w / 2) 0 0 0
41 0 $rx = $w/2;
42 }
43 0 ▶ if ( $ry > $h/2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ry > $h / 2) 0 0 0
44 0 $ry = $h/2;
45 }
46 0 $self->_dbg( $self->name, "(rounded) rx=$rx ry=$ry" );
47  
48 0 $xo->move( $x+$rx, $y );
49 0 $xo->hline( $x + $w - $rx );
50 0 $xo->arc( $x+$w-$rx, $y+$ry, $rx, $ry, -90, 0 );
51 0 $xo->vline( $y + $h - $ry );
52 0 $xo->arc( $x+$w-$rx, $y+$h-$ry, $rx, $ry, 0, 90 );
53 0 $xo->hline( $x + $rx );
54 0 $xo->arc( $x+$rx, $y+$h-$ry, $rx, $ry, 90, 180 );
55 0 $xo->vline( $y + $ry );
56 0 $xo->arc( $x+$rx, $y+$ry, $rx, $ry, 180, 270 );
57 0 $xo->close;
58 }
59  
60 0 $self->_paintsub->();
61  
62 0 $self->_dbg( "- xo restore" );
63 0 $xo->restore;
64 0 $self->css_pop;
65 12 }
66  
67 12 1;
« lib/ChordPro/Output/PDF/StringDiagram.pm ↑ Summary lib/ChordPro/Output/PDF/Writer.pm »