Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

import javafx.application.

Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Polygon;
import javafx.stage.Stage;

public class SuperRealisticFaceDrawing extends Application {

@Override
public void start(Stage primaryStage) {
// Create a pane to hold the face elements
Pane root = new Pane();

// Draw the head (circle)


Circle head = new Circle(150, 150, 100);
head.setFill(Color.PEACHPUFF);

// Draw the eyes (circles)


Circle leftEye = createEye(120, 120);
Circle rightEye = createEye(180, 120);

// Draw the nose (triangle)


Polygon nose = createNose(150, 140);

// Draw the mouth (ellipse)


Ellipse mouth = createMouth(150, 180);

// Add all elements to the pane


root.getChildren().addAll(head, leftEye, rightEye, nose, mouth);

// Create the scene and set it on the stage


Scene scene = new Scene(root, 300, 300);
primaryStage.setScene(scene);

// Set the stage title and show it


primaryStage.setTitle("Super Realistic Face Drawing");
primaryStage.show();
}

private Circle createEye(double x, double y) {


Circle eye = new Circle(x, y, 10, Color.BLACK);
return eye;
}

private Polygon createNose(double x, double y) {


Polygon nose = new Polygon();
nose.getPoints().addAll(
x, y,
x - 10, y + 20,
x + 10, y + 20
);
nose.setFill(Color.BURLYWOOD);
return nose;
}

private Ellipse createMouth(double x, double y) {


Ellipse mouth = new Ellipse(x, y, 30, 15);
mouth.setFill(Color.PINK);
return mouth;
}

public static void main(String[] args) {


launch(args);
}
}

You might also like