| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package VS::Chart::Color; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
25960
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
40
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp qw(croak); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
78
|
|
|
7
|
1
|
|
|
1
|
|
1063
|
use List::MoreUtils qw(any); |
|
|
1
|
|
|
|
|
1492
|
|
|
|
1
|
|
|
|
|
115
|
|
|
8
|
1
|
|
|
1
|
|
10
|
use Scalar::Util qw(blessed); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
117
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
691
|
use VS::Chart::Color::Gradient; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
1332
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
54
|
|
|
54
|
1
|
59
|
my $pkg = shift; |
|
14
|
|
|
|
|
|
|
|
|
15
|
54
|
50
|
|
|
|
100
|
if (@_ == 2) { |
|
16
|
0
|
|
|
|
|
0
|
my $c1 = $pkg->new(shift); |
|
17
|
0
|
|
|
|
|
0
|
my $c2 = $pkg->new(shift); |
|
18
|
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
return VS::Chart::Color::Gradient->new($c1, $c2); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
54
|
100
|
|
|
|
89
|
if (@_ == 1) { |
|
22
|
27
|
|
|
|
|
28
|
my $rgba = shift; |
|
23
|
27
|
50
|
|
|
|
89
|
if ($rgba =~ m/^ # [:xdigit:]{6} ([:xdigit:]{2})? $/x) { |
|
24
|
27
|
|
|
|
|
67
|
$rgba =~ s/^#//; |
|
25
|
27
|
|
|
|
|
176
|
my ($r, $g, $b, $a) = map hex, $rgba =~ /(.{2})/g; |
|
26
|
27
|
50
|
|
|
|
67
|
$a = 255 if !defined $a; |
|
27
|
27
|
|
|
|
|
61
|
return $pkg->new($r, $g, $b, $a); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
croak "Don't know how to handle '${rgba}'"; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
27
|
50
|
|
|
|
52
|
if (@_ == 3) { |
|
33
|
0
|
0
|
|
0
|
|
0
|
my $a = any { $_ > 1 } @_ ? 255 : 1; |
|
|
0
|
|
|
|
|
0
|
|
|
34
|
0
|
|
|
|
|
0
|
return $pkg->new(@_, $a); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
27
|
50
|
|
|
|
44
|
if (@_ == 4) { |
|
37
|
27
|
50
|
|
|
|
37
|
my @colors = map { defined $_ ? $_ : 0 } @_; |
|
|
108
|
|
|
|
|
206
|
|
|
38
|
27
|
50
|
|
39
|
|
123
|
if (any { $_ > 1 } @colors ) { |
|
|
39
|
|
|
|
|
72
|
|
|
39
|
27
|
|
|
|
|
33
|
@colors = map { $_ / 255 } @colors; |
|
|
108
|
|
|
|
|
202
|
|
|
40
|
|
|
|
|
|
|
} |
|
41
|
27
|
|
|
|
|
89
|
my $self = bless \@colors, $pkg; |
|
42
|
27
|
|
|
|
|
260
|
return $self; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
0
|
croak "Can't create color"; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub set { |
|
49
|
0
|
|
|
0
|
1
|
0
|
my ($self, $cx) = @_; |
|
50
|
0
|
|
|
|
|
0
|
$cx->set_source_rgba(@$self); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get { |
|
54
|
0
|
|
|
0
|
1
|
0
|
my ($pkg, $spec, $default) = @_; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
0
|
return $pkg->color($default) unless defined $spec; |
|
57
|
0
|
0
|
0
|
|
|
0
|
return $spec if blessed $spec && $spec->isa("VS::Chart::Color"); |
|
58
|
0
|
0
|
|
|
|
0
|
return $pkg->new(@$spec) if ref $spec eq 'ARRAY'; |
|
59
|
0
|
0
|
|
|
|
0
|
return $pkg->color($default) if $spec eq '1'; |
|
60
|
0
|
0
|
|
|
|
0
|
return $pkg->color($spec) if $spec =~ /^\w+$/; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
my $color; |
|
63
|
0
|
|
|
|
|
0
|
eval { |
|
64
|
0
|
|
|
|
|
0
|
$color = VS::Chart::Color->new($spec); |
|
65
|
|
|
|
|
|
|
}; |
|
66
|
0
|
0
|
|
|
|
0
|
$color = $default if $@; |
|
67
|
0
|
|
|
|
|
0
|
return $color; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
BEGIN { |
|
71
|
1
|
|
|
1
|
|
31
|
my %color = ( |
|
72
|
|
|
|
|
|
|
white => '#ffffffff', |
|
73
|
|
|
|
|
|
|
black => '#000000ff', |
|
74
|
|
|
|
|
|
|
red => '#ff0000ff', |
|
75
|
|
|
|
|
|
|
green => '#00ff00ff', |
|
76
|
|
|
|
|
|
|
blue => '#0000ffff', |
|
77
|
|
|
|
|
|
|
grid => '#ccccccff', |
|
78
|
|
|
|
|
|
|
axis => '#333333ff', |
|
79
|
|
|
|
|
|
|
major_tick => '#333333ff', |
|
80
|
|
|
|
|
|
|
minor_tick => '#eeeeeeff', |
|
81
|
|
|
|
|
|
|
text => '#000000ff', |
|
82
|
|
|
|
|
|
|
border => '#000000ff', |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Define default colors for 16 series |
|
85
|
|
|
|
|
|
|
dataset_0 => "#2e578cff", |
|
86
|
|
|
|
|
|
|
dataset_1 => "#5d9648ff", |
|
87
|
|
|
|
|
|
|
dataset_2 => "#e7a13dff", |
|
88
|
|
|
|
|
|
|
dataset_3 => "#bc2d30ff", |
|
89
|
|
|
|
|
|
|
dataset_4 => "#6f3d79ff", |
|
90
|
|
|
|
|
|
|
dataset_5 => "#7d807fff", |
|
91
|
|
|
|
|
|
|
dataset_6 => "#41699bff", |
|
92
|
|
|
|
|
|
|
dataset_7 => "#6ea45aff", |
|
93
|
|
|
|
|
|
|
dataset_8 => "#eaad55ff", |
|
94
|
|
|
|
|
|
|
dataset_9 => "#c54346ff", |
|
95
|
|
|
|
|
|
|
dataset_10 => "#814f8bff", |
|
96
|
|
|
|
|
|
|
dataset_11 => "#8e9190ff", |
|
97
|
|
|
|
|
|
|
dataset_12 => "#577caaff", |
|
98
|
|
|
|
|
|
|
dataset_13 => "#80b26eff", |
|
99
|
|
|
|
|
|
|
dataset_14 => "#eeb96dff", |
|
100
|
|
|
|
|
|
|
dataset_15 => "#ce5b5dff", |
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
2
|
my %Colors; |
|
105
|
1
|
|
|
|
|
16
|
while (my ($name, $spec) = each %color) { |
|
106
|
27
|
|
|
|
|
52
|
$Colors{$name} = __PACKAGE__->new($spec); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub color { |
|
110
|
2
|
|
|
2
|
1
|
17
|
my ($pkg, $name) = @_; |
|
111
|
|
|
|
|
|
|
|
|
112
|
2
|
50
|
33
|
|
|
12
|
return $name if blessed $name && $name->isa("VS::Chart::Color"); |
|
113
|
2
|
50
|
|
|
|
12
|
return $Colors{$name} if exists $Colors{$name}; |
|
114
|
0
|
|
|
|
|
0
|
return $Colors{black}; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub as_hex { |
|
119
|
2
|
|
|
2
|
1
|
1342
|
my $self = shift; |
|
120
|
2
|
|
|
|
|
6
|
return sprintf("#%02x%02x%02x", map { int($_ * 255) } @{$self}[0..2]); |
|
|
6
|
|
|
|
|
64
|
|
|
|
2
|
|
|
|
|
9
|
|
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
|
124
|
|
|
|
|
|
|
__END__ |