Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Adding a BlendMode to a Clipped Node in JavaFX


Is there a way to add a Blendmode (or Blend effect) to a Node that has been clipped? It seems that if I try to add a clip to a Node with a BlendMode already set, the BlendMode is overridden by the clip and no longer works properly. Some example code to reproduce the problem:

package miatool.display.fx.demo;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.effect.BlendMode;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

public class BlendModeClipProblem extends Application {
public Rectangle blueRect = new Rectangle(0, 0, 30, 30);
public Rectangle redRect = new Rectangle(15, 15, 30, 30);

public void start(final Stage stage)
throws Exception {
final Pane pane = new Pane();
final Scene scene = new Scene(pane);



// Comment this next line to see blending
redRect.setClip(new Rectangle(15, 15, 20, 20));


Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered

This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Adding a BlendMode to a Clipped Node in JavaFX


Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription