-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFadeTransitionDemo.java
executable file
·59 lines (50 loc) · 1.99 KB
/
FadeTransitionDemo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.Random;
import javafx.animation.FadeTransition;
import javafx.animation.Interpolator;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.BoxBlur;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javafx.util.Duration;
/**
* フェードのデモ
*
* 円がフェードイン、フェードアウトを繰り返すアニメーション
*/
public class FadeTransitionDemo extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("Fade Transtion Demo");
Group container = new Group();
Scene scene = new Scene(container, 400, 400);
Random random = new Random();
for (int i = 0; i < 50; i++) {
Circle circle = new Circle(random.nextInt(400),
random.nextInt(400),
random.nextInt(100));
circle.setFill(new Color(random.nextDouble()*0.5+0.5,
random.nextDouble()*0.5+0.5,
random.nextDouble()*0.5+0.5,
random.nextDouble()*0.8));
circle.setEffect(new BoxBlur(10, 10, 1));
container.getChildren().add(circle);
FadeTransition transition
= new FadeTransition(new Duration(random.nextInt(4000)+1000),
circle);
transition.setAutoReverse(true);
transition.setCycleCount(FadeTransition.INDEFINITE);
transition.setInterpolator(Interpolator.EASE_BOTH);
transition.setFromValue(1.0);
transition.setToValue(0.0);
transition.play();
}
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
Application.launch(null);
}
}