svg3d¶
Three-dimensional vector rendering software in Python.
This primary package contains object primitives (Mesh) and the rendering engine
Engine itself.
- class svg3d.svg3d.Engine(views, precision=14)[source]¶
Bases:
object- Parameters:
precision (int)
- __init__(views, precision=14)[source]¶
The engine used to render a scene into an image.
Example
> import svg3d > scene = [svg3d.Mesh.example_mesh()] > view = svg3d.View.isometric(scene) > svg3d.Engine([view]).render(“example.svg”) Wrote file “example.svg”
- Parameters:
views (list[View]) – List of
Viewobjects to render. Each is rendered into the same image, allowing for composite graphics from multiple viewpoints. For simplicity, a singleViewobject is often best.precision (int) – Number of decimal places of precision for numeric quantities in the mesh. Smaller values will reduce file sizes but may result in minor inconsistencies in very small geometries. Default value: 14
- render(filename, size=(512, 512), viewbox='-0.5 -0.5 1.0 1.0', **extra)[source]¶
Render the current view or views to a file.
- Parameters:
filename (str) – The name of the file to save the render to. Should be postfixed with .svg
size (tuple of int, optional) – Size of the render in pixels. Default is (512, 512).
viewbox (str, optional) –
viewBoxattribute for the SVG. Default is “-0.5 -0.5 1.0 1.0”.**extra – Additional keyword arguments to be passed into
svgwrite.
- Raises:
RuntimeWarning – If all faces of a mesh are pruned due to an incorrect projection matrix.
RuntimeWarning – If
render()is called without any Views to render.
- class svg3d.svg3d.Mesh(faces, shader=None, circle_radius=0.0)[source]¶
Bases:
object- property circle_radius¶
- classmethod from_coxeter(poly, shader=None)[source]¶
Create a
Meshobject from a coxeterConvexPolyhedron.- Parameters: