Vanishing Circles Demo / Threading Fixes

19 views
Skip to first unread message

Stephen Chin

unread,
Dec 30, 2011, 7:07:33 AM12/30/11
to visag...@googlegroups.com
I finally got around to doing some much needed fixes in the core
VisageFX code. There were threading issues with the main application
loading and also with animations that got fired, which would eventually
freeze your application. Now all of the code in the main script file is
executed on the JavaFX event dispatch thread, and all the animation
logic is executed on the animation thread (and is fully backed by the
JavaFX animation libraries). At the same time I finished implementing
the rest of the interpolators, so the animation support is feature
complete now.

With a few other fixes I was able to get the VanishingCircles demo, that
I am using in the Pro JavaFX book update, working. The code is pretty
short [1/4 the character count of the Java version], but it does a lot:
var circles:Circle[];
Stage {
title: "Vanishing Circles"
Scene {
width: 800
height: 600
fill: BLACK
Group {
circles = for (i in [1..50]) {
def c:Circle = Circle {
centerX: random() * 800
centerY: random() * 600
radius: 150
fill: color(random(), random(), random(), .2)
effect: BoxBlur {
height: 10
width: 10
iterations: 3
}
stroke: WHITE
strokeWidth: bind if (c.hover) 5 else 0
onMouseClicked: function(e) {
Timeline {at (3s) {c.radius => 0}}.play()
}
}
}
}
}
}

Timeline {
for (circle in circles) at (40s) {
circle.centerX => random() * 800;
circle.centerY => random() * 600
}
}.play()

Give it a try and let me know what you think.

P.S.: On a side note, I have started down the dark path of implementing
object literal and binding support directly against JavaFX 2.0
libraries. It has turned out to be a challenging implementation, but if
I can get this done it will mean you can code directly against the
JavaFX 2.0 Java APIs without a wrapper layer in the middle (better
performance, solves the bind listener problem, no need to update our
APIs each version, etc.)

Cheers,
--
--Steve
blog: http://steveonjava.com/

Reply all
Reply to author
Forward
0 new messages