jitx.shapes package#

Shapes and geometry#

This module provides the core Shape and ShapeGeometry classes for representing geometric objects with optional transformations. Shapes can be converted between different representations (primitive, shapely) and positioned using transforms.

class Shape(geometry, transform)[source]#

Bases: Generic[CoShapeGeometry]

A shape with geometry and an optional transform.

Shapes combine geometric data with positioning information, allowing geometric objects to be placed and transformed in 2D space.

Parameters:
  • geometry (CoShapeGeometry)

  • transform (Transform | None)

geometry: TypeVar(CoShapeGeometry, bound= ShapeGeometry, covariant=True)#

The geometric data for this shape.

transform: Transform#

The transformation applied to the geometry.

to_shapely()[source]#

Convert the given shape into a ‘shapely’ native format including the transform.

Returns:

A ShapelyGeometry shape with all of the points of the geometry transformed by the transform project of this shape.

to_primitive()[source]#

Convert the given shape into a Primitive shape.

Return type:

Shape[Primitive]

Returns:

A Primitive shape with all of the points of the geometry transformed by the transform project of this shape.

at(x, y=None, /, *, rotate=0, scale=1)[source]#

Create a new shape with additional positioning transform.

Parameters:
  • x (float | TypeAliasType | Transform) – X coordinate, point, or transform to apply.

  • y (float | None) – Y coordinate if x is a coordinate.

  • rotate (float)

  • scale (float)

Return type:

Shape[TypeVar(CoShapeGeometry, bound= ShapeGeometry, covariant=True)]

Returns:

New shape with the additional transform applied.

class ShapeGeometry[source]#

Bases: ABC, Shape

Shape geometry is raw shape information, without a transform.

property geometry#
property transform#
abstractmethod to_primitive()[source]#

Convert the given shape into a Primitive shape.

Return type:

Primitive

Returns:

A Primitive shape with all of the points of the geometry transformed by the transform project of this shape.

Submodules#