line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convert::Color::LCh; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
25
|
use 5.008009; |
|
2
|
|
|
|
|
2
|
|
4
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
44
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
68
|
|
6
|
2
|
|
|
2
|
|
7
|
use parent qw/Convert::Color/; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000001'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
109
|
use Convert::Color::LUV; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
38
|
|
11
|
2
|
|
|
2
|
|
876
|
use Math::Trig ':pi'; |
|
2
|
|
|
|
|
18737
|
|
|
2
|
|
|
|
|
770
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->register_color_space('lch'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
3585
|
|
|
3585
|
1
|
4225
|
my ($class, $l, $c, $h) = @_; |
17
|
3585
|
100
|
|
|
|
4597
|
($l, $c, $h) = split /,/s, $l unless defined $c; |
18
|
3585
|
|
|
|
|
14098
|
bless [$l, $c, $h], $class |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
1
|
7
|
sub L { shift->[0] } |
22
|
1
|
|
|
1
|
1
|
4
|
sub C { shift->[1] } |
23
|
1
|
|
|
1
|
1
|
3
|
sub h { shift->[2] } |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
1
|
1
|
sub lch { @{$_[0]} } |
|
1
|
|
|
|
|
7
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub convert_to_luv { |
28
|
1024
|
|
|
1024
|
0
|
873
|
my ($self) = @_; |
29
|
1024
|
|
|
|
|
826
|
my ($l, $c, $h) = @$self; |
30
|
1024
|
|
|
|
|
795
|
my $hrad = $h / 180 * pi; |
31
|
1024
|
|
|
|
|
1180
|
my $u = $c * cos $hrad; |
32
|
1024
|
|
|
|
|
902
|
my $v = $c * sin $hrad; |
33
|
1024
|
|
|
|
|
1822
|
Convert::Color::LUV->new($l, $u, $v) |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new_from_luv { |
37
|
2560
|
|
|
2560
|
0
|
1982
|
my ($class, $luv) = @_; |
38
|
2560
|
|
|
|
|
2205
|
my ($l, $u, $v) = @$luv; |
39
|
2560
|
|
|
|
|
2589
|
my $c = sqrt $u * $u + $v * $v; |
40
|
2560
|
100
|
|
|
|
3898
|
return $class->new($l, $c, 0) if $c < 0.00000001; |
41
|
2520
|
|
|
|
|
3734
|
my $hrad = atan2 $v, $u; |
42
|
2520
|
|
|
|
|
2349
|
my $h = $hrad * 180 / pi; |
43
|
2520
|
100
|
|
|
|
3467
|
$h += 360 if $h < 0; |
44
|
2520
|
|
|
|
|
3410
|
$class->new($l, $c, $h) |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
1024
|
|
|
1024
|
1
|
1244
|
sub rgb { shift->convert_to_luv->rgb } |
48
|
2560
|
|
|
2560
|
0
|
120142
|
sub new_rgb { shift->new_from_luv(Convert::Color::LUV->new_rgb(@_)) } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
__END__ |