line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graphics::Color::CMYK; |
2
|
|
|
|
|
|
|
$Graphics::Color::CMYK::VERSION = '0.30'; |
3
|
1
|
|
|
1
|
|
17871
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use MooseX::Aliases; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends qw(Graphics::Color); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: CMYK color model |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Graphics::Color::Types qw(Number360OrLess NumberOneOrLess); |
11
|
|
|
|
|
|
|
use Graphics::Color::RGB; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'cyan' => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
17
|
|
|
|
|
|
|
default => 1, |
18
|
|
|
|
|
|
|
alias => 'c' |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'magenta' => ( |
23
|
|
|
|
|
|
|
is => 'rw', |
24
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
25
|
|
|
|
|
|
|
default => 1, |
26
|
|
|
|
|
|
|
alias => 'm' |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'yellow' => ( |
31
|
|
|
|
|
|
|
is => 'rw', |
32
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
33
|
|
|
|
|
|
|
default => 1, |
34
|
|
|
|
|
|
|
alias => 'y' |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has 'key' => ( |
39
|
|
|
|
|
|
|
is => 'rw', |
40
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
41
|
|
|
|
|
|
|
default => 1, |
42
|
|
|
|
|
|
|
alias => 'k' |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has 'name' => ( is => 'rw', isa => 'Str' ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub as_string { |
50
|
|
|
|
|
|
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
my ($self) = @_; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
my ($self) = @_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return ($self->cyan, $self->magenta, $self->yellow, $self->key); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub equal_to { |
76
|
|
|
|
|
|
|
my ($self, $other) = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return 0 unless defined($other); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
unless($self->cyan == $other->cyan) { |
81
|
|
|
|
|
|
|
return 0; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
unless($self->magenta == $other->magenta) { |
84
|
|
|
|
|
|
|
return 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
unless($self->yellow == $other->yellow) { |
87
|
|
|
|
|
|
|
return 0; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
unless($self->key == $other->key) { |
90
|
|
|
|
|
|
|
return 0; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return 1; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
no Moose; |
99
|
|
|
|
|
|
|
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 |