svgen.cartesian package#

Subpackages#

Submodules#

svgen.cartesian.angle module#

A module implementing an interface for angles.

class svgen.cartesian.angle.DegreePrimitive(val: int)[source]#

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[source]#

Rotate this angle around the circle.

rotate(val: int) DegreePrimitive[source]#

Rotate this degree instance.

class svgen.cartesian.angle.Rotatable[source]#

Bases: ABC

A generic interface for rotatable instances.

abstractmethod arc(count: int = 1, divisor: int = 2) T[source]#

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))[source]#

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[source]#

Scale this circle’s radius.

translate(move: Translation) Circle[source]#

Move this circle by a given translation.

class svgen.cartesian.circle.CircleAttrs(radius: SimpleAttribute, center: PointAttrs)[source]#

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)[source]#

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[source]#

Create an angle from a degree value.

static from_radians(val: float) Angle[source]#

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)[source]#

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[source]#

Normalize input data into a translation.

rotate(angle: Angle = (90.0, 1.5707963267948966, 1.0, 6.123233995736766e-17)) Translation[source]#

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)[source]#

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)[source]#

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[source]#

Compute the distance from this point to another.

idx: int#

Alias for field number 3

to_center() Point[source]#

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

translate(move: Translation | float, *args) Point[source]#

Move a point by a given translation.

with_index(idx: int) Point[source]#

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)[source]#

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)[source]#

Bases: object

A class for managing points.

add_point(name: str, point: Point | float, *args) Point[source]#

Add a named point to this manager.

get_point(name: str) Point[source]#

Access a point object.

translate(move: Translation | float, *args) None[source]#

Translate all entities in the plane by some amount.

svgen.cartesian.point.to_center(point: Point) Point[source]#

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)[source]#

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)[source]#

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[source]#

Scale these dimensions.

property square: bool#

Determine if these dimensions are square.

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

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[source]#

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[source]#

Compute the distance between two points.