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