[英]How can I change the points colors of a ScatterChart using javafx inside java code?
[英]JavaFX: How can I change the points of a polygon in an animation?
我知道您可以在這樣的動畫中更改圓圈的位置(另請參見此處 ):
timeline.getKeyFrames().addAll(
new KeyFrame(Duration.ZERO, // set start position at 0
new KeyValue(circle.translateXProperty(), random() * 800),
new KeyValue(circle.translateYProperty(), random() * 600)
),
new KeyFrame(new Duration(40000), // set end position at 40s
new KeyValue(circle.translateXProperty(), random() * 800),
new KeyValue(circle.translateYProperty(), random() * 600)
)
);
但是還有可能(這意味着一個Property
)來改變動畫中多邊形的點嗎?
如果沒有:我還有哪些其他可能性來使用JavaFX在動畫中變形多邊形?
有一個點的任何個人性質Polygon
,但你可以我們一個Path
的LineTo
S, MoveTo
和ClosePath
單獨動畫多邊形的坐標。
例:
Pane pane = new Pane();
pane.setPrefSize(400, 400);
MoveTo corner1 = new MoveTo();
LineTo corner2 = new LineTo();
LineTo corner3 = new LineTo();
Path path = new Path(corner1, corner2, corner3, new ClosePath());
pane.getChildren().add(path);
Timeline timeline = new Timeline(
new KeyFrame(Duration.ZERO,
new KeyValue(corner1.xProperty(), 200d),
new KeyValue(corner1.yProperty(), 200d),
new KeyValue(corner2.xProperty(), 200d),
new KeyValue(corner2.yProperty(), 200d),
new KeyValue(corner3.xProperty(), 200d),
new KeyValue(corner3.yProperty(), 200d)),
new KeyFrame(Duration.seconds(2),
new KeyValue(corner1.xProperty(), 100d),
new KeyValue(corner1.yProperty(), 100d),
new KeyValue(corner2.xProperty(), 250d),
new KeyValue(corner2.yProperty(), 300d),
new KeyValue(corner3.xProperty(), 50d),
new KeyValue(corner3.yProperty(), 380d)));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.setAutoReverse(true);
timeline.play();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.