lib/PDF/FromHTML/Template/Element/Circle.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 60 CC 5 SCAR 26.9
CC
5
Cov
0%
render
30.0
BEGIN
2.0
new
2.0
CRAP 14.7
1 package PDF::FromHTML::Template::Element::Circle;
2  
3 use strict;
4  
5 BEGIN {
6 use vars qw(@ISA);
7 @ISA = qw(PDF::FromHTML::Template::Element);
8  
9 use PDF::FromHTML::Template::Element;
10 }
11  
12 sub new
13 {
14 my $class = shift;
15 my $self = $class->SUPER::new(@_);
16  
17 # warn 'Warning: <circle> missing required attribute R' unless exists $self->{R};
18  
19 return $self;
20 }
21  
22 sub render
23 {
24 my $self = shift;
25 my ($context) = @_;
26  
27 return 0 unless $self->should_render($context);
28  
29 return 1 if $context->{CALC_LAST_PAGE};
30  
31 my ($x, $y, $r) = map { $context->get($self, $_) } qw(X Y R);
32  
33 return 1 unless defined $r;
34  
35 my $p = $context->{PDF};
36  
37 $p->save_state;
38  
39 $self->set_color($context, 'COLOR', 'stroke');
40  
41 my $fillcolor = $context->get($self, 'FILLCOLOR');
42 $self->set_color($context, 'FILLCOLOR', 'fill');
43  
44 my $width = $context->get($self, 'WIDTH') || 1;
45 $p->linewidth($width);
46  
47 $p->circle($x, $y, $r);
48  
49 if (defined $fillcolor)
50 {
51 $p->fill_stroke;
52 }
53 else
54 {
55 $p->stroke;
56 }
57  
58 $p->restore_state;
59  
60 return 1;
61 }
62  
63 sub deltas
64 {
65 my $self = shift;
66 my ($context) = @_;
67  
68 # my ($x, $y, $r) = map { $context->get($self, $_) } qw(X Y R);
69 my ($x, $y) = map { $context->get($self, $_) } qw(X Y);
70  
71 #GGG Have $r involved here?
72 return {
73 X => $x - $context->{X},
74 Y => $y - $context->{Y},
75 };
76 }
77  
78 1;
79 __END__