SVGPDF/Rect.pm

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