svgen.cartesian.rectangle package#

Submodules#

svgen.cartesian.rectangle.corner module#

A module for working with corners of rectangles.

class svgen.cartesian.rectangle.corner.CornerScalar(from_origin: Translation, vector: Translation)[source]#

Bases: NamedTuple

A collection of attributes for a rectangle’s corner.

from_origin: Translation#

Alias for field number 0

property horizontal: bool#

Determine if this vector is horizontal.

vector: Translation#

Alias for field number 1

property vertical: bool#

Determine if this vector is vertical.

class svgen.cartesian.rectangle.corner.RectangleCorner(*values)[source]#

Bases: Enum

An enumeration of the corners of a rectangle.

BOTTOM_LEFT = ((0.0, 1.0), (1.0, 0.0))#
BOTTOM_RIGHT = ((1.0, 1.0), (0.0, -1.0))#
TOP_LEFT = ((0.0, 0.0), (0.0, 1.0))#
TOP_RIGHT = ((1.0, 0.0), (-1.0, 0.0))#
property horizontal: bool#

Determine if this vector is horizontal.

property on_bottom: bool#

Determine if this corner is on the bottom side.

property on_left: bool#

Determine if this corner is on the left side.

property on_right: bool#

Determine if this corner is on the right side.

property on_top: bool#

Determine if this corner is on the top side.

origin(dimensions: Dimensions, location: Point) Point[source]#

Get the specific corner from a rectangular object.

property origin_dx: float#

Get the ‘x’ component of this corner.

property origin_dy: float#

Get the ‘y’ component of this corner.

property vector_dx: float#

Get the ‘x’ component of this corner.

property vector_dy: float#

Get the ‘x’ component of this corner.

property vertical: bool#

Determine if this vector is vertical.

svgen.cartesian.rectangle.grid module#

A module implementing grid interfaces for rectangles.

class svgen.cartesian.rectangle.grid.RectangleGrid(rect: Rectangle, columns: int, rows: int)[source]#

Bases: NamedTuple

A class for locating points within a rectangle.

adjust(columns: int = None, rows: int = None, rect: Rectangle = None) RectangleGrid[source]#

Create a new grid from new parameters.

box(x: float, y: float) Rectangle[source]#

Get a rectangle object from provided coordinates.

property boxes: Iterable[Rectangle]#

Iterate over boxes belonging to this grid.

columns: int#

Alias for field number 1

property enumerate_boxes: Iterable[Tuple[RectangleIndex, Rectangle]]#

Iterate over boxes belonging to this grid.

property points: Iterable[Point]#

Iterate over points in the grid.

rect: Rectangle#

Alias for field number 0

rows: int#

Alias for field number 2

translate(dx: Translation | float, *args, **kwargs) RectangleGrid[source]#

Translate this rectangle grid.

property x_scale: float#

Get the scalar value for ‘x’ coordinates.

property y_scale: float#

Get the scalar value for ‘y’ coordinates.

class svgen.cartesian.rectangle.grid.RectangleIndex(column: int, row: int)[source]#

Bases: NamedTuple

An index into a rectangle grid.

column: int#

Alias for field number 0

row: int#

Alias for field number 1

Module contents#

svgen - A module for interacting with rectangular entities.

class svgen.cartesian.rectangle.Rectangle(dimensions: Dimensions, location: Point = (0.0, 0.0, False, -1))[source]#

Bases: NamedTuple

A definition of a rectangle.

property bottom_left: Point#

Get the bottom left corner point.

property bottom_right: Point#

Get the bottom right corner point.

property center: Point#

Get the center location of this rectangle.

static centered(source: Rectangle, width_scale: float = 1.0, height_scale: float = 1.0, square: bool = False) Rectangle[source]#

Create a centered rectangle from another rectangle.

corner(corner: RectangleCorner) Point[source]#

Get a specific corner of a rectangle.

static create(width: float, height: float, point: Point = (0.0, 0.0, False, -1)) Rectangle[source]#

Create a rectangle from simple parameters.

dimensions: Dimensions#

Alias for field number 0

from_center(width_scale: float = 1.0, height_scale: float = 1.0, square: bool = False) Rectangle[source]#

Create a new rectangle from this instance’s center.

property height: float#

Get the height of this rectangle..

location: Point#

Alias for field number 1

property origin: Point#

Get the origin location for this rectangle.

scale(width_scale: float = 1.0, height_scale: float = 1.0) Rectangle[source]#

Scale this rectangle’s width and height.

scale_whole(scalar: float = 1.0) Rectangle[source]#

Scale width and height of this rectangle equally.

property square: bool#

Determine if this rectangle is square.

to_square(scale: float = 1.0) Rectangle[source]#

Convert this rectangle to a square.

property top_left: Point#

Get the top left corner point.

property top_right: Point#

Get the top right corner point.

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

Move a rectangle by a given translation.

property width: float#

Get the width of this rectangle.