zoukankan      html  css  js  c++  java
  • Using JAVAFX To build a ugly ball

    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    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 Main extends Application {
        static int dx = 1;
        static int dy = 1;
    
        public static void main(String[] args) {
            Application.launch(args);
        }
    
        @Override
        public void start(final Stage primaryStage) {
            primaryStage.setTitle("Animation");
            Group root = new Group();
            Scene scene = new Scene(root, 400, 300, Color.WHITE);
    
            primaryStage.setScene(scene);
            addBouncyBall(scene); 
            primaryStage.show();
        }
        private void addBouncyBall(final Scene scene) {
            final Circle ball = new Circle(100, 100, 20);
    
            RadialGradient gradient1 = new RadialGradient(0,
                .1,
                100,
                100,
                20,
                false,
                CycleMethod.NO_CYCLE,
                new Stop(0, Color.YELLOW),
                new Stop(1, Color.BLACK));
    
            ball.setFill(gradient1);
    
        
            final Group root = (Group) scene.getRoot();
            root.getChildren().add(ball);
    
        }
    }
    
    

    this ball is so ugly, maybe you can change the color's position not putting in the middle.

  • 相关阅读:
    MySQL循环插入语法
    查看linux机子的配置
    extends与implements的不区别
    Git基本命令
    VirtualBox配置 以及文件传输
    zookeeper应用场景
    oracle学习
    linux学习
    Mysql优化
    线程3
  • 原文地址:https://www.cnblogs.com/RabbitHole/p/3424717.html
Copyright © 2011-2022 走看看