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