| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::wmiirc::Role::Fade; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$App::wmiirc::Role::Fade::VERSION = '1.000'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
1
|
|
|
1
|
|
48141
|
use Moo::Role; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
14
|
|
|
6
|
1
|
|
|
1
|
|
4946
|
use Color::Model::RGB qw(rgb blend_alpha); |
|
|
1
|
|
|
|
|
77359
|
|
|
|
1
|
|
|
|
|
4272
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has fade_start_color => ( |
|
9
|
|
|
|
|
|
|
is => 'rw', |
|
10
|
|
|
|
|
|
|
coerce => sub { |
|
11
|
|
|
|
|
|
|
_rgb_tuple(shift) |
|
12
|
|
|
|
|
|
|
}, |
|
13
|
|
|
|
|
|
|
default => sub { |
|
14
|
|
|
|
|
|
|
my($self) = @_; |
|
15
|
|
|
|
|
|
|
$self->core->main_config->{alertcolors}; |
|
16
|
|
|
|
|
|
|
}, |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has fade_end_color => ( |
|
20
|
|
|
|
|
|
|
is => 'rw', |
|
21
|
|
|
|
|
|
|
coerce => sub { |
|
22
|
|
|
|
|
|
|
_rgb_tuple(shift) |
|
23
|
|
|
|
|
|
|
}, |
|
24
|
|
|
|
|
|
|
default => sub { |
|
25
|
|
|
|
|
|
|
my($self) = @_; |
|
26
|
|
|
|
|
|
|
$self->core->main_config->{normcolors}; |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has fade_count => ( |
|
31
|
|
|
|
|
|
|
is => 'ro', |
|
32
|
|
|
|
|
|
|
default => sub { 50 }, |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has _fade_pos => ( |
|
36
|
|
|
|
|
|
|
is => 'rw', |
|
37
|
|
|
|
|
|
|
default => sub { 0 }, |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub fade_current_color { |
|
41
|
2
|
|
|
2
|
0
|
122
|
my($self) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
2
|
100
|
|
|
|
40
|
return $self->_fade_pos == ($self->fade_count - 1) |
|
44
|
|
|
|
|
|
|
? _rgb_tuple_fmt($self->fade_end_color) |
|
45
|
|
|
|
|
|
|
: _blend_alpha_tuple($self->fade_start_color, |
|
46
|
|
|
|
|
|
|
1-($self->_fade_pos/$self->fade_count), |
|
47
|
|
|
|
|
|
|
$self->fade_end_color, |
|
48
|
|
|
|
|
|
|
$self->_fade_pos/$self->fade_count); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Go on to the next position, return true if there are more iterations left. |
|
52
|
|
|
|
|
|
|
sub fade_next { |
|
53
|
50
|
|
|
50
|
0
|
22874
|
my($self) = @_; |
|
54
|
50
|
100
|
|
|
|
125
|
if($self->_fade_pos == $self->fade_count - 1) { |
|
55
|
1
|
|
|
|
|
4
|
return 0; |
|
56
|
|
|
|
|
|
|
} else { |
|
57
|
49
|
|
|
|
|
84
|
$self->_fade_pos($self->_fade_pos + 1); |
|
58
|
49
|
|
|
|
|
85
|
return 1; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub fade_set { |
|
63
|
0
|
|
|
0
|
0
|
0
|
my($self, $pos) = @_; |
|
64
|
0
|
|
|
|
|
0
|
$self->_fade_pos($pos); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Utility functions to handle tuples via Color::Model::RGB's API. |
|
68
|
|
|
|
|
|
|
sub _rgb_tuple { |
|
69
|
2
|
|
|
2
|
|
16
|
[map rgb($_), split / /, shift] |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _rgb_tuple_fmt { |
|
73
|
1
|
|
|
1
|
|
62
|
my($tuple) = @_; |
|
74
|
1
|
|
|
|
|
12
|
join " ", map "#" . $_, @$tuple; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _blend_alpha_tuple { |
|
78
|
1
|
|
|
1
|
|
1286
|
my($from, $from_a, $to, $to_a) = @_; |
|
79
|
1
|
|
|
|
|
4
|
my $i = 0; |
|
80
|
1
|
|
|
|
|
8
|
join " ", map "#" . blend_alpha($_, $from_a, $to->[$i++], $to_a), @$from |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |