line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graphics::ColorNames::GrayScale; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Graphics::ColorNames::GrayScale - grayscale colors for Graphics::ColorNames |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Graphics::ColorNames::GrayScale; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$NameTable = Graphics::ColorNames::GrayScale->NamesRgbTable(); |
12
|
|
|
|
|
|
|
$RgbColor = $NameTable->{gray80}; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This module provides grayscale colors for L. |
17
|
|
|
|
|
|
|
The following are valid colors: |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Format Example Description |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
grayHH grey80 Gray value in hexidecimal (HH between 00 and ff) |
22
|
|
|
|
|
|
|
grayDDD gray128 Gray value in decimal (DDD between 000 and 255) |
23
|
|
|
|
|
|
|
grayP% gray50% Gray value in percentage (P between 0 and 100) |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Besides C, on can also use the following colors: |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
red |
28
|
|
|
|
|
|
|
green |
29
|
|
|
|
|
|
|
blue |
30
|
|
|
|
|
|
|
yellow |
31
|
|
|
|
|
|
|
cyan |
32
|
|
|
|
|
|
|
purple |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Lower values are darker, higher values are brighter. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 AUTHOR |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Robert Rothenberg |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 LICENSE |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Copyright (c) 2004 Robert Rothenberg. All rights reserved. |
43
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
44
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
require 5.006; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
7759
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
51
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
492
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
our $VERSION = '2.00'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my %RgbColors = ( ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my %Schemes = ( ); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub NamesRgbTable() { |
60
|
|
|
|
|
|
|
return sub { |
61
|
3018
|
|
|
3018
|
|
238372
|
my $name = shift; |
62
|
3018
|
100
|
|
|
|
10394
|
return $RgbColors{$name}, |
63
|
|
|
|
|
|
|
if (exists $RgbColors{$name}); |
64
|
|
|
|
|
|
|
|
65
|
2405
|
50
|
|
|
|
10018
|
if ($name =~ /^(gr[ae]y|red|green|blue|yellow|cyan|purple)([\da-f]+\%?)$/) |
66
|
|
|
|
|
|
|
{ |
67
|
2405
|
|
|
|
|
4174
|
my $color = $1; |
68
|
2405
|
|
|
|
|
3460
|
my $degree = $2; |
69
|
|
|
|
|
|
|
|
70
|
2405
|
100
|
|
|
|
5197
|
unless (keys %Schemes) { |
71
|
1
|
|
|
|
|
12
|
%Schemes = ( |
72
|
|
|
|
|
|
|
gray => 0xffffff, |
73
|
|
|
|
|
|
|
grey => 0xffffff, |
74
|
|
|
|
|
|
|
red => 0xff0000, |
75
|
|
|
|
|
|
|
green => 0x00ff00, |
76
|
|
|
|
|
|
|
blue => 0x0000ff, |
77
|
|
|
|
|
|
|
yellow => 0xffff00, |
78
|
|
|
|
|
|
|
cyan => 0x00ffff, |
79
|
|
|
|
|
|
|
purple => 0xff00ff, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
2405
|
50
|
|
|
|
8738
|
return, unless (exists $Schemes{$color}); |
84
|
|
|
|
|
|
|
|
85
|
2405
|
|
|
|
|
2174
|
my $byte; |
86
|
2405
|
100
|
|
|
|
7229
|
if ($degree =~ /^\d{3}$/) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
87
|
2048
|
|
|
|
|
2993
|
$byte = $degree; |
88
|
|
|
|
|
|
|
} elsif ($degree =~ /^(\d{1,3})\%$/) { |
89
|
101
|
|
|
|
|
223
|
$byte = int($1 / 100 * 255); |
90
|
|
|
|
|
|
|
} elsif ($degree =~ /^[\da-f]{2}$/) { |
91
|
256
|
|
|
|
|
330
|
$byte = CORE::hex $degree; |
92
|
|
|
|
|
|
|
} else { |
93
|
0
|
|
|
|
|
0
|
return; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
2405
|
50
|
|
|
|
5899
|
return, if ($byte > 255); |
97
|
|
|
|
|
|
|
|
98
|
2405
|
|
|
|
|
4594
|
my $rgb = $Schemes{$color} & ( ($byte << 16) | ($byte << 8) | $byte ); |
99
|
|
|
|
|
|
|
|
100
|
2405
|
|
|
|
|
5255
|
$RgbColors{$name} = $rgb; |
101
|
|
|
|
|
|
|
|
102
|
2405
|
|
|
|
|
13024
|
return $rgb; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
else { |
106
|
0
|
|
|
|
|
0
|
return; |
107
|
|
|
|
|
|
|
} |
108
|
1
|
|
|
1
|
0
|
805
|
}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# sub NamesRgbTable() { |
113
|
|
|
|
|
|
|
# unless (keys %RgbColors) { |
114
|
|
|
|
|
|
|
# for my $i (0..255) { |
115
|
|
|
|
|
|
|
# my $rgb = ($i << 16) | ($i << 8) | $i; |
116
|
|
|
|
|
|
|
# my $dec = sprintf('%03d',$i); |
117
|
|
|
|
|
|
|
# my $hex = sprintf('%02x',$i); |
118
|
|
|
|
|
|
|
# my $pct = int(($i / 255) * 100) . '%'; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# $RgbColors{"gray$dec"} = $rgb; |
121
|
|
|
|
|
|
|
# $RgbColors{"gray$hex"} = $rgb; |
122
|
|
|
|
|
|
|
# $RgbColors{"gray$pct"} = $rgb, |
123
|
|
|
|
|
|
|
# unless (exists $RgbColors{"gray$pct"}); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# $RgbColors{"red$dec"} = ($rgb & 0xff0000); |
126
|
|
|
|
|
|
|
# $RgbColors{"red$hex"} = ($rgb & 0xff0000); |
127
|
|
|
|
|
|
|
# $RgbColors{"red$pct"} = ($rgb & 0xff0000), |
128
|
|
|
|
|
|
|
# unless (exists $RgbColors{"red$pct"}); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# $RgbColors{"green$dec"} = ($rgb & 0x00ff00); |
131
|
|
|
|
|
|
|
# $RgbColors{"green$hex"} = ($rgb & 0x00ff00); |
132
|
|
|
|
|
|
|
# $RgbColors{"green$pct"} = ($rgb & 0x00ff00), |
133
|
|
|
|
|
|
|
# unless (exists $RgbColors{"green$pct"}); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# $RgbColors{"blue$dec"} = ($rgb & 0x0000ff); |
136
|
|
|
|
|
|
|
# $RgbColors{"blue$hex"} = ($rgb & 0x0000ff); |
137
|
|
|
|
|
|
|
# $RgbColors{"blue$pct"} = ($rgb & 0x0000ff), |
138
|
|
|
|
|
|
|
# unless (exists $RgbColors{"blue$pct"}); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# $RgbColors{"yellow$dec"} = ($rgb & 0xffff00); |
141
|
|
|
|
|
|
|
# $RgbColors{"yellow$hex"} = ($rgb & 0xffff00); |
142
|
|
|
|
|
|
|
# $RgbColors{"yellow$pct"} = ($rgb & 0xffff00), |
143
|
|
|
|
|
|
|
# unless (exists $RgbColors{"yellow$pct"}); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# $RgbColors{"cyan$dec"} = ($rgb & 0x00ffff); |
146
|
|
|
|
|
|
|
# $RgbColors{"cyan$hex"} = ($rgb & 0x00ffff); |
147
|
|
|
|
|
|
|
# $RgbColors{"cyan$pct"} = ($rgb & 0x00ffff), |
148
|
|
|
|
|
|
|
# unless (exists $RgbColors{"cyan$pct"}); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# $RgbColors{"purple$dec"} = ($rgb & 0xff00ff); |
151
|
|
|
|
|
|
|
# $RgbColors{"purple$hex"} = ($rgb & 0xff00ff); |
152
|
|
|
|
|
|
|
# $RgbColors{"purple$pct"} = ($rgb & 0xff00ff), |
153
|
|
|
|
|
|
|
# unless (exists $RgbColors{"purple$pct"}); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# } |
156
|
|
|
|
|
|
|
# } |
157
|
|
|
|
|
|
|
# return \%RgbColors; |
158
|
|
|
|
|
|
|
# } |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
1; |
161
|
|
|
|
|
|
|
|