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