数学之美(二)Java实现绚烂绽放

25 篇文章 1 订阅
2 篇文章 1 订阅

一部Java编写的震撼特效合集

由于CSDN只能通过腾讯视频上传视频,所以附上下方链接,具体源代码目前没时间上传,等有时间另说,敬请期待,视频读者自取:

截取到的图片展示

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

核心代码在此

    Timeline timeline;
    public void show(Stage primaryStage){
    	timeline = new Timeline();
        Label label=new Label("csdn关注:四原色");//
        label.setVisible(true);

		//使用CSS设置控件的样式
        label.setStyle("-fx-text-fill: white; -fx-effect: dropshadow( three-pass-box ,#40E0D0 , 40, 0.5 , 0 , 0 );-fx-font-size:30px;");
        //
        label.setLayoutX(0);
        label.setLayoutY(0);
        
        Group root = new Group();
        Scene scene = new Scene(root, 0, 0, Color.BLACK);
        primaryStage.setScene(scene);
        Group circles = new Group();
        for (int i = 0; i <4900; i++) {
            Circle circle = new Circle(100, Color.web("#00f2fe", 0.001));
            circle.setStrokeType(StrokeType.OUTSIDE);
            circle.setStroke(Color.web("#EEE8AA", 0.5));
            circle.setStrokeWidth(2);
            circles.getChildren().add(circle);
        }
        Rectangle colors = new Rectangle(scene.getWidth(), scene.getHeight(),
                new LinearGradient(1f, 0f, 0f, 1f, true, CycleMethod.NO_CYCLE,
                        new Stop(0, Color.web("#84fab0")),
                        new Stop(0.14, Color.web("#fa709a")),
                        new Stop(0.28, Color.web("#4169E1")),
                        new Stop(0.43, Color.web("#64c2f8")),
                        new Stop(0.57, Color.web("#9400D3")),
                        new Stop(0.71, Color.web("#ed5fc2")),
                        new Stop(0.85, Color.web("#00CED1")),
                        new Stop(1, Color.web("#2E8B57"))));
        colors.widthProperty().bind(scene.widthProperty());
        colors.heightProperty().bind(scene.heightProperty());
        Group blendModeGroup = new Group(new Group(new Rectangle(
                scene.getWidth(), scene.getHeight(), Color.BLACK), circles),
                colors);
        colors.setBlendMode(BlendMode.OVERLAY);
        root.getChildren().add(blendModeGroup);
        root.getChildren().add(label);
        circles.setEffect(new BoxBlur(10, 20, 10));
        int i=0;
        for (Node circle : circles.getChildren()) {
            
            //以下三个变量非常重要
            double  X=(960)+(2430-i)*Math.sin(i*Math.PI*2/100);
           //960表示我电脑屏幕的中心的横坐标,因为我的电脑是1920*1080的分辨率,同样下面的540也是这个道理

			double Y=(540)-(2430-i)*Math.cos((i)*Math.PI*2/100);
           //(X,Y)表示当前节点需要运动到达的位置
           
 			int times=(int)(5000+1000*Math.sin((i++)*Math.PI*3/200));
            //这个变量相当于个一个循环节点设置一个循环的时间差
            
            timeline.getKeyFrames().addAll(
                    new KeyFrame(
                           Duration.ZERO,
                            new KeyValue(circle.translateXProperty(), 960),
                            new KeyValue(circle.translateYProperty(), 540)
                    )//设置此节点起始位置,即我的屏幕正中间(960,540)
                    , new KeyFrame(
                            new Duration(times),//这里设置运动时间
                            new KeyValue(circle.translateXProperty(),X),
                            new KeyValue(circle.translateYProperty(),Y)
                    )//设置此节点终点位置(X,Y)
                    ,new KeyFrame(
                            new Duration(8000),
                            new KeyValue(circle.translateXProperty(),960),
                            new KeyValue(circle.translateYProperty(),540)
                    )//让此节点回到中心位置(960,540)
            );
        }
        timeline.setCycleCount(100000);//播放次数100000
        timeline.play();
        primaryStage.show();
    }

重点:视频地址在此

😐 JAVA视频特效合集,点击这里 😐

  • 7
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值