📅  最后修改于: 2020-10-14 01:15:34             🧑  作者: Mango
通常,三次曲线是3阶曲线。在JavaFX中,我们只需实例化javafx.scene.shape.CubicCurve类即可创建三次曲线。该类包含表中定义的各种属性以及setter方法。需要设置这些属性,以便根据需要创建三次曲线。
三次曲线类的属性具有以下属性。
Property | Description | Setter method |
---|---|---|
controlX1 | X coordinate of first control point of cubic curve. | setControlX1(Double) |
controlX2 | X coordinate of second control point of cubic curve | setControlX2(Double) |
controlY1 | Y coordinate of first control point of cubic curve | setControlY1(Double) |
controlY2 | Y coordinate of second control point of cubic curve | setControlX1(Double) |
endX | X coordinate of end point of cubic curve | setEndX(Double) |
endY | Y coordinate of end point of cubic curve. | setEndY(Double) |
startX | X coordinate of starting point of cubic curve | setStartX(Double) |
startY | Y coordinate of starting point of cubic curve | setStartY(Double) |
package application;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.paint.Color;
import javafx.scene.shape.CubicCurve;
import javafx.stage.Stage;
public class Shape_Example extends Application {
@Override
public void start(Stage primarystage) {
Group root = new Group();
primarystage.setTitle("Cubic Curve Example");
CubicCurve c = new CubicCurve();
c.setStartX(20);
c.setStartY(100);
c.setControlX1(300);
c.setControlX2(200);
c.setControlY1(100);
c.setControlY2(90);
c.setFill(Color.RED);
c.setEffect(new DropShadow());
c.setEndX(100);
c.setEndY(300);
root.getChildren().add(c);
Scene scene = new Scene(root,300,400);
primarystage.setScene(scene);
primarystage.show();
}
public static void main(String[] args) {
launch(args);
}
}