placement module#

Component placement and positioning#

This module provides classes for positioning components and other objects on the board with transformations and side placement.

class Placement(xform: Point | Transform | Placement, /, *, on: Side | None = None)[source]#
class Placement(translate: Point, rotate: float = 0, scale: float | tuple[float, float] = (1, 1))

Bases: Transform

Component placement with side information.

Extends Transform to include which side of the board the component is placed on.

Parameters:
side: Side = 0#

Which side of the board this placement is on.

class Kinematic[source]#

Bases: Generic

Mixin for objects that can have transforms applied.

transform: Optional[TypeVar(T, bound= Transform)] = None#

The transform applied to this object.

class Positionable[source]#

Bases: Structural, Kinematic[Placement]

Base class for objects that can be positioned on the board.

at(x, y=None, /, *, on=Side.Top, rotate=0)[source]#

Place this object relative to its frame of reference. Note that this modifies the object, and does not create a copy.

Parameters:
  • x (Placement | Transform | TypeAliasType | float) – x-value, transform, or placement to adopt.

  • y (float | None) – y-value if x is an x-value. This argument is only valid in that context.

  • rotate (float) – Rotation in degrees to apply to the object. Only applicable if not supplying a transform or placement.

  • on (Side) – If set to bottom, this object will be placed on the “opposite” side from its frame of reference. This means if the frame of reference is on the bottom of the board, setting this to “bottom” will actually put the object back on top.

Returns:

the object itself.