line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convert::Color::LCh; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
14
|
use 5.008009; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
13
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
3
|
use parent qw/Convert::Color/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
57
|
use Convert::Color::LUV; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
11
|
1
|
|
|
1
|
|
1080
|
use Math::Trig ':pi'; |
|
1
|
|
|
|
|
18587
|
|
|
1
|
|
|
|
|
409
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->register_color_space('lch'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
12288
|
|
|
12288
|
1
|
12853
|
my ($class, $l, $c, $h) = @_; |
17
|
12288
|
50
|
|
|
|
17685
|
($l, $c, $h) = split /,/s, $l unless defined $c; |
18
|
12288
|
|
|
|
|
54782
|
bless [$l, $c, $h], $class |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
0
|
1
|
0
|
sub L { shift->[0] } |
22
|
0
|
|
|
0
|
1
|
0
|
sub C { shift->[1] } |
23
|
0
|
|
|
0
|
1
|
0
|
sub h { shift->[2] } |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
0
|
1
|
0
|
sub lch { @{$_[0]} } |
|
0
|
|
|
|
|
0
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub convert_to_luv { |
28
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
29
|
0
|
|
|
|
|
0
|
my ($l, $c, $h) = @$self; |
30
|
0
|
|
|
|
|
0
|
my $hrad = $h / 180 * pi; |
31
|
0
|
|
|
|
|
0
|
my $u = $c * cos $hrad; |
32
|
0
|
|
|
|
|
0
|
my $v = $c * sin $hrad; |
33
|
0
|
|
|
|
|
0
|
Convert::Color::LUV->new($l, $u, $v) |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new_from_luv { |
37
|
12288
|
|
|
12288
|
0
|
12937
|
my ($class, $luv) = @_; |
38
|
12288
|
|
|
|
|
13122
|
my ($l, $u, $v) = @$luv; |
39
|
12288
|
|
|
|
|
16687
|
my $c = sqrt $u * $u + $v * $v; |
40
|
12288
|
100
|
|
|
|
21277
|
return $class->new($l, $c, 0) if $c < 0.00000001; |
41
|
12240
|
|
|
|
|
20673
|
my $hrad = atan2 $v, $u; |
42
|
12240
|
|
|
|
|
13688
|
my $h = $hrad * 180 / pi; |
43
|
12240
|
100
|
|
|
|
19597
|
$h += 360 if $h < 0; |
44
|
12240
|
|
|
|
|
22321
|
$class->new($l, $c, $h) |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
0
|
sub rgb { shift->convert_to_luv->rgb } |
48
|
12288
|
|
|
12288
|
0
|
1391951
|
sub new_rgb { shift->new_from_luv(Convert::Color::LUV->new_rgb(@_)) } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
__END__ |