CubicCurve with control points : CubicCurve « JavaFX « Java






CubicCurve with control points

 

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.DropShadowBuilder;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.stage.Stage;
public class Main extends Application {
    public static void main(String[] args) {
        Application.launch(args);
    }
    
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Shapes");
        Group root = new Group();
        Scene scene = new Scene(root, 300, 300, Color.WHITE);

        // CubicCurve
        CubicCurve cubicCurve = CubicCurveBuilder.create()
                .startX(50)
                .startY(75)        // start pt (x1,y1)
                .controlX1(80)
                .controlY1(-25)    // control pt1
                .controlX2(110)
                .controlY2(275)    // control pt2
                .endX(140).endY(375) // end pt (x2,y2)
                .strokeType(StrokeType.CENTERED).strokeWidth(1)
                .stroke(Color.BLACK)
                .strokeWidth(3)
                .fill(Color.WHITE)
                .build();

        root.getChildren().add(cubicCurve);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

   
  








Related examples in the same category

1.Cubic Bezier