svgen.cartesian package — docs

Skip to main content
`Ctrl`+`K`

# svgen.cartesian package

## Subpackages

- svgen.cartesian.rectangle package
  - Submodules
  - svgen.cartesian.rectangle.corner module
    - `CornerScalar`
      - `CornerScalar.from_origin`
      - `CornerScalar.horizontal`
      - `CornerScalar.vector`
      - `CornerScalar.vertical`
    - `RectangleCorner`
      - `RectangleCorner.BOTTOM_LEFT`
      - `RectangleCorner.BOTTOM_RIGHT`
      - `RectangleCorner.TOP_LEFT`
      - `RectangleCorner.TOP_RIGHT`
      - `RectangleCorner.horizontal`
      - `RectangleCorner.on_bottom`
      - `RectangleCorner.on_left`
      - `RectangleCorner.on_right`
      - `RectangleCorner.on_top`
      - `RectangleCorner.origin()`
      - `RectangleCorner.origin_dx`
      - `RectangleCorner.origin_dy`
      - `RectangleCorner.vector_dx`
      - `RectangleCorner.vector_dy`
      - `RectangleCorner.vertical`
  - svgen.cartesian.rectangle.grid module
    - `RectangleGrid`
      - `RectangleGrid.adjust()`
      - `RectangleGrid.box()`
      - `RectangleGrid.boxes`
      - `RectangleGrid.columns`
      - `RectangleGrid.enumerate_boxes`
      - `RectangleGrid.points`
      - `RectangleGrid.rect`
      - `RectangleGrid.rows`
      - `RectangleGrid.translate()`
      - `RectangleGrid.x_scale`
      - `RectangleGrid.y_scale`
    - `RectangleIndex`
      - `RectangleIndex.column`
      - `RectangleIndex.row`
  - Module contents
    - `Rectangle`
      - `Rectangle.bottom_left`
      - `Rectangle.bottom_right`
      - `Rectangle.center`
      - `Rectangle.centered()`
      - `Rectangle.contains()`
      - `Rectangle.corner()`
      - `Rectangle.create()`
      - `Rectangle.dimensions`
      - `Rectangle.from_center()`
      - `Rectangle.height`
      - `Rectangle.location`
      - `Rectangle.origin`
      - `Rectangle.scale()`
      - `Rectangle.scale_whole()`
      - `Rectangle.square`
      - `Rectangle.to_square()`
      - `Rectangle.top_left`
      - `Rectangle.top_right`
      - `Rectangle.translate()`
      - `Rectangle.width`

## Submodules

## svgen.cartesian.angle module

A module implementing an interface for angles.

class svgen.cartesian.angle.DegreePrimitive(val: int)

  Bases: `int`, `Rotatable`

  A class to manage integer primitives for degrees within a 0 and 360 range.

  arc(count: int = 1, divisor: int = 2) → DegreePrimitive

    Rotate this angle around the circle.

  rotate(val: int) → DegreePrimitive

    Rotate this degree instance.

class svgen.cartesian.angle.Rotatable

  Bases: `ABC`

  A generic interface for rotatable instances.

  abstractmethod arc(count: int = 1, divisor: int = 2) → T

    Rotate this angle around the circle.

## svgen.cartesian.circle module

svgen - A module for interacting with circular entities.

class svgen.cartesian.circle.Circle(radius: float, center: Point = (0.0, 0.0, True, -1))

  Bases: `NamedTuple`

  A radius and center describing a circle.

  property attrs: CircleAttrs

    Get the ‘radius’ and ‘center’ attributes for this circle.

  center: Point

    Alias for field number 1

  property center_attrs: PointAttrs

    Get the ‘center’ attributes for this circle.

  radius: float

    Alias for field number 0

  property radius_attr: SimpleAttribute

    Get the ‘radius’ attribute for this circle.

  scale(scale: float = 1.0) → Circle

    Scale this circle’s radius.

  translate(move: Translation) → Circle

    Move this circle by a given translation.

class svgen.cartesian.circle.CircleAttrs(radius: SimpleAttribute, center: PointAttrs)

  Bases: `NamedTuple`

  A grouping for ‘width’ and ‘center’ attributes for a cicle.

  center: PointAttrs

    Alias for field number 1

  radius: SimpleAttribute

    Alias for field number 0

  property radius_val: float

    Get the ‘radius’ value for this circle.

## svgen.cartesian.mutate module

A module implementing cartesian object mutations.

class svgen.cartesian.mutate.Angle(degrees: float, radians: float, sin: float, cos: float)

  Bases: `NamedTuple`

  A definition of angle attributes.

  cos: float

    Alias for field number 3

  degrees: float

    Alias for field number 0

  static from_degrees(val: float) → Angle

    Create an angle from a degree value.

  static from_radians(val: float) → Angle

    Create an angle from a radian value.

  radians: float

    Alias for field number 1

  sin: float

    Alias for field number 2

class svgen.cartesian.mutate.Translation(dx: float = 0.0, dy: float = 0.0)

  Bases: `NamedTuple`

  A definition of a translation in a Cartesian coordinate system.

  dx: float

    Alias for field number 0

  dy: float

    Alias for field number 1

  static normalize(dx: Translation | float, *args, **kwargs) → Translation

    Normalize input data into a translation.

  static polar(count: float, radius: float = 1.0, degrees: bool = True, ccw: bool = True) → Translation

    Create a polar translation based on provided parameters.

  rotate(angle: Angle = (90.0, 1.5707963267948966, 1.0, 6.123233995736766e-17)) → Translation

    Rotate this translation vector by some angle.

## svgen.cartesian.plane module

A module for working with two-dimensional planes.

class svgen.cartesian.plane.Plane(origin: Point = (0.0, 0.0, False, -1), points: dict[str, Point] = None)

  Bases: `PointManager`

  A class for managing geometric entities.

  property origin: Point

    Get the origin of this plane.

## svgen.cartesian.point module

A module for interfacing with points.

class svgen.cartesian.point.Point(x: float = 0.0, y: float = 0.0, center: bool = False, idx: int = -1)

  Bases: `NamedTuple`

  A definition of a point in a Cartesian coordinate system.

  property attrs: PointAttrs

    Get the ‘x’ and ‘y’ attributes for this point.

  center: bool

    Alias for field number 2

  distance(point: Point) → float

    Compute the distance from this point to another.

  idx: int

    Alias for field number 3

  polar(count: float, radius: float = 1.0, degrees: bool = True, ccw: bool = True) → Point

    Create a new point from a polar-coordinate translation.

  to_center() → Point

    Convert an existing point to one that is definitely a ‘center’ type.

  translate(move: Translation | float, *args) → Point

    Move a point by a given translation.

  with_index(idx: int) → Point

    Get a new point with the specified index, from an existing point.

  x: float

    Alias for field number 0

  property x_attr: SimpleAttribute

    Get the ‘x’ attribute for this point.

  y: float

    Alias for field number 1

  property y_attr: SimpleAttribute

    Get the ‘y’ attribute for this point.

class svgen.cartesian.point.PointAttrs(x: SimpleAttribute, y: SimpleAttribute)

  Bases: `NamedTuple`

  A grouping for ‘x’ and ‘y’ attributes.

  x: SimpleAttribute

    Alias for field number 0

  property x_val: float

    Get the ‘x’ coordinate for these attributes.

  y: SimpleAttribute

    Alias for field number 1

  property y_val: float

    Get the ‘y’ coordinate for these attributes.

class svgen.cartesian.point.PointManager(points: dict[str, Point] = None)

  Bases: `object`

  A class for managing points.

  add_point(name: str, point: Point | float, *args) → Point

    Add a named point to this manager.

  get_point(name: str) → Point

    Access a point object.

  translate(move: Translation | float, *args) → None

    Translate all entities in the plane by some amount.

svgen.cartesian.point.to_center(point: Point) → Point

  Convert an existing point to one that is definitely a ‘center’ type.

## Module contents

svgen - A module for Cartesian-coordinate interfaces.

class svgen.cartesian.DimensionAttrs(width: SimpleAttribute, height: SimpleAttribute)

  Bases: `NamedTuple`

  A grouping for ‘width’ and ‘height’ attributes.

  height: SimpleAttribute

    Alias for field number 1

  property height_val: float

    Get the ‘height’ value for these dimensions.

  width: SimpleAttribute

    Alias for field number 0

  property width_val: float

    Get this ‘width’ value for these dimensions.

class svgen.cartesian.Dimensions(width: float, height: float)

  Bases: `NamedTuple`

  A set of dimensions describing a rectangular entity.

  property attrs: DimensionAttrs

    Get the ‘width’ and ‘height’ attributes for these dimensions.

  property dx: float

    An alias for width.

  property dy: float

    An alias for height.

  height: float

    Alias for field number 1

  property height_attr: SimpleAttribute

    Get the ‘height’ attribute for these dimensions.

  scale(width_scale: float = 1.0, height_scale: float = 1.0) → Dimensions

    Scale these dimensions.

  property square: bool

    Determine if these dimensions are square.

  to_centered_square(scale: float = 1.0) → Tuple[Dimensions, Translation]

    Make dimensions square and determine the resulting translation that would be needed to logically center the new object.

  to_square(scale: float = 1.0) → Dimensions

    Convert these dimensions to a scaled square.

  width: float

    Alias for field number 0

  property width_attr: SimpleAttribute

    Get the ‘width’ attribute for these dimensions.

svgen.cartesian.distance(point_a: Point, point_b: Point = (0.0, 0.0, False, -1)) → float

  Compute the distance between two points.