一部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視頻特效合集,點擊這里 😐
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/240136.html
標籤:其他
下一篇:同步方法以及同步塊
