line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convert::Color::IRC; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
43951
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
4
|
1
|
|
|
1
|
|
6
|
use base qw( Convert::Color::RGB8 ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1561
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
29315
|
use constant COLOR_SPACE => 'irc'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
59
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
321
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
C - named lookup for the basic IRC colors |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Directly: |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Convert::Color::IRC; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $red = Convert::Color::IRC->new( 'red' ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Can also use index |
25
|
|
|
|
|
|
|
my $black = Convert::Color::IRC->new( 1 ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Via L: |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Convert::Color; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $cyan = Convert::Color->new( 'irc:cyan' ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This subclass of L provides predefined colors for the 16 |
36
|
|
|
|
|
|
|
basic IRC colors. Their names are |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
white |
39
|
|
|
|
|
|
|
black |
40
|
|
|
|
|
|
|
blue |
41
|
|
|
|
|
|
|
green |
42
|
|
|
|
|
|
|
red |
43
|
|
|
|
|
|
|
brown |
44
|
|
|
|
|
|
|
purple |
45
|
|
|
|
|
|
|
orange |
46
|
|
|
|
|
|
|
yellow |
47
|
|
|
|
|
|
|
light green |
48
|
|
|
|
|
|
|
cyan |
49
|
|
|
|
|
|
|
light cyan |
50
|
|
|
|
|
|
|
light blue |
51
|
|
|
|
|
|
|
pink |
52
|
|
|
|
|
|
|
gray |
53
|
|
|
|
|
|
|
light gray |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
They may be looked up either by name, or by numerical index within this list. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my %irc_colors = ( |
60
|
|
|
|
|
|
|
white => [ 255, 255, 255 ], |
61
|
|
|
|
|
|
|
black => [ 0, 0, 0 ], |
62
|
|
|
|
|
|
|
blue => [ 0, 0, 255 ], |
63
|
|
|
|
|
|
|
green => [ 0, 255, 0 ], |
64
|
|
|
|
|
|
|
red => [ 255, 0, 0 ], |
65
|
|
|
|
|
|
|
brown => [ 165, 42, 42 ], |
66
|
|
|
|
|
|
|
purple => [ 128, 0, 128 ], |
67
|
|
|
|
|
|
|
orange => [ 255, 165, 0 ], |
68
|
|
|
|
|
|
|
yellow => [ 255, 255, 0 ], |
69
|
|
|
|
|
|
|
'light green' => [ 144, 238, 144 ], |
70
|
|
|
|
|
|
|
cyan => [ 0, 255, 255 ], |
71
|
|
|
|
|
|
|
'light cyan' => [ 224, 255, 255 ], |
72
|
|
|
|
|
|
|
'light blue' => [ 173, 216, 230 ], |
73
|
|
|
|
|
|
|
pink => [ 255, 192, 203 ], |
74
|
|
|
|
|
|
|
gray => [ 128, 128, 128 ], |
75
|
|
|
|
|
|
|
'light gray' => [ 211, 211, 211 ] |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Also indexes |
79
|
|
|
|
|
|
|
my @irc_colors = ( |
80
|
|
|
|
|
|
|
'white', 'black', 'blue', 'green', |
81
|
|
|
|
|
|
|
'red', 'brown', 'purple', 'orange', |
82
|
|
|
|
|
|
|
'yellow', 'light green', 'cyan', 'light cyan', |
83
|
|
|
|
|
|
|
'light blue', 'pink', 'gray', 'light gray' |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 $color = Convert::Color::IRC->new( $name ) |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns a new object to represent the named color. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 $color = Convert::Color::IRC->new( $index ) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns a new object to represent the color at the given index. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub new |
101
|
|
|
|
|
|
|
{ |
102
|
9
|
|
|
9
|
1
|
42210
|
my $class = shift; |
103
|
9
|
|
|
|
|
19
|
my $name = shift; |
104
|
|
|
|
|
|
|
|
105
|
9
|
50
|
|
|
|
26
|
if( defined $name ) { |
106
|
9
|
100
|
|
|
|
43
|
if( $name =~ m/^\d{1,2}$/ ) { |
107
|
3
|
50
|
33
|
|
|
33
|
$name >= 0 and $name < @irc_colors or |
108
|
|
|
|
|
|
|
croak "No such IRC color at index $name"; |
109
|
|
|
|
|
|
|
|
110
|
3
|
|
|
|
|
20
|
$name = $irc_colors[$name]; |
111
|
|
|
|
|
|
|
} |
112
|
9
|
50
|
|
|
|
32
|
my $color = $irc_colors{$name} or |
113
|
|
|
|
|
|
|
croak "No such IRC color named '$name'"; |
114
|
|
|
|
|
|
|
|
115
|
9
|
|
|
|
|
68
|
return $class->SUPER::new( @$color ); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
else { |
118
|
0
|
|
|
|
|
|
croak "usage: Convert::Color::IRC->new( NAME ) or ->new( INDEX )"; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Keep perl happy; keep Britain tidy |
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |