line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Algorithm::Easing::Exponential; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
374
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
3924
|
use Math::Trig qw(:pi); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
102
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use constant EPSILON => 0.000001; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
extends 'Algorithm::Easing::Ease'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use namespace::clean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub ease_in { |
14
|
402
|
|
|
402
|
1
|
298
|
my $self = shift; |
15
|
402
|
|
|
|
|
425
|
my ($t,$b,$c,$d) = (shift,shift,shift,shift); |
16
|
|
|
|
|
|
|
|
17
|
402
|
100
|
|
|
|
558
|
return $b if ($t < EPSILON); |
18
|
401
|
50
|
|
|
|
451
|
return $c if ($d < EPSILON); |
19
|
|
|
|
|
|
|
|
20
|
401
|
50
|
|
|
|
1243
|
return ($t==0) ? $b : $c * $self->pow(2, 10 * ($t / $d - 1)) + $b; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub ease_out { |
24
|
402
|
|
|
402
|
1
|
314
|
my $self = shift; |
25
|
402
|
|
|
|
|
392
|
my ($t,$b,$c,$d) = (shift,shift,shift,shift); |
26
|
|
|
|
|
|
|
|
27
|
402
|
100
|
|
|
|
486
|
return $b if ($t < EPSILON); |
28
|
401
|
50
|
|
|
|
435
|
return $c if ($d < EPSILON); |
29
|
|
|
|
|
|
|
|
30
|
401
|
50
|
|
|
|
939
|
return ($t == $d) ? $b + $c : $c * (-$self->pow(2, -10 * $t / $d) + 1) + $b; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub ease_both { |
34
|
402
|
|
|
402
|
1
|
300
|
my $self = shift; |
35
|
402
|
|
|
|
|
398
|
my ($t,$b,$c,$d) = (shift,shift,shift,shift); |
36
|
|
|
|
|
|
|
|
37
|
402
|
100
|
|
|
|
549
|
return $b if ($t < EPSILON); |
38
|
401
|
50
|
|
|
|
434
|
return $c if ($d < EPSILON); |
39
|
|
|
|
|
|
|
|
40
|
401
|
50
|
|
|
|
491
|
if ($t == 0) { |
41
|
0
|
|
|
|
|
0
|
return $b; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
401
|
50
|
|
|
|
454
|
if ($t == $d) { |
45
|
0
|
|
|
|
|
0
|
return $b + $c; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
401
|
100
|
|
|
|
569
|
if (($t /= $d / 2) < 1) { |
49
|
199
|
|
|
|
|
500
|
return $c / 2 * $self->pow(2, 10 * ($t - 1)) + $b; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
202
|
|
|
|
|
491
|
return $c / 2 * (-$self->pow(2, -10 * --$t) + 2) + $b; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# MAN3 POD |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Algorithm::Easing::Exponential - Calculate eased translations between two positive whole integer values over time |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SYNOPSIS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use Algorithm::Easing; |
70
|
|
|
|
|
|
|
use Algorithm::Easing::Exponential; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# this example produces traditional 'exponential' output; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $translation = Algorithm::Easing::Exponential->new; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# total time for eased translation as a real positive integer value |
77
|
|
|
|
|
|
|
my $d = 2.5; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# begin |
80
|
|
|
|
|
|
|
my $b = 0; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# change |
83
|
|
|
|
|
|
|
my $c = 240; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# time passed in seconds as a real positive integer between each frame |
86
|
|
|
|
|
|
|
my $frame_time = 0.0625; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my @p = [319,0]; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
for(my $t = 0; $t < 2.5; $t += 0.0625) { |
91
|
|
|
|
|
|
|
$p[1] = $translation->ease_out($t,$b,$c,$d) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# plot |
94
|
|
|
|
|
|
|
...; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 METHODS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 ease_none |
104
|
|
|
|
|
|
|
usage : |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Parameters : |
107
|
|
|
|
|
|
|
Let t be time, |
108
|
|
|
|
|
|
|
Let b be begin, |
109
|
|
|
|
|
|
|
Let c be change, |
110
|
|
|
|
|
|
|
Let d be duration, |
111
|
|
|
|
|
|
|
Results : |
112
|
|
|
|
|
|
|
Let p be position, |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $p = $obj->ease_none($t,$b,$c,$d); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This method is used for a linear translation between two positive real whole integers using a positive real integer as the parameter for time. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 ease_in |
121
|
|
|
|
|
|
|
usage : |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Parameters : |
124
|
|
|
|
|
|
|
Let t be time, |
125
|
|
|
|
|
|
|
Let b be begin, |
126
|
|
|
|
|
|
|
Let c be change, |
127
|
|
|
|
|
|
|
Let d be duration, |
128
|
|
|
|
|
|
|
Results : |
129
|
|
|
|
|
|
|
Let p be position, |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $p = $obj->ease_in($t,$b,$c,$d); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This method is used to ease in between two positive real whole integers as an inward tween using a positive real integer as the parameter for time in an exponential fashion. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 ease_out |
138
|
|
|
|
|
|
|
usage : |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Parameters : |
141
|
|
|
|
|
|
|
Let t be time, |
142
|
|
|
|
|
|
|
Let b be begin, |
143
|
|
|
|
|
|
|
Let c be change, |
144
|
|
|
|
|
|
|
Let d be duration, |
145
|
|
|
|
|
|
|
Results : |
146
|
|
|
|
|
|
|
Let p be position, |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my $p = $obj->ease_out($t,$b,$c,$d); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This method is used to ease in between two positive real whole integers as an inward tween using a positive real integer as the parameter for time in exponential fashion. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 ease_both |
155
|
|
|
|
|
|
|
usage : |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Parameters : |
158
|
|
|
|
|
|
|
Let t be time, |
159
|
|
|
|
|
|
|
Let b be begin, |
160
|
|
|
|
|
|
|
Let c be change, |
161
|
|
|
|
|
|
|
Let d be duration, |
162
|
|
|
|
|
|
|
Results : |
163
|
|
|
|
|
|
|
Let p be position, |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
my $p = $obj->ease_both($t,$b,$c,$d); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This method is used to ease both in then out between two positive real whole integers as an inward tween using a positive real integer as the parameter for time in exponential fashion. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Jason McVeigh, <jmcveigh@outlook.com> |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Copyright 2016 by Jason McVeigh |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
182
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |