SWF/Type/RGBA.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 44 CC 3 SCAR 13.3
CC
3
Cov
0%
build
6.0
string
6.0
parse
2.0
CRAP 3.8
1 package IO::SWF::Type::RGBA;
2  
3 use strict;
4 use warnings;
5  
6 use base 'IO::SWF::Type';
7  
8 use IO::SWF::Bit;
9  
10 sub parse {
11 my ($reader, $opts_href) = @_;
12 my %rgba = ();
13 $rgba{'Red'} = $reader->getUI8();
14 $rgba{'Green'} = $reader->getUI8();
15 $rgba{'Blue'} = $reader->getUI8();
16 $rgba{'Alpha'} = $reader->getUI8();
17 return \%rgba;
18 }
19  
20 sub build {
21 my ($writer, $rgba_href, $opts_href) = @_;
22 my %rgba = ref($rgba_href) ? %{$rgba_href} : ();
23 $writer->putUI8($rgba{'Red'});
24 $writer->putUI8($rgba{'Green'});
25 $writer->putUI8($rgba{'Blue'});
26 $writer->putUI8($rgba{'Alpha'});
27 }
28  
29 sub string {
30 my ($color_href, $opts_href) = @_;
31 my %color = ref($color_href) ? %{$color_href} : ();
32 return sprintf("#%02x%02x%02x(%02x)", $color{'Red'}, $color{'Green'}, $color{'Blue'}, $color{'Alpha'});
33 }
34  
35 1;