blib/lib/Graphics/Primitive/Canvas.pm

filter: Statementstmt 100% 32 / 32 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 95.9% 47 / 49 CC 3 SCAR 2.9
CC
3
Cov
94%
restore
2.0
do
2.0
BEGIN
1.0
CRAP 1.3
« blib/lib/Graphics/Primitive/Component.pm ↑ Summary blib/lib/Graphics/Primitive.pm »
1 package Graphics::Primitive::Canvas;
2 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use MooseX::Storage;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 extends 'Graphics::Primitive::Component';
6  
7 1 with 'MooseX::Clone';
8 1 with Storage (format => 'JSON', io => 'File');
9  
10 1 ▶use Graphics::Primitive::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 has path => (
13 isa => 'Graphics::Primitive::Path',
14 is => 'rw',
15 1 ▶ default => sub { Graphics::Primitive::Path->new },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 1 handles => [
17 'arc', 'close_path', 'current_point', 'curve_to', 'line_to',
18 'move_to', 'rectangle', 'rel_curve_to', 'rel_line_to', 'rel_move_to'
19 ]
20 );
21  
22 has paths => (
23 traits => [qw(Array Clone)],
24 isa => 'ArrayRef',
25 is => 'rw',
26 1 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
27 1 handles => {
28 add_path => 'push',
29 path_count => 'count',
30 get_path => 'get',
31 }
32 );
33  
34 has saved_paths => (
35 traits => [qw(Array Copy)],
36 isa => 'ArrayRef',
37 is => 'rw',
38 1 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
39 1 handles => {
40 push_path => 'push',
41 pop_path => 'pop',
42 saved_path_count => 'count',
43 }
44 );
45  
46 2 ▶sub do {
Subroutine do: called CC=2 SCAR=7.0
Pod documented
47 2 my ($self, $op) = @_;
48  
49 2 $self->add_path({ op => $op, path => $self->path->clone });
50 # Don't replace the current path if we are preserving.
51 2 ▶ unless($op->preserve) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($op->preserve) 2 0 2
52 2 $self->path(Graphics::Primitive::Path->new);
53 }
54 }
55  
56 2 ▶sub save {
Subroutine save: called CC=1 SCAR=0.0
Pod documented
57 2 my ($self) = @_;
58  
59 2 $self->push_path($self->path->clone);
60 }
61  
62 2 ▶sub restore {
Subroutine restore: called CC=2 SCAR=7.1
Pod documented
63 2 my ($self) = @_;
64  
65 2 ▶ return if($self->saved_path_count < 1);
Branch: 1 branch
BranchTrueFalseTotal
if $self->saved_path_count < 1 0 2 2
66  
67 2 $self->path($self->pop_path);
68 }
69  
70 1 __PACKAGE__->meta->make_immutable;
71  
72 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 1 1;
74 __END__
« blib/lib/Graphics/Primitive/Component.pm ↑ Summary blib/lib/Graphics/Primitive.pm »