Example usage for javafx.scene.paint CycleMethod REFLECT

List of usage examples for javafx.scene.paint CycleMethod REFLECT

Introduction

In this page you can find the example usage for javafx.scene.paint CycleMethod REFLECT.

Prototype

CycleMethod REFLECT

To view the source code for javafx.scene.paint CycleMethod REFLECT.

Click Source Link

Document

Defines the cycle method that reflects the gradient colors start-to-end, end-to-start to fill the remaining area.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);//from  w w  w  .  j  a v  a  2s  . c  om
    // A rectangle filled with a linear gradient with a translucent color.
    Rectangle rectangle = new Rectangle();
    rectangle.setX(50);
    rectangle.setY(50);
    rectangle.setWidth(100);
    rectangle.setHeight(70);

    LinearGradient cycleGrad = new LinearGradient(50, // start X
            50, // start Y
            70, // end X
            70, // end Y
            false, // proportional
            CycleMethod.REFLECT, // cycleMethod
            new Stop(0f, Color.rgb(21, 25, 0, .784)), new Stop(1.0f, Color.rgb(0, 210, 0, .784)));
    rectangle.setFill(cycleGrad);

    box.getChildren().add(rectangle);

    stage.setScene(scene);
    stage.show();
}