Home > javafx > JavaFX – Glow Effect

JavaFX – Glow Effect


This sample is just to demonstrate how easy it is to add an effect to a Node.
First we initialize the Glow effect as shown below. The level attribute is bound to glowLevel variable so as to change the glow value at runtime.


var glowLevel = 0.0;
var glow = Glow {
    level: bind glowLevel
}

Now we will instantiate an ImageView and load the Image as shown below.


var imageView = ImageView {
    image: Image {
        url: "{__DIR__}images/light.jpg"
    }
    effect: bind glow
}

Create a Timeline which will run 5 times with auto-reverse. This Timeline is used for updating the value of glowLevel.


var timeline = Timeline {
    repeatCount: 15
    autoReverse: true
    keyFrames: [
        KeyFrame {
            time: 0s
            values: glowLevel => 0.0 ]
        },
        KeyFrame {
            time: 3s
            values: glowLevel => 0.85 ]
        }
    ]
}
timeline.play();

Click on above image for Applet mode.


The glow effect is added to the candles! Simple?!

Source

var dzone_url = “http://blogs.sun.com/rakeshmenonp/entry/javafx_glow_effect”;
var dzone_style = ‘2’;

Advertisements
Categories: javafx Tags: ,
  1. santhosh
    March 13, 2009 at 3:22 AM

    not getting any glow effect

  2. Rakesh Menon
    March 13, 2009 at 4:03 AM

    @santhosh i updated the sample with a better image, hope now its bit more obvious

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: