persunraveltorch.draw.seizing

Utilities for specifying SVGs ‘width’ and ‘height’ attributes.

class persunraveltorch.draw.seizing.Length(value, unit)[source]

Bases: NamedTuple

unit: Unit

Alias for field number 1

value: float

Alias for field number 0

class persunraveltorch.draw.seizing.Seizing(*args, **kwargs)[source]

Bases: Protocol

Callable to obtain ‘width’ and ‘height’ from parameters.

__call__(*, aspect_ratio: float, viewbox: Viewbox, complete_dimensions: bool, **kwargs: Any) Sizes[source]

Computes ‘width’ and ‘height’ attributes from parameters.

Parameters:
  • aspect_ratio (float)

  • viewbox (Viewbox)

  • complete_dimensions (bool) – Whether both attributes, ‘width’ and ‘height’ should be specified.

  • **kwargs (Any) – Any descendent of Seizing needs this so the protocol can be extended in the future.

Returns:

The resulting ‘width’ and/or ‘height’ attribute.

Return type:

Sizes

class persunraveltorch.draw.seizing.SeizingByHeight(*, length: Length)[source]

Bases: Seizing

Computes ‘width’ and ‘height’ attributes from a specified height.

__call__(*, aspect_ratio: float, complete_dimensions: bool, **kwargs: Any) Sizes[source]

Computes ‘width’ and ‘height’ attributes from parameters.

Parameters:
  • aspect_ratio (float)

  • viewbox (Viewbox)

  • complete_dimensions (bool) – Whether both attributes, ‘width’ and ‘height’ should be specified.

  • **kwargs (Any) – Any descendent of Seizing needs this so the protocol can be extended in the future.

Returns:

The resulting ‘width’ and/or ‘height’ attribute.

Return type:

Sizes

length: Length

The length of the specified height.

Type:

Length

class persunraveltorch.draw.seizing.SeizingByWidth(*, length: Length)[source]

Bases: Seizing

Computes ‘width’ and ‘height’ attributes from a specified width.

__call__(*, aspect_ratio: float, complete_dimensions: bool, **kwargs: Any) Sizes[source]

Computes ‘width’ and ‘height’ attributes from parameters.

Parameters:
  • aspect_ratio (float)

  • viewbox (Viewbox)

  • complete_dimensions (bool) – Whether both attributes, ‘width’ and ‘height’ should be specified.

  • **kwargs (Any) – Any descendent of Seizing needs this so the protocol can be extended in the future.

Returns:

The resulting ‘width’ and/or ‘height’ attribute.

Return type:

Sizes

length: Length

The length of the specified width.

Type:

Length

class persunraveltorch.draw.seizing.Sizes(width: persunraveltorch.draw.seizing.sizes.Length | None = None, height: persunraveltorch.draw.seizing.sizes.Length | None = None)[source]

Bases: object

height: Length | None
width: Length | None
class persunraveltorch.draw.seizing.Unit(value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

CM = 'cm'
EM = 'em'
EX = 'ex'
IN = 'in'
MM = 'mm'
PC = 'pc'
PERCENT = '%'
PT = 'pt'
PX = 'px'