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