pythagoras.canvas module¶
- class pythagoras.canvas.Canvas(scale: float = 1)[source]¶
Bases:
objectContainer class for a collection of
PObject’s. Controls the SVG and TikZ output, and resizes automatically when a new element is added.- Variables:
context (pythagoras.pobject.RenderingContext) – State of the canvas; groups its scaling, its bounding box, and so forth. It can be queried to retrieve its current height, origin, etc.
- add(obj: PObject, *args: POProperty) None[source]¶
Appends an element into the list of objects to be renderded.
- Parameters:
obj –
PObjectto be included into the scene.*args – Parameters of the object, i.e.:
Fill(BLUE)orStroke(RED). Seepythagoras.stylefor further information on styling.
- add_many(objs: Iterable[PObject], *args: POProperty) None[source]¶
Appends a collection of elements sharing common arguments into the list of objects to be renderded.
- Parameters:
objs – Sequence of
PObject’s to be included into the scene.*args – Parameters of the object, i.e.:
Fill(BLUE)orStroke(RED). Seepythagoras.stylefor further information on styling.
- context: RenderingContext¶
- property scale: float¶
Scaling factor stored in the
contextattribute.