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, 2014 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Convert::Color::mIRC; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
15949
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
9
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
52
|
|
10
|
2
|
|
|
2
|
|
13
|
use base qw( Convert::Color::RGB8 ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
983
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
33640
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
603
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->register_color_space( 'mirc' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
C - indexed colors used by mIRC |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Directly: |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Convert::Color::mIRC; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $red = Convert::Color::mIRC->new( 3 ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Via L: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Convert::Color; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $cyan = Convert::Color->new( 'mirc:11' ) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This subclass of L provides lookup of the colours that |
39
|
|
|
|
|
|
|
F uses by default. Note that of course the module is not intelligent |
40
|
|
|
|
|
|
|
enough to be able to parse mIRC config, or know what palettes users are |
41
|
|
|
|
|
|
|
actually using, and thus it provides only an approximation of the likely |
42
|
|
|
|
|
|
|
behaviour of clients. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The palette implemented consists of 16 colours, described as: |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
0 1 2 3 4 5 6 7 |
47
|
|
|
|
|
|
|
white black blue green red brown purple orange |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
8 9 10 11 12 13 14 15 |
50
|
|
|
|
|
|
|
yellow light-green teal cyan light-blue pink grey silver |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my @color; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _init_colors |
57
|
|
|
|
|
|
|
{ |
58
|
1
|
|
|
1
|
|
1
|
my $idx = 0; |
59
|
1
|
|
|
|
|
6
|
while( ) { |
60
|
16
|
|
|
|
|
13
|
chomp; |
61
|
16
|
|
|
|
|
36
|
my $c = __PACKAGE__->SUPER::new( $_ ); |
62
|
16
|
|
|
|
|
224
|
$c->[3] = $idx++; |
63
|
|
|
|
|
|
|
|
64
|
16
|
|
|
|
|
42
|
push @color, $c; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__PACKAGE__->register_palette( |
69
|
|
|
|
|
|
|
enumerate_once => sub { |
70
|
|
|
|
|
|
|
@color or _init_colors; |
71
|
|
|
|
|
|
|
@color |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 $color = Convert::Color::mIRC->new( $index ) |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns a new object to represent the color at that index. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# TODO: Surely we can move this logic into Convert::Color base somehow... |
86
|
|
|
|
|
|
|
sub new |
87
|
|
|
|
|
|
|
{ |
88
|
2
|
|
|
2
|
1
|
11
|
my $class = shift; |
89
|
2
|
50
|
|
|
|
5
|
croak "usage: Convert::Color::mIRC->new( INDEX )" unless @_ == 1; |
90
|
2
|
|
|
|
|
3
|
my ( $index ) = @_; |
91
|
|
|
|
|
|
|
|
92
|
2
|
100
|
|
|
|
6
|
@color or _init_colors; |
93
|
|
|
|
|
|
|
|
94
|
2
|
50
|
33
|
|
|
10
|
$index >= 0 and $index < @color or |
95
|
|
|
|
|
|
|
croak "No such mIRC color at index '$index'"; |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
|
|
5
|
return $color[$index]; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 METHODS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 $index = $color->index |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The index of the mIRC color. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub index |
111
|
|
|
|
|
|
|
{ |
112
|
3
|
|
|
3
|
1
|
3771
|
my $self = shift; |
113
|
3
|
|
|
|
|
11
|
return $self->[3]; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 TODO |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=over 4 |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Find out if the embedded colour palette really is the default mIRC one, or |
123
|
|
|
|
|
|
|
update it if not. Patches welcome ;) |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Paul Evans |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
0x55AA; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# This palette taken from |
136
|
|
|
|
|
|
|
# http://www.mish-script.de/help/mircini/colors.htm |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
__DATA__ |