vpype_viewer

This module implements a flexible, GPU-accelerated viewer for interactive and offscreen rendering of vpype.Document instances. It includes a Qt-based interactive backend as well as a Pillow-based offscreen rendering backend.

Functions

render_image

Render a vpype.Document instance as a Pillow PIL.Image.Image.

show

Show a viewer for the provided vpype.Document instance.

Classes

Engine([view_mode, show_pen_up, …])

OpenGL-based rendering engine for vpype.Document.

ImageRenderer(size)

Viewer engine wrapper class to render to a PIL.Image.Image instance.

QtViewer([document, view_mode, show_pen_up, …])

Full featured, stand-alone viewer suitable for displaying a vpype.Document to a user.

UnitType(value)

Type of unit to use for display purposes.

ViewMode(value)

View mode enum.

Functions

render_image(document, size=(512, 512), view_mode=<ViewMode.PREVIEW: 4>, show_pen_up=False, show_points=False, pen_width=1.1, pen_opacity=0.8, show_ruler=False, pixel_factor=1.0, unit_type=<UnitType.METRIC: 1>, scale=None, origin=None)

Render a vpype.Document instance as a Pillow PIL.Image.Image.

By default, the document is scaled and offset to entirely fit in the image. This behaviour can be overridden using the scale and offset arguments.

Parameters
  • document (Document) -- document to render

  • size (Tuple[int, int]) -- output image size

  • view_mode (ViewMode) -- ViewMode to use

  • show_pen_up (bool) -- render pen-up trajectories

  • show_points (bool) -- render points

  • pen_width (float) -- pen width (ViewMode.PREVIEW only)

  • pen_opacity (float) -- pen opacity (ViewMode.PREVIEW only)

  • show_ruler (bool) -- display the rulers

  • pixel_factor (float) -- pixel factor (HiDPI screen support)

  • unit_type (UnitType) -- type of unit to use for the ruler

  • scale (Optional[float]) -- manually set scale

  • origin (Optional[Tuple[float, float]]) -- manually set origin

Returns

the rendered image

Return type

PIL.Image.Image

show(document, view_mode=<ViewMode.PREVIEW: 4>, show_pen_up=False, show_points=False, argv=None)

Show a viewer for the provided vpype.Document instance.

This function returns when the user close the window.

Parameters
  • document (Document) -- the document to display

  • view_mode (ViewMode) -- view mode

  • show_pen_up (bool) -- render pen-up trajectories

  • show_points (bool) -- render points

  • argv -- argument passed to Qt

Return type

int

Returns

exit status returned by Qt