Circle_Path_CubicCurve1
  • class CubicCurveTo
    Creates a curved path element, defined by three new pointsCreates a curved path element, defined by three new pointsCreates a curved path element, defined by three new points
  • No Animation Yet
Code :

package javafxtemplate1;
//
import javafx.animation.Animation;
import javafx.animation.Interpolator;
import javafx.animation.PathTransition.OrientationType;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.ArcTo;
import javafx.scene.shape.Circle;
import javafx.scene.shape.ClosePath;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.stage.Stage;
import javafx.animation.PathTransition;
import javafx.scene.shape.CubicCurveTo;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.PathElement;
import javafx.util.Duration;
/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
//

final PathTransition pathTransition = new PathTransition();
@Override

public void start(Stage primaryStage)
{

final Circle circle1 = new Circle();
circle1.setCenterX(10);circle1.setCenterY(10);
circle1.setRadius(10.0f); circle1.setFill(Color.WHITE);
//PathElement[] path = squareOrbit();
Path path = new Path();
path.getElements().add (new MoveTo (0f, 50f));
path.setStroke(Color.WHITE);
path.setStrokeWidth(4);

path.getElements().add (new CubicCurveTo (40f, 10f, 390f, 240f, 400, 50f));
//

Group root = new Group();
root.getChildren().addAll(path, circle1);
root.setTranslateX(50);
root.setTranslateY(50);
Scene scene = new Scene(root, 500, 500, Color.DARKGRAY);

primaryStage.setTitle("Moveto-Path demo");
primaryStage.setScene(scene);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);

}

}
 

 
 
Displays: