Home > Java, JavaFX > Growing Plant Animation in JavaFX

Growing Plant Animation in JavaFX

This is how I implemented plant visual effect:

Unfortunately current JavaFX(1.2) version doesn’t support converting a node to Buffered Image. Without this feature, not only it is difficult to make complex visual effects, it is difficult to develop an application like paint brush and photo editing software in JavaFX.

I took the following approach to show the plant grow effect,

1)      Create a CubicCurve object.

2)      Get all X,Y points on the cubic curve (CurvePath class http://forums.sun.com/thread.jspa?threadID=5363171 ).

3)      Start a Timeline, and link it to a function, so that everytime timeline changes this function (ex:-  addAPoint() ) is called.

4)      On each call of this addAPoint() method insert an extra LineTo object into the scene.content.

This will not give a smooth curve effect, as each time it is adding a line between two points, we can’t get an ant-aliasing smooth curve, to make it look smooth, I inserted all lines into group and applied the Gassien Blur effect on the group. This will blur the edges and give the smoothness.

If you need to increase growth speed, insert more lines on each function call.

You can download my complete netbeans source here (Note: There is lot of unnecessary logic in the source).

Categories: Java, JavaFX Tags:
  1. February 4th, 2010 at 00:00 | #1

    Thanks for highlighting this limitation in JavaFX 1.2. We will investigate this and make sure it is addressed in an upcoming version of JavaFX.

    The JavaFX product team

  1. No trackbacks yet.