Wednesday, May 25, 2016

6. Ellipse

A red Ellipse with center of 200, 200 and radius of 100 in x and 150 in y is drawn.


Since the window is 400 by 400, it is centered inside the window.


package ex06;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Ellipse;
import javafx.stage.Stage;

public class Ex06 extends Application {
    
    @Override
    public void start(Stage primaryStage) {
        
        Ellipse elli = new Ellipse(
                200, 200,   // center x,y
                100, 150);  // radius x,y
        elli.setFill(Color.RED);
        Group root = new Group();
        root.getChildren().add(elli);
        
        Scene scene = new Scene(root, 400, 400, Color.AQUA);
        
        primaryStage.setTitle("Example 6. Ellipse");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

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

This is the output:


No comments:

Post a Comment