| 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
| |||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | unless ( $rx || $ry ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rx or $ry
MC/DC0%0/2
$rx or $ry
$rx
$ry
Truth table0%0/3
A or B
A= $rxB= $ry
| |||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | $rx = $1 * $w if $rx =~ /^([-+,\d]+)\%$/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ( $ry ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $ry = $1 * $h if $ry =~ /^([-+,\d]+)\%$/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||
| 37 | # Default one to the other. | ||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $rx ||= $ry; $ry ||= $rx; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$rx ||= $ry
$ry ||= $rx
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
Truth table0%0/3
A ||= B
A= $ryB= $rx
| |||||||||||||||||||||||||||||||||||||||
| 39 | # Maximize to half of the width/height. | ||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if ( $rx > $w/2 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $rx = $w/2; | |||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ( $ry > $h/2 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||||||||||||