File Coverage

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


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