Another JavaFX example: The editable label JavaDoc is dead, long live DocWeb?
May 28

Here’s a little something I didn’t know before taking a loop at Chris Oliver’s Heroes example: You can hook up to the dur keyword’s iteration of an array of values, by using the (undocument) primitive unitinterval and a “normal” for loop. Example from his code:


        for (unitinterval r in dur 500 fps 100) {
            bookY = 420 + (r * -200);
            bookOpacity = r;
            bookScale = (0.8 * r);
            bookRotation = -10 + (10 * r);
        }

The value for r is going to be between 0 and 1 - So you will almost always have to use it with multiplication of a real value.

I suppose that in that case, you can say that the code x = [1..100] dur 500 is actually:


var x;
var arr = [1..100];
for (unitinterval s in dur 500) {
    x = arr[s * sizeof arr];
}

Other posts of interest

One Response to “Hooking up to animations in JavaFX”

  1. 10 Minute Tutorial - JavaFX: Basic 2D Graphics and Animation at Die, AJAX! Says:

    […] Learn more about the dur operator here, here and here […]

Leave a Reply

Chaotic Java is Digg proof thanks to caching by WP Super Cache!