Created
June 20, 2018 16:19
-
-
Save hudsonb/50a62e4b9b4ae727533172c46174dde7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.layout.Pane; | |
import javafx.scene.paint.Color; | |
import javafx.scene.paint.CycleMethod; | |
import javafx.scene.paint.RadialGradient; | |
import javafx.scene.paint.Stop; | |
import javafx.scene.shape.Circle; | |
import javafx.stage.Stage; | |
public class MaskTest extends Application { | |
public static void main(String[] args) { | |
Application.launch(args); | |
} | |
public void start(Stage stage) { | |
Pane layout = new Pane(); | |
Circle red = new Circle(); | |
red.setCenterX(200); | |
red.setCenterY(200); | |
red.setRadius(50); | |
red.setFill(Color.RED); | |
layout.getChildren().addAll(red); | |
Circle mask = new Circle(); | |
mask.setCenterX(200); | |
mask.setCenterY(200); | |
mask.setRadius(50); | |
mask.setFill(new RadialGradient(0, .1, 200, 200, 20, false, CycleMethod.NO_CYCLE, new Stop(0, Color.BLACK), new Stop(1, Color.TRANSPARENT))); | |
red.setClip(mask); | |
Scene scene = new Scene(layout); | |
stage.setScene(scene); | |
stage.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment