Skip to content

vm

The vm module contains concrete implementation of VirtualMachine using Shapely library.

ShapelyResult

Bases: Result

The ShapelyResult class is a wrapper around items returned ShapelyVirtualMachine class as a result of executing rendering instruction.

save

save(
    destination: str | Path | BinaryIO,
    file_format: str,
    color: Style = Style.presets.COPPER_ALPHA,
    **kwargs: Any
) -> None

Save result to a file or buffer in file_format.

Parameters:

  • destination (str | Path | BinaryIO) –

    str and Path objects are interpreted as file paths and opened with truncation. BinaryIO-like (files, BytesIO) objects are written to directly.

  • file_format (str) –

    Format to save the image in. Supported formats vary depending on the VirtualMachine used. You can expect though that vector images will support SVG and raster images will support PNG and JPEG formats. Other formats are possible, please check the documentation of the VirtualMachine you are using.

  • color (Style, default: COPPER_ALPHA ) –

    Color to use for SVG, background is ignored as it is always rendered as empty space, so only foreground applies, by default Style.presets.COPPER_ALPHA

  • kwargs (Any, default: {} ) –

    Additional keyword arguments to pass to save implementation.

save_svg

save_svg(
    destination: str | Path | BinaryIO,
    color: Style = Style.presets.COPPER_ALPHA,
    **kwargs: Any
) -> None

Save result to a file or buffer in SVG format.

Parameters:

  • destination (str | Path | BinaryIO) –

    str and Path objects are interpreted as file paths and opened with truncation. BinaryIO-like (files, StringIO) objects are written to directly.

  • color (Style, default: COPPER_ALPHA ) –

    Color to use for SVG, background is ignored as it is always rendered as empty space, so only foreground applies, by default Style.presets.COPPER_ALPHA

  • kwargs (Any, default: {} ) –

    Additional keyword arguments to pass to implementation. In particular, encoding can be used to specify encoding of the data, default is utf-8.

ShapelyEagerLayer

Bases: EagerLayer

ShapelyEagerLayer class represents drawing space of known fixed size.

It is specifically used by ShapelyEagerLayer class.

ShapelyDeferredLayer

Bases: DeferredLayer

ShapelyDeferredLayer class represents drawing space of size unknown at time of creation of layer.

It is specifically used by ShapelyDeferredLayer class.

ShapelyVirtualMachine

Bases: VirtualMachine

The ShapelyVirtualMachine class is a concrete implementation of VirtualMachine which uses Shapely library for rendering commands.

layer property

Get current layer.

create_eager_layer

create_eager_layer(
    layer_id: LayerID, box: Box, origin: Vector
) -> Layer

Create new eager layer instances (factory method).

create_deferred_layer

create_deferred_layer(
    layer_id: LayerID, origin: Vector
) -> Layer

Create new deferred layer instances (factory method).

on_shape_eager

on_shape_eager(command: Shape) -> None

Visit shape command.

on_paste_layer_eager

on_paste_layer_eager(command: PasteLayer) -> None

Visit PasteLayer command.

run

run(rvmc: RVMC) -> ShapelyResult

Execute all commands.

is_shapely_available

is_shapely_available() -> bool

Check if the language server feature is available.