0
我試圖做一個節點按照這個路徑:包含arcTo使圓角風格的路徑
但我有一個很難真正得到它的工作。目前,我有它這樣做:
有人知道如何使這項工作正常?這裏是我當前的代碼:
import javafx.animation.PathTransition;
import javafx.animation.Transition;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.ArcTo;
import javafx.scene.shape.Circle;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Test extends Application {
public void start(Stage primaryStage) throws Exception {
double fromX = 50;
double fromY = 400;
double toX = 300;
double toY = 300;
Circle node = new Circle(10);
MoveTo path1 = new MoveTo();
path1.setX(fromX);
path1.setY(fromY);
ArcTo path2 = new ArcTo();
path2.setX(toX);
path2.setY(toY);
path2.setRadiusX(.5);
path2.setRadiusY(1.0);
path2.setXAxisRotation(45.0);
path2.setSweepFlag(true);
//path2.setLargeArcFlag(true);
Path path = new Path(path1, path2);
path.setStroke(Color.DODGERBLUE);
path.getStrokeDashArray().setAll(5d, 5d);
PathTransition secondMove = new PathTransition(Duration.seconds(2), path, node);
secondMove.setCycleCount(Transition.INDEFINITE);
Pane content = new Pane(node, path);
primaryStage.setScene(new Scene(content, 600, 600));
primaryStage.show();
secondMove.play();
}
}