SpriteBuilder/ImageDriver/Common.pm

filter: Statementstmt 54.5% 18 / 33 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 6 / 15 Podpod 100% 12 / 12 totaltotal 61.2% 38 / 62 CC 2 SCAR 5.2
CC
2
Cov
57%
driver
2.0
width
2.0
height
2.0
CRAP 1.7
« SpriteBuilder/SpriteItem.pm ↑ Summary SpriteBuilder/ImageDriver/Fake.pm »
1 package CSS::SpriteBuilder::ImageDriver::Common;
2  
3 =head1 NAME
4  
5 CSS::SpriteBuilder::Image::Common - Abstract class for image manipulation
6  
7 head1 SYNOPSIS
8  
9 my $image = SpriteBuilder::ImageDriver::<driver>->new();
10  
11 $image->read('image.png');
12  
13 $image->extent( $image->width() * 2, $image->height() * 2);
14  
15 $image->write('image2.png');
16  
17 =head1 METHODS
18  
19 =head2 new
20  
21 my $image = SpriteBuilder::ImageDriver::<driver>->new();
22  
23 Creates a new blank image.
24  
25 =back
26  
27 =head2 driver
28  
29 Returns a driver name (ImageMagick, GD or undef).
30  
31 =back
32  
33 =head2 width
34  
35 Returns a width of image.
36  
37 =back
38  
39 =head2 height
40  
41 Returns a height of image.
42  
43 =back
44  
45 =head2 is_blank
46  
47 Returns '1' when image is blank.
48  
49 =back
50  
51 =head2 reset([<image>])
52  
53 Make a blank image.
54 When B<image> parameter is specified than assign the initial value as B<image>.
55  
56 =back
57  
58 =head2 set_transparent_color(<color>)
59  
60 $image->set_transparent_color('white');
61  
62 Set transparent color.
63  
64 =back
65  
66 =head2 set_quality(<0..100>)
67  
68 Set image qualit (for JPEG only).
69  
70 =back
71  
72 =head2 read(<filename>)
73  
74 Reads an image from a file.
75  
76 =back
77  
78 =head2 write(<filename>)
79  
80 Writes the image to a file.
81  
82 =back
83  
84 =head2 extent(<width>, <height>)
85  
86 Extent image to B<width> x B<height>.
87  
88 =back
89  
90 =head2 composite(<image>, <x>, <y>)
91  
92 Composite image, specified by B<image> parameter, onto source image.
93  
94 =back
95  
96 =cut
97  
98 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
99 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
100 4 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
101  
102 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
103 6 my ($class, @args) = @_;
104  
105 6 my $self = bless {
106 _image => undef,
107 _quality => undef,
108 @args,
109 }, $class;
110  
111 6 $self->reset();
112  
113 6 return $self;
114 }
115  
116 0 ▶sub driver { undef }
Subroutine driver: not called CC=1 SCAR=6.9
Pod documented
117 0 ▶sub width { 0 }
Subroutine width: not called CC=1 SCAR=6.9
Pod documented
118 0 ▶sub height { 0 }
Subroutine height: not called CC=1 SCAR=6.9
Pod documented
119 9 ▶sub is_blank { $_[0]->width() ? 0 : 1 }
Subroutine is_blank: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->width ? : 3 6 9
120  
121 0 ▶sub reset {
Subroutine reset: not called CC=1 SCAR=6.9
Pod documented
122 0 my ($self, $image) = @_;
123  
124 # Nothing
125  
126 0 return;
127 }
128  
129 0 ▶sub set_transparent_color {
Subroutine set_transparent_color: not called CC=1 SCAR=6.9
Pod documented
130 0 my ($self, $color) = @_;
131  
132 # Nothing
133  
134 0 return;
135 }
136  
137 3 ▶sub set_quality {
Subroutine set_quality: called CC=1 SCAR=0.0
Pod documented
138 3 my ($self, $quality) = @_;
139  
140 3 $self->{_quality} = $quality;
141  
142 3 return;
143 }
144  
145 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
Pod documented
146 0 my ($self, $filename) = @_;
147  
148 0 die "Not implemented";
149 }
150  
151 0 ▶sub write {
Subroutine write: not called CC=1 SCAR=6.9
Pod documented
152 0 my ($self, $filename) = @_;
153  
154 0 die "Not implemented";
155 }
156  
157 0 ▶sub extent {
Subroutine extent: not called CC=1 SCAR=6.9
Pod documented
158 0 my ($self, $width, $height) = @_;
159  
160 0 die "Not implemented";
161 }
162  
163 0 ▶sub composite {
Subroutine composite: not called CC=1 SCAR=6.9
Pod documented
164 0 my ($self, $image, $x, $y) = @_;
165  
166 0 die "Not implemented";
167 }
168  
169 4 1;
« SpriteBuilder/SpriteItem.pm ↑ Summary SpriteBuilder/ImageDriver/Fake.pm »