Java Reference
In-Depth Information
To demonstrate this, we will go through an Elastic Interpolator based on the elas-
tic interpolator defined in the The Yahoo! User Interface Library (YUI) ( http://
developer.yahoo.com/yui/docs/Easing.js.html). The main difference between the
two implementations is that the Yahoo JavaScript version translates directly to
the actual values based on the elapsed time, whereas the JavaFX version deals
with the percentage of elapsed time, and therefore returns a percentage change
for the target value.
The actual implementation is shown in Listing 7.3.
Listing 7.3
Elastic Interpolator
package animation;
import javafx.animation.SimpleInterpolator ;
import java.lang.Math;
// Elastic period is at start of animation
public def IN = 0;
// Elastic period is at end of animation
public def OUT = 1;
// Elastic period is at start and end of animation
public def BOTH = 3;
public class Elastic extends SimpleInterpolator {
public-init var type = BOTH;
public-init var amplitude = 1.0;
public-init var period = if(type == BOTH)
{0.3*1.5} else { 0.3}
on replace {
if(amplitude < Math.abs(period)) {
amplitude = period;
s = period/4.0;
}
};
var s: Number;
init {
if(s == 0.0) {
s = period/(2*Math.PI) *
Math.asin (1.0/amplitude);
}
}
 
Search WWH ::




Custom Search