File Coverage

blib/lib/Graphics/Color.pm
Criterion Covered Total %
statement 2 4 50.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 4 6 66.6


line stmt bran cond sub pod time code
1             package Graphics::Color;
2             BEGIN {
3 1     1   23009 $Graphics::Color::VERSION = '0.29';
4             }
5 1     1   408 use Moose;
  0            
  0            
6             use Moose::Util::TypeConstraints;
7              
8             with qw(MooseX::Clone Graphics::Color::Equal MooseX::Storage::Deferred);
9              
10             # ABSTRACT: Device and library agnostic color spaces.
11              
12              
13             sub derive {
14             my ($self, $args) = @_;
15              
16             return unless ref($args) eq 'HASH';
17             my $new = $self->clone;
18             foreach my $key (keys %{ $args }) {
19             $new->$key($args->{$key}) if($new->can($key));
20             }
21             return $new;
22             }
23              
24              
25             sub equal_to {
26             die("Override me!");
27             }
28              
29             __PACKAGE__->meta->make_immutable;
30              
31             no Moose;
32             1;
33              
34             __END__
35             =pod
36              
37             =head1 NAME
38              
39             Graphics::Color - Device and library agnostic color spaces.
40              
41             =head1 VERSION
42              
43             version 0.29
44              
45             =head1 SYNOPSIS
46              
47             my $color = Graphics::Color::RGB->new(
48             red => .5, green => .5, blue => .5, alpha => .5
49             );
50             say $color->as_string;
51              
52             =head1 DESCRIPTION
53              
54             Graphics color is a device and library agnostic system for creating and
55             manipulating colors in various color spaces.
56              
57             =head1 DISCLAIMER
58              
59             I'm not an art student or a wizard of arcane color knowledge. I'm a normal
60             programmer with a penchant for things graphical. Hence this module is likely
61             incomplete in some places. Patches are encouraged. I've intentions of adding
62             more color spaces as well as conversion routines (where applicable).
63              
64             =head1 COLOR TYPES
65              
66             The following color types are supported.
67              
68             L<CMYK|Graphics::Color::CMYK>
69              
70             L<HSL|Graphics::Color::HSL>
71              
72             L<HSV|Graphics::Color::HSV>
73              
74             L<RGB|Graphics::Color::RGB>
75              
76             L<YIQ|Graphics::Color::YIQ>
77              
78             L<YUV|Graphics::Color::YUV>
79              
80             =head1 METHODS
81              
82             =head2 derive
83              
84             Clone this color but allow one of more of it's attributes to change by passing
85             in a hashref of options:
86              
87             my $new = $color->derive({ attr => $newvalue });
88              
89             The returned color will be identical to the cloned one, save the attributes
90             specified.
91              
92             =head2 equal_to
93              
94             Compares this color to the provided one. Returns 1 if true, else 0;
95              
96             =head2 not_equal_to
97              
98             The opposite of equal_to.
99              
100             =head1 AUTHOR
101              
102             Cory G Watson <gphat@cpan.org>
103              
104             =head1 COPYRIGHT AND LICENSE
105              
106             This software is copyright (c) 2011 by Cold Hard Code, LLC.
107              
108             This is free software; you can redistribute it and/or modify it under
109             the same terms as the Perl 5 programming language system itself.
110              
111             =cut
112