diff --git a/src/main/java/shape/CenterDecorator.java b/src/main/java/shape/CenterDecorator.java new file mode 100644 index 0000000000000000000000000000000000000000..4dd21ad4a4a7cc38f9fc890267c03141b33285fc --- /dev/null +++ b/src/main/java/shape/CenterDecorator.java @@ -0,0 +1,30 @@ +package shape; + +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.paint.Color; +import javafx.geometry.Point2D; +import shape.Shape; + +public class CenterDecorator extends Decorator{ + private double radius; + + public CenterDecorator(Shape decoratedShape, double radius){ + super(decoratedShape); + this.radius=radius; + } + + @Override + protected void drawDecoration(GraphicsContext graphicsContext) { + graphicsContext.setStroke(Color.RED); // Définir la couleur de la décoration + + // Calculer le centre de la forme décorée + Point2D center = point(0); + + // Dessiner un cercle autour du centre + graphicsContext.fillOval(center.getX() - radius, center.getY() - radius, radius * 2, radius * 2); + } + public void draw(GraphicsContext graphicsContext) { + super.draw(graphicsContext); + drawDecoration(graphicsContext); + } +}