line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convert::Color::LCh; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
26
|
use 5.008009; |
|
2
|
|
|
|
|
4
|
|
4
|
2
|
|
|
2
|
|
18
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
32
|
|
5
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
67
|
|
6
|
2
|
|
|
2
|
|
6
|
use parent qw/Convert::Color/; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
98
|
use Convert::Color::LUV; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
32
|
|
11
|
2
|
|
|
2
|
|
995
|
use Math::Trig ':pi'; |
|
2
|
|
|
|
|
17629
|
|
|
2
|
|
|
|
|
719
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->register_color_space('lch'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
3585
|
|
|
3585
|
1
|
3338
|
my ($class, $l, $c, $h) = @_; |
17
|
3585
|
100
|
|
|
|
4962
|
($l, $c, $h) = split /,/s, $l unless defined $c; |
18
|
3585
|
|
|
|
|
9880
|
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
|
4
|
sub h { shift->[2] } |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
1
|
1
|
sub lch { @{$_[0]} } |
|
1
|
|
|
|
|
6
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub convert_to_luv { |
28
|
1024
|
|
|
1024
|
0
|
768
|
my ($self) = @_; |
29
|
1024
|
|
|
|
|
895
|
my ($l, $c, $h) = @$self; |
30
|
1024
|
|
|
|
|
787
|
my $hrad = $h / 180 * pi; |
31
|
1024
|
|
|
|
|
961
|
my $u = $c * cos $hrad; |
32
|
1024
|
|
|
|
|
879
|
my $v = $c * sin $hrad; |
33
|
1024
|
|
|
|
|
1825
|
Convert::Color::LUV->new($l, $u, $v) |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new_from_luv { |
37
|
2560
|
|
|
2560
|
0
|
2150
|
my ($class, $luv) = @_; |
38
|
2560
|
|
|
|
|
2142
|
my ($l, $u, $v) = @$luv; |
39
|
2560
|
|
|
|
|
2356
|
my $c = sqrt $u * $u + $v * $v; |
40
|
2560
|
100
|
|
|
|
4149
|
return $class->new($l, $c, 0) if $c < 0.00000001; |
41
|
2520
|
|
|
|
|
3593
|
my $hrad = atan2 $v, $u; |
42
|
2520
|
|
|
|
|
2515
|
my $h = $hrad * 180 / pi; |
43
|
2520
|
100
|
|
|
|
3292
|
$h += 360 if $h < 0; |
44
|
2520
|
|
|
|
|
3233
|
$class->new($l, $c, $h) |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
1024
|
|
|
1024
|
1
|
1240
|
sub rgb { shift->convert_to_luv->rgb } |
48
|
2560
|
|
|
2560
|
0
|
145225
|
sub new_rgb { shift->new_from_luv(Convert::Color::LUV->new_rgb(@_)) } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
__END__ |