fix confusion between circle radius and diameter

classic shite
This commit is contained in:
2026-03-19 19:05:12 +01:00
parent dd59c7d51a
commit ad45eddbf5
3 changed files with 5 additions and 5 deletions

View File

@@ -57,7 +57,7 @@ public class App {
SCollection.of(
SRectangle.create(100, 200, 40, 60, Color.MAGENTA),
SRectangle.create(150, 200, 40, 60, Color.MAGENTA),
SCircle.create(200, 200, 60)
SCircle.create(200, 250, 30)
)
);
}

View File

@@ -8,10 +8,10 @@ import java.awt.*;
public class SCircle extends AbstractShape {
private int radius;
private final int radius;
private SCircle(int x, int y, int radius) {
super(new Rectangle(x, y, radius, radius));
super(new Rectangle(x, y, radius * 2, radius * 2));
this.radius = radius;
}

View File

@@ -56,10 +56,10 @@ public class ShapeDraftman implements ShapeVisitor {
}
if (colAttrs.filled) {
this.g2d.setColor(colAttrs.filledColor);
this.g2d.fillOval(bounds.x, bounds.y, circle.getRadius(), circle.getRadius());
this.g2d.fillOval(bounds.x, bounds.y, 2 * circle.getRadius(), 2 * circle.getRadius());
}
if (colAttrs.stroked) this.g2d.setColor(colAttrs.strokedColor);
this.g2d.drawOval(bounds.x, bounds.y, circle.getRadius(), circle.getRadius());
this.g2d.drawOval(bounds.x, bounds.y, 2 * circle.getRadius(), 2 * circle.getRadius());
drawHandlerIfSelected(circle);
}