Circle

class photonforge.Circle(radius, center=(0, 0), inner_radius=None, sector=(0, 0), rotation=0)

Circular primitives including circles, ellipses, rings and sectors.

Parameters:
  • radius – Outer radius for the circle. If a pair of number is given, an ellipse is constructed instead.

  • center – Pair of coordinates (or complex number) for the center of the circle.

  • inner_radius – If set to a number or pair of numbers, constructs a ring with circular or elliptical hole.

  • sector – Initial and final angles (in degrees) to create a circular or elliptical sector.

  • rotation – Rotation angle for the main axis of the ellipse (in degrees).

Example

>>> circle = Circle(10, (-3, 4))  # Circular shape
>>> elliptical_ring = Circle(radius=(10, 8), inner_radius=(8, 6))
>>> half_ring = Circle(radius=10, inner_radius=8, sector=(0, 180))

Methods

area()

Structure area.

bounds()

Calculate the structure bounds

copy()

Create a copy of this structure.

mirror([axis_endpoint, axis_origin])

Mirror this structure.

rotate(rotation[, center])

Rotate this structure.

scale(scaling[, center])

Scale this structure.

to_polygon()

Create a Polygon from this structure.

transform([translation, rotation, scaling, ...])

Apply a transformation to this structure: self = translate(rotate(mirror(scale(self))))

translate(translation)

Translate this structure.

Attributes

center

Center of the circle.

inner_radius

Inner radius of a ring.

radius

Circle radius.

rotation

Rotation angle of an elliptical shape (in degrees).

sector

Initial and final angles of a circular sector.

x_max

Upper bound in the x axis.

x_mid

Bounding box center in the x axis.

x_min

Lower bound in the x axis.

y_max

Upper bound in the y axis.

y_mid

Bounding box center in the y axis.

y_min

Lower bound in the y axis.

area()

Structure area.

Returns:

Area of the structure.

bounds()

Calculate the structure bounds

Returns:

The lower-left and upper-right corners of the bounding box of the structure: ((min_x, min_y), (max_x, max_y)).

Example

>>> polygon = Polygon([(0, 1), (1, 2), (3, -1)])
>>> bounds = polygon.bounds()
>>> print(bounds)
((0.0, -1.0), (3.0, 2.0))
center

Center of the circle.

copy()

Create a copy of this structure.

Returns:

New copy.

inner_radius

Inner radius of a ring.

mirror(axis_endpoint=(1, 0), axis_origin=(0, 0))

Mirror this structure.

Parameters:
  • axis_endpoint – Mirror axis endpoint.

  • axis_origin – Mirror axis origin.

Returns:

This object.

radius

Circle radius.

rotate(rotation, center=(0, 0))

Rotate this structure.

Parameters:
  • rotation – Rotation angle in degrees.

  • center – Center of rotation.

Returns:

This object.

rotation

Rotation angle of an elliptical shape (in degrees).

scale(scaling, center=(0, 0))

Scale this structure.

Parameters:
  • scaling – Magnification factor.

  • center – Center of scaling.

Returns:

This object.

sector

Initial and final angles of a circular sector.

to_polygon()

Create a Polygon from this structure.

Returns:

New polygon instance.

Examples

>>> rectangle = Rectangle((0, 0), (2, 1), rotation=45)
>>> polygon = rectangle.to_polygon()
>>> circle = Circle(5, (0, 0), inner_radius=3)
>>> polygon = circle.to_polygon()
>>> path = Path((0, 0), 0.5).s_bend((10, 2))
>>> polygon = path.to_polygon()
transform(translation=(0, 0), rotation=0, scaling=1, x_reflection=False)

Apply a transformation to this structure: self = translate(rotate(mirror(scale(self))))

Parameters:
  • translation – Coordinate pair used as a translation vector.

  • rotation – Rotation angle in degrees.

  • scaling – Magnification factor.

  • x_reflection – Mirror across the horizontal axis.

Returns:

This object.

translate(translation)

Translate this structure.

Parameters:

translation – Coordinate pair used as a translation vector.

Returns:

This object.

x_max

Upper bound in the x axis.

x_mid

Bounding box center in the x axis.

x_min

Lower bound in the x axis.

y_max

Upper bound in the y axis.

y_mid

Bounding box center in the y axis.

y_min

Lower bound in the y axis.