Skip to content

Circle

The Circle class represents an SVG circle element. It supports setting the center position and radius, and provides computed properties such as diameter and area.

Info

This class inherits from SvgElement.

pydreamplet.core.Circle

Circle(**kwargs)

Initializes a new circle. If pos is provided in kwargs, it sets the circle's center coordinates.

Parameters

  • **kwargs: Attributes for the circle, including pos (a Vector) and other SVG properties (e.g., r for radius).
from pydreamplet import SVG, Circle

svg = SVG(200, 200)
svg.append(Circle(cx=100, cy=100, r=50, fill="#a00344"))

Result

pos

Getter: Returns the center of the circle as a Vector.

Setter: Updates the center coordinates.

print(circle.pos)
circle.pos = Vector(60, 60)

radius

Getter: Returns the radius of the circle.

Setter: Updates the radius.

print(circle.radius)
circle.radius = 30

center

Alias for pos, returning the circle's center.

diameter

Returns the circle's diameter (2 × radius).

area

Returns the area of the circle, computed as \(\pi \times (\text{radius})^2\).