| 1 | package Graphics::Color::CMYK; | ||||||||||
| 2 | 1 | $Graphics::Color::CMYK::VERSION = '0.30'; | |||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use MooseX::Aliases; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | extends qw(Graphics::Color); | |||||||||
| 7 | |||||||||||
| 8 | # ABSTRACT: CMYK color model | ||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Graphics::Color::Types qw(Number360OrLess NumberOneOrLess); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Graphics::Color::RGB; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | 1 | has 'cyan' => ( | |||||||||
| 15 | is => 'rw', | ||||||||||
| 16 | isa => NumberOneOrLess, | ||||||||||
| 17 | default => 1, | ||||||||||
| 18 | alias => 'c' | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | 1 | has 'magenta' => ( | |||||||||
| 23 | is => 'rw', | ||||||||||
| 24 | isa => NumberOneOrLess, | ||||||||||
| 25 | default => 1, | ||||||||||
| 26 | alias => 'm' | ||||||||||
| 27 | ); | ||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | 1 | has 'yellow' => ( | |||||||||
| 31 | is => 'rw', | ||||||||||
| 32 | isa => NumberOneOrLess, | ||||||||||
| 33 | default => 1, | ||||||||||
| 34 | alias => 'y' | ||||||||||
| 35 | ); | ||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | 1 | has 'key' => ( | |||||||||
| 39 | is => 'rw', | ||||||||||
| 40 | isa => NumberOneOrLess, | ||||||||||
| 41 | default => 1, | ||||||||||
| 42 | alias => 'k' | ||||||||||
| 43 | ); | ||||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | 1 | has 'name' => ( is => 'rw', isa => 'Str' ); | |||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | sub as_string { | ||||||||||
| 50 | 1 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 51 | |||||||||||
| 52 | 1 | return sprintf('%0.2f,%0.2f,%0.2f,%0.2f', | |||||||||
| 53 | $self->cyan, $self->magenta, $self->yellow, $self->key | ||||||||||
| 54 | ); | ||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | sub as_percent_string { | ||||||||||
| 59 | 1 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
as_percent_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 60 | |||||||||||
| 61 | 1 | return sprintf("%d%%, %d%%, %d%%, %d%%", | |||||||||
| 62 | $self->cyan * 100, $self->magenta * 100, $self->yellow * 100, | ||||||||||
| 63 | $self->key * 100 | ||||||||||
| 64 | ); | ||||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | sub as_array { | ||||||||||
| 69 | 1 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
as_array: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 70 | |||||||||||
| 71 | 1 | return ($self->cyan, $self->magenta, $self->yellow, $self->key); | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | |||||||||||
| 75 | sub equal_to { | ||||||||||
| 76 | 2 | ▶ | my ($self, $other) = @_; | ||||||||
|
Subroutine
equal_to: called CC=6 SCAR=19.9
Pod
documented
| |||||||||||
| 77 | |||||||||||
| 78 | 2 | ▶ | return 0 unless defined($other); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | |||||||||||
| 80 | 2 | ▶ | unless($self->cyan == $other->cyan) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 0 | return 0; | |||||||||
| 82 | } | ||||||||||
| 83 | 2 | ▶ | unless($self->magenta == $other->magenta) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 0 | return 0; | |||||||||
| 85 | } | ||||||||||
| 86 | 2 | ▶ | unless($self->yellow == $other->yellow) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | 1 | return 0; | |||||||||
| 88 | } | ||||||||||
| 89 | 1 | ▶ | unless($self->key == $other->key) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 0 | return 0; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 1 | return 1; | |||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 97 | |||||||||||
| 98 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 99 | 1 | 1; | |||||||||
| 100 | |||||||||||
| 101 | __END__ | ||||||||||
| 102 | |||||||||||
| 103 | =pod | ||||||||||
| 104 | |||||||||||
| 105 | =head1 NAME | ||||||||||
| 106 | |||||||||||
| 107 | Graphics::Color::CMYK - CMYK color model | ||||||||||
| 108 | |||||||||||
| 109 | =head1 VERSION | ||||||||||
| 110 | |||||||||||
| 111 | version 0.30 | ||||||||||
| 112 | |||||||||||
| 113 | =head1 SYNOPSIS | ||||||||||
| 114 | |||||||||||
| 115 | use Graphics::Color::CMYK; | ||||||||||
| 116 | |||||||||||
| 117 | my $color = Graphics::Color::CMYK->new({ | ||||||||||
| 118 | cyan => 120, | ||||||||||
| 119 | magenta => .5, | ||||||||||
| 120 | yellow => .25, | ||||||||||
| 121 | key => .5 | ||||||||||
| 122 | }); | ||||||||||
| 123 | |||||||||||
| 124 | =head1 DESCRIPTION | ||||||||||
| 125 | |||||||||||
| 126 | Graphics::Color::CMYK represents a Color in CMYK color model. Cyan stands for | ||||||||||
| 127 | B<Cyan> B<Magenta> B<Yellow> B<Key> (or black). | ||||||||||
| 128 | |||||||||||
| 129 | =head1 ATTRIBUTES | ||||||||||
| 130 | |||||||||||
| 131 | =head2 cyan | ||||||||||
| 132 | |||||||||||
| 133 | =head2 c | ||||||||||
| 134 | |||||||||||
| 135 | Set/Get the cyan component of this Color. | ||||||||||
| 136 | |||||||||||
| 137 | =head2 magenta | ||||||||||
| 138 | |||||||||||
| 139 | =head2 m | ||||||||||
| 140 | |||||||||||
| 141 | Set/Get the magenta component of this Color. | ||||||||||
| 142 | |||||||||||
| 143 | =head2 yellow | ||||||||||
| 144 | |||||||||||
| 145 | =head2 y | ||||||||||
| 146 | |||||||||||
| 147 | Set/Get the yellow component of this Color. | ||||||||||
| 148 | |||||||||||
| 149 | =head2 key | ||||||||||
| 150 | |||||||||||
| 151 | =head2 k | ||||||||||
| 152 | |||||||||||
| 153 | Set/Get the key (black) component of this Color. | ||||||||||
| 154 | |||||||||||
| 155 | =head2 name | ||||||||||
| 156 | |||||||||||
| 157 | Get the name of this color. Only valid if the color was created by name. | ||||||||||
| 158 | |||||||||||
| 159 | =head1 METHODS | ||||||||||
| 160 | |||||||||||
| 161 | =head2 as_string | ||||||||||
| 162 | |||||||||||
| 163 | Get a string version of this Color in the form of: | ||||||||||
| 164 | |||||||||||
| 165 | CYAN,MAGENTA,YELLOW,KEY | ||||||||||
| 166 | |||||||||||
| 167 | =head2 as_percent_string | ||||||||||
| 168 | |||||||||||
| 169 | Return a percent formatted value for this color. | ||||||||||
| 170 | |||||||||||
| 171 | =head2 as_array | ||||||||||
| 172 | |||||||||||
| 173 | Get the CMYK values as an array | ||||||||||
| 174 | |||||||||||
| 175 | =head2 equal_to | ||||||||||
| 176 | |||||||||||
| 177 | Compares this color to the provided one. Returns 1 if true, else 0; | ||||||||||
| 178 | |||||||||||
| 179 | =head2 not_equal_to | ||||||||||
| 180 | |||||||||||
| 181 | The opposite of C<equal_to>. | ||||||||||
| 182 | |||||||||||
| 183 | =head1 AUTHOR | ||||||||||
| 184 | |||||||||||
| 185 | Cory G Watson <gphat@cpan.org> | ||||||||||
| 186 | |||||||||||
| 187 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 188 | |||||||||||
| 189 | This software is copyright (c) 2014 by Cold Hard Code, LLC. | ||||||||||
| 190 | |||||||||||
| 191 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 192 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 193 | |||||||||||
| 194 | =cut | ||||||||||