vpype_gscrib.processor
Vector graphics preprocessing for G-code generation.
This module provides the core functionality and interface for processing and rendering vpype documents. It is used by the vpype_gscrib.renderer module to produce the G-Code programs.
- class vpype_gscrib.processor.DocumentProcessor(renderer: DocumentRenderer)
Bases:
objectProcesses vector graphics documents by traversing their hierarchical structure and delegating operations to a renderer.
This class walks through a document’s hierarchical structure —layers, paths, and segments— calling the appropriate methods to process a document on a DocumentRenderer instance.
The traversal order is:
Start document processing.
Process each layer of the document.
Process each path within a layer.
Process each segment within a path.
End document processing.
- class vpype_gscrib.processor.DocumentRenderer
Bases:
ABCAbstract base class defining the interface for document renderers.
This class defines a structured approach to processing a document by traversing its hierarchy: Document → Layers → Paths → Segments. Implementations of this class must provide methods to handle each stage of the traversal.
- abstractmethod begin_document(document: Document)
This method is invoked once per document before any of the document layers are processed.
- abstractmethod begin_layer(layer: LineCollection)
Each layer is composed of one or more paths. This method is invoked once per layer before any paths are processed.
- abstractmethod begin_path(path: array)
Each path is composed of one or more segments. This method is invoked once per path before any of its segments are processed.
- abstractmethod end_document(document: Document)
This method is invoked once per document after all layers on the document have been processed.
- abstractmethod end_layer(layer: LineCollection)
This method is invoked once per layer after all paths on the layer have been processed.
- abstractmethod end_path(path: array)
This method is invoked once per path after all segments of the path have been processed.