| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
|
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2009,2010 -- leonerd@leonerd.org.uk |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Convert::Color::Library; |
|
7
|
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
1716
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
97
|
|
|
9
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
85
|
|
|
10
|
3
|
|
|
3
|
|
20
|
use base qw( Convert::Color::RGB8 ); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
2700
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->register_color_space( 'lib' ); |
|
13
|
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
81724
|
use Carp; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
758
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
C - named lookup of colors from C |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Directly: |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Convert::Color::Library; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $red = Convert::Color::Library->new( 'red' ); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Only use the SVG dictionary |
|
31
|
|
|
|
|
|
|
my $brown = Convert::Color::Library->new( 'svg/brown' ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Use either HTML or SVG dictionary |
|
34
|
|
|
|
|
|
|
my $pink = Convert::Color::Library->new( 'html,svg/pink' ); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Via L: |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use Convert::Color; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $cyan = Convert::Color->new( 'lib:cyan' ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $darkcyan = Convert::Color->new( 'lib:windows/darkcyan' ); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This subclass of L provides lookup of color names |
|
47
|
|
|
|
|
|
|
using Robert Krimen's L module. It therefore provides |
|
48
|
|
|
|
|
|
|
convenient access to named colours in many dictionaries, such as SVG, X11 and |
|
49
|
|
|
|
|
|
|
HTML. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 $color = Convert::Color::Library->new( $name ) |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns a new object to represent the named color. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
If the name is of the form |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
dicts/name |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Then C is parsed as a comma-separated list of dictionary names to pass |
|
66
|
|
|
|
|
|
|
to C. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub new |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
4
|
|
|
4
|
1
|
17139
|
my $class = shift; |
|
73
|
|
|
|
|
|
|
|
|
74
|
4
|
|
|
|
|
2172
|
require Color::Library; |
|
75
|
|
|
|
|
|
|
|
|
76
|
4
|
50
|
|
|
|
407941
|
if( @_ == 1 ) { |
|
77
|
4
|
|
|
|
|
13
|
my $name = $_[0]; |
|
78
|
|
|
|
|
|
|
|
|
79
|
4
|
|
|
|
|
9
|
my $color; |
|
80
|
|
|
|
|
|
|
|
|
81
|
4
|
100
|
|
|
|
28
|
if( $name =~ m{^(.*)/(.*)$} ) { |
|
82
|
2
|
|
|
|
|
11
|
( my $dicts, $name ) = ( $1, $2 ); |
|
83
|
|
|
|
|
|
|
|
|
84
|
2
|
|
|
|
|
18
|
$color = Color::Library->color( [ split m/,/, $dicts ], $name ); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
else { |
|
87
|
2
|
|
|
|
|
14
|
$color = Color::Library->color( $name ); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
4
|
50
|
|
|
|
94247
|
defined $color or croak "No such library color named '$name'"; |
|
91
|
4
|
|
|
|
|
22
|
return $class->SUPER::new( $color->rgb ); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
else { |
|
94
|
0
|
|
|
|
|
|
croak "usage: Convert::Color::Library->new( NAME )"; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Keep perl happy; keep Britain tidy |
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |