Just a place to put together some thoughts on Java, Technology and Other Stuff (tm) that interests me.

Monday, June 11, 2007

JavaFX morph example code

Here is a quick JavaFX program? script? that demonstrates the morph animation ability in the latest version of JavaFX (I snagged a version from June 1st). In any case here is the code:

/*
* This file is created with Netbeans 6 Plug-In for JavaFX
*/
import javafx.ui.*;
import javafx.ui.canvas.*;
import javafx.ui.filter.*;

var win = Frame {
width: 600
height: 400
content: Canvas {
content:
Morph {

morph: bind [0,.01..1] dur 2500

fill: blue

start: Rect {
x: 10
y: 10
width: 460
height: 140
}

end: Circle {cx: 200, cy: 200, radius: 100}
}

}
visible: true
};

This code should draw a blue-filled rectangle and then morph it into a blue circle taking 2.5 seconds to do it. Pretty simple and slick, although a rather trivial effect.