Example usage for javafx.scene.effect BlendMode DARKEN

List of usage examples for javafx.scene.effect BlendMode DARKEN

Introduction

In this page you can find the example usage for javafx.scene.effect BlendMode DARKEN.

Prototype

BlendMode DARKEN

To view the source code for javafx.scene.effect BlendMode DARKEN.

Click Source Link

Document

The darker of the color components from the two inputs are selected to produce the resulting color.

Usage

From source file:com.github.vatbub.tictactoe.view.Main.java

private void addWinLineOnWin(Board.WinnerInfo winnerInfo, Paint color, Runnable onFinished) {
    Line originLine = new Line(0, 0, 0, 0);
    winLineGroup.getChildren().add(originLine);

    WinLine winLine = new WinLine(winnerInfo);
    double winLineEndX = winLine.endArc.getCenterX();
    double winLineEndY = winLine.endArc.getCenterY();
    winLine.startArc.setFill(color);//  w ww  . j  a  v a  2s  . co m
    winLine.startArc.setStrokeWidth(0);
    winLine.endArc.setFill(color);
    winLine.endArc.setStrokeWidth(0);
    winLine.rightLine.setStrokeWidth(0);
    winLine.leftLine.setStrokeWidth(0);
    winLine.centerLine.setStroke(color);

    winLine.centerLine.strokeWidthProperty().bind(winLine.startArc.radiusXProperty().multiply(2));
    winLineGroup.getChildren().addAll(winLine.getAll());

    blurNode(gamePane, 4);

    winLineGroup.setOpacity(0);
    GaussianBlur blur = new GaussianBlur(100);
    winLineGroup.setEffect(blur);
    winLineGroup.setBlendMode(BlendMode.DARKEN);
    winLineGroup.setVisible(true);

    double winLineAnimationX1 = 0.2;
    double winLineAnimationX2 = 0.5;

    KeyValue stretchKeyValue1x = new KeyValue(winLine.endArc.centerXProperty(), winLine.startArc.getCenterX());
    KeyValue stretchKeyValue1y = new KeyValue(winLine.endArc.centerYProperty(), winLine.startArc.getCenterY());
    KeyFrame stretchKeyFrame1 = new KeyFrame(Duration.millis(0), stretchKeyValue1x, stretchKeyValue1y);

    KeyValue stretchKeyValue2x = new KeyValue(winLine.endArc.centerXProperty(), winLine.startArc.getCenterX(),
            new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2));
    KeyValue stretchKeyValue2y = new KeyValue(winLine.endArc.centerYProperty(), winLine.startArc.getCenterY(),
            new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2));
    KeyFrame stretchKeyFrame2 = new KeyFrame(Duration.millis(100), stretchKeyValue2x, stretchKeyValue2y);

    KeyValue stretchKeyValue3x = new KeyValue(winLine.endArc.centerXProperty(), winLineEndX,
            new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2));
    KeyValue stretchKeyValue3y = new KeyValue(winLine.endArc.centerYProperty(), winLineEndY,
            new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2));
    KeyFrame stretchKeyFrame3 = new KeyFrame(Duration.millis(800), stretchKeyValue3x, stretchKeyValue3y);

    KeyValue opacityKeyValue1 = new KeyValue(winLineGroup.opacityProperty(), 0.8);
    KeyFrame opacityKeyFrame1 = new KeyFrame(Duration.millis(400), opacityKeyValue1);

    Timeline timeline = new Timeline();
    timeline.getKeyFrames().addAll(stretchKeyFrame1, stretchKeyFrame2, stretchKeyFrame3, opacityKeyFrame1);
    timeline.play();

    timeline.setOnFinished((event) -> onFinished.run());
}