Cutting out with the SRC_ATOP blend mode

This blend mode draws only part of the top input lying inside the node it's applied to. By using this, you can get nice clipping effect:

Here, we used the same cosmonaut image as a fill for the "JavaFX" text:

// chapter8/combining/BlendSrcDemo.javapublic void start(Stage primaryStage) {    Image image = new Image(        "https://github.com/sgrinev/mastering-javafx-9-book/blob/master/resources/sample.jpg?raw=true",         300, 300, true, true);    ImageInput ii = new ImageInput(image, 0, 0);    Blend blend = new Blend();    blend.setMode(BlendMode.SRC_ATOP);    blend.setTopInput(ii);    Text text = new Text(0, 80, "JavaFX"); text.setFont(Font.font("Verdana", ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.