pythagoras.pobject module¶
- class pythagoras.pobject.POProperty[source]¶
Bases:
ABCAbstract base class for a property of a
PObject.
- class pythagoras.pobject.PObject[source]¶
Bases:
ABCAbstract base class for renderable objects.
- abstractmethod extrema() list[tuple[float, float]][source]¶
Computes the furthermost points of the figure.
- Returns:
A list with the bounding points of the object.
- set_rendering_priority(order: int) None[source]¶
Modify the
_zordattribute after the instantiation. The higher the order, the later it will be rendered.- Parameters:
order – Rendering priority.
- abstractmethod svg(ctx: RenderingContext, *args: POProperty) str[source]¶
Compiles the object into SVG commands.
- Parameters:
ctx – Context associated with the
Canvasinstance.args – Properties of the object.
- Returns:
The corresponding SVG code.
- abstractmethod tikz(ctx: RenderingContext, *args: POProperty) str[source]¶
Compiles the object into a sequence of TikZ instructions.
- Parameters:
ctx – Context associated with the
Canvasinstance.args – Properties of the object.
- Returns:
The resulting TikZ code.
- class pythagoras.pobject.RenderingContext(scale: float, xmin: float, xmax: float, ymin: float, ymax: float)[source]¶
Bases:
objectContainer class for the properties of a
Canvasobject. Its main purpose is to be passed as an argument when callingPObject.svg()orPObject.tikz().- Variables:
scale (float) – The scaling factor by which the canvas is stretched. When exporting to TikZ, this is compiled exactly into
[scale={scale}], and when using SVG, every distance is muliplied by its value.xmin (float) – Minimum \(x\)-coordinate across all the entities (without scaling).
xmax (float) – Maximum \(x\)-coordinate across all the entities (without scaling).
ymin (float) – Minimum \(y\)-coordinate across all the entities (without scaling).
xmax – Maximum \(y\)-coordinate across all the entities (without scaling).
- classmethod from_dimensions(scale: float, width: float, height: float, origin: tuple[float, float] = (0, 0)) Self[source]¶
Construct a rendering context from its dimensions and its position in space.
- Returns:
An instance of
RenderingContext.
- property height: float¶
Height of the canvas (after scaling).
- property origin: tuple[float, float]¶
Center of the canvas in the Cartesian plane (before scaling).
- scale: float¶
- property width: float¶
Width of the canvas (after scaling).
- xmax: float¶
- xmin: float¶
- ymax: float¶
- ymin: float¶