line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! perl |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
13
|
use v5.26; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
7
|
use Object::Pad; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
95
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
22
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
132
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
class SVGPDF::Rect :isa(SVGPDF::Element); |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
0
|
0
|
|
method process () { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my $atts = $self->atts; |
12
|
0
|
|
|
|
|
|
my $xo = $self->xo; |
13
|
0
|
0
|
|
|
|
|
return if $atts->{omit}; # for testing/debugging. |
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
|
0
|
|
|
|
|
$self->set_transform($tf) if $tf; |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
0
|
|
|
|
unless ( $rx || $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
|
0
|
|
|
|
|
if ( $rx ) { |
32
|
0
|
0
|
|
|
|
|
$rx = $1 * $w if $rx =~ /^([-+,\d]+)\%$/; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
0
|
|
|
|
|
if ( $ry ) { |
35
|
0
|
0
|
|
|
|
|
$ry = $1 * $h if $ry =~ /^([-+,\d]+)\%$/; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
# Default one to the other. |
38
|
0
|
|
0
|
|
|
|
$rx ||= $ry; $ry ||= $rx; |
|
0
|
|
0
|
|
|
|
|
39
|
|
|
|
|
|
|
# Maximize to half of the width/height. |
40
|
0
|
0
|
|
|
|
|
if ( $rx > $w/2 ) { |
41
|
0
|
|
|
|
|
|
$rx = $w/2; |
42
|
|
|
|
|
|
|
} |
43
|
0
|
0
|
|
|
|
|
if ( $ry > $h/2 ) { |
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
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |