persunraveltorch.draw.svg

Utilities for auxiliary SVG fragments.

class persunraveltorch.draw.svg.BackgroundCreator(*args, **kwargs)[source]

Bases: Protocol

Callable for drawing backgrounds.

__call__(*, range_intervals: Tuple[float, float], strip_orientation: StripOrientation, **kwargs: Any) str[source]

Draws a background from parameters.

Parameters:
  • range_intervals (Tuple[float, float]) – The finite range containing all persistence intervals.

  • strip_orientation (StripOrientation) – The orientation of the strip to be drawn.

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

Returns:

The SVG code for the background.

Return type:

str

persunraveltorch.draw.svg.MARKERS = '<marker id="marker-disc"\n        markerUnits="userSpaceOnUse"\n        viewBox="-0.02 -0.02 0.04 0.04"\n        markerWidth="0.04"\n        markerHeight="0.04">\n  <circle r="0.015"\n          fill="currentColor"\n          class="tint-red" />\n</marker>\n<marker id="marker-x"\n        markerUnits="userSpaceOnUse"\n        viewBox="-0.03 -0.03 0.06 0.06"\n        markerWidth="0.06"\n        markerHeight="0.06">\n  <g fill="currentColor"\n     class="tint-green">\n    <rect width="0.01" height="0.04"\n          transform="rotate(-45) translate(-0.005 -0.02)" />\n    <rect width="0.01" height="0.04"\n          transform="rotate(45) translate(-0.005 -0.02)" />\n  </g>\n</marker>\n'

SVG code defining markers for <polyline>s.

Type:

str

class persunraveltorch.draw.svg.StripWithAxesPattern(*, large: float = 100, line_width: float = 0.005, tiles: int = 15)[source]

Bases: BackgroundCreator

Draws an axes pattern as a background.

This BackgroundCreator draws an axes pattern matching the regions of the unravelled relative homology lattice as a background.

__call__(range_intervals: Tuple[float, float], strip_orientation: StripOrientation, **kwargs: Any)[source]

Draws a background from parameters.

Parameters:
  • range_intervals (Tuple[float, float]) – The finite range containing all persistence intervals.

  • strip_orientation (StripOrientation) – The orientation of the strip to be drawn.

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

Returns:

The SVG code for the background.

Return type:

str

large: float

Large number used for infinite shapes and lines.

Type:

float

line_width: float
tiles: int

The number of tiles to be drawn.

Type:

int