An arc shape is drawn on a 400 by 400 scene window.
The arc is centered at (200,200) so it at center of window. Its radius is 100 in both x and y direction.
It starts at 0 degrees and ends at 270 degrees, thus only 3/4 of the circle is filled.
package ex04;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.stage.Stage;
public class Ex04 extends Application {
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Example 4. Arc");
Group root = new Group();
Arc arc = new Arc(
200, 200, // center x,y
100, 100, // radius x,y
0, 270); // start and length angle
arc.setType(ArcType.ROUND);
arc.setFill(Color.RED);
root.getChildren().add(arc);
Scene scene = new Scene(root, 400, 400, Color.AZURE);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
This is the output:
No comments:
Post a Comment