📜  JavaFX Quad曲线

📅  最后修改于: 2020-10-14 01:15:52             🧑  作者: Mango

JavaFX Quad曲线

四边形曲线是二阶的普通曲线。这与“三次曲线”不同,因为它没有像三次曲线那样的两个控制点。而是具有单个控制点(X,Y)。

在JavaFX中,我们可以实例化javafx.scene.shape.QuadCurve类来创建Quad曲线。该类包含下表中定义的各种属性。该类还包含setter方法,可用于根据我们的要求设置属性以获得四边形曲线。

物产

下表提供了类的属性及其设置方法。

Property Description Setter Method
controlX X coordinate of the control point of quad curve setControlX(Double)
controlY Y coordinate of the control point of quad curve setControlY(Double)
endX X coordinate of the end point of quad curve setEndX(Double)
endY Y coordinate of ending point of quad curve setEndY(Double)
startX X coordinate of starting point of quad curve setStartX(Double)
startY Y coordinate of starting point of quad 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.QuadCurve;
import javafx.stage.Stage;
public class Shape_Example extends Application {

  @Override
  public void start(Stage primarystage) {
    Group root = new Group();
    primarystage.setTitle("QuadCurve Example");
    QuadCurve c = new QuadCurve();
    c.setStartX(70);
    c.setStartY(30);
    c.setControlX(250);
    c.setControlY(50);
    c.setFill(Color.RED);
    c.setEffect(new DropShadow());
    c.setEndX(250);
    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);
  }
}