JavaFX – BlendMode Effect


Just thought of demonstrating use of JavaFX BlendMode effect API to combine and render multiple nodes. Since this requires blending of multiple nodes, we apply this effect to Group by specifying its blendMode attribute.

For Applet mode, click on right image above.

For standalone mode

Here we create two ImageView and add it to group. The blendMode attribute is bound to one of element of an array of blend modes available in JavaFX. This is done so that we can just change the index to switch to another blend mode.


var blendGroup = Group {
    
    // Specify BlendMode
    blendMode: bind blendMode[index]
    
    content: [
        ImageView {
            image: Image {
                url: "{__DIR__}images/sky.jpg"
            }
        },
        ImageView {
            image: Image {
                url: "{__DIR__}images/baloon.jpg"
            }
        },
    ]
    
    translateX: 5
    translateY: 5
};

Source

Advertisements

About Rakesh Menon
-

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