Skip to content

draw_rectangle

draw_rectangle

Rectangle component for creating apertures.

DrawRectangle

Bases: DrawCommand

Description of rectangle aperture component.

Source code in src/pygerber/backend/abstract/draw_commands/draw_rectangle.py
class DrawRectangle(DrawCommand):
    """Description of rectangle aperture component."""

    center_position: Vector2D
    x_size: Offset
    y_size: Offset

    def __init__(
        self,
        backend: Backend,
        polarity: Polarity,
        center_position: Vector2D,
        x_size: Offset,
        y_size: Offset,
    ) -> None:
        """Initialize draw command."""
        super().__init__(backend, polarity)
        self.center_position = center_position
        self.x_size = x_size
        self.y_size = y_size

    def get_bounding_box(self) -> BoundingBox:
        """Return bounding box of draw operation."""
        return self._bounding_box

    @cached_property
    def _bounding_box(self) -> BoundingBox:
        return (
            BoundingBox.from_rectangle(self.x_size, self.y_size) + self.center_position
        )

__init__

__init__(
    backend: Backend,
    polarity: Polarity,
    center_position: Vector2D,
    x_size: Offset,
    y_size: Offset,
) -> None

Initialize draw command.

Source code in src/pygerber/backend/abstract/draw_commands/draw_rectangle.py
def __init__(
    self,
    backend: Backend,
    polarity: Polarity,
    center_position: Vector2D,
    x_size: Offset,
    y_size: Offset,
) -> None:
    """Initialize draw command."""
    super().__init__(backend, polarity)
    self.center_position = center_position
    self.x_size = x_size
    self.y_size = y_size

get_bounding_box

get_bounding_box() -> BoundingBox

Return bounding box of draw operation.

Source code in src/pygerber/backend/abstract/draw_commands/draw_rectangle.py
def get_bounding_box(self) -> BoundingBox:
    """Return bounding box of draw operation."""
    return self._bounding_box