package shape;

import javafx.geometry.Point2D;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;

public class Circle implements Shape {
    private Point2D center;
    private double radius;
    private Color color;

    public Circle(Color color, double x, double y, double radius) {
        this.color = color;
        this.center = new Point2D(x, y);
        this.radius = radius;
    }

    @Override
    public int pointsCount() {
        return 1;  // Un cercle n'a qu'un centre
    }

    @Override
    public Point2D point(int index) {
        if (index == 0) {
            return center;
        }
        throw new IndexOutOfBoundsException("Circle has only one center point.");
    }

    @Override
    public void draw(GraphicsContext context) {
        context.setStroke(color);
        context.strokeOval(center.getX() - radius, center.getY() - radius,
                radius * 2, radius * 2);
    }
}