Tuesday, June 21, 2016

59. SepiaTone

The SepiaTone effect can be applied to a node, usually an image. Here we chained an ImageInput with the SepiaTone effect.


The SepiaTone effect is used to create image looking older and more monochrome.


package ex59;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.ImageInput;
import javafx.scene.effect.SepiaTone;
import javafx.scene.image.Image;
import javafx.stage.Stage;

public class Ex59 extends Application {

    @Override
    public void start(Stage stage) {
        Group root = new Group();
        
        String hillary = "Hillary";
        String clinton = "Clinton";

        SepiaTone sepiaTone = new SepiaTone();
        sepiaTone.setLevel(.5);
        
        String fileName = hillary + clinton + ".png";

        Image image = new Image(fileName);
        ImageInput imageInput = new ImageInput(image);
        sepiaTone.setInput(imageInput);
        root.setEffect(sepiaTone);
 
        Scene scene = new Scene(root);
        stage.setTitle("Example 59. SepiaTone");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }
}

This is the output:


No comments:

Post a Comment