Newer
Older
package shape;
import javafx.geometry.Point2D;
import javafx.scene.canvas.GraphicsContext;
AREZKI Celia
committed
import javafx.scene.paint.Color;
AREZKI Celia
committed
private Point2D center;
private double radius;
private Color color;
AREZKI Celia
committed
public Circle(Color color, double x, double y, double radius) {
this.color = color;
this.center = new Point2D(x, y);
this.radius = radius;
AREZKI Celia
committed
return 1; // Un cercle n'a qu'un centre
AREZKI Celia
committed
if (index == 0) {
return center;
}
throw new IndexOutOfBoundsException("Circle has only one center point.");
}
@Override
public void draw(GraphicsContext context) {
AREZKI Celia
committed
context.setStroke(color);
context.strokeOval(center.getX() - radius, center.getY() - radius,
radius * 2, radius * 2);