Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- }
- }
Add Comment
Please, Sign In to add comment