VSceneExporter
VSceneExporter
Unified exporter for VScene supporting static and animated exports.
Handles:
- Static exports: SVG, PNG, PDF at specific time points
- Animation exports: Frame sequences and video files
Constructor
VSceneExporter(self, scene, output_dir: 'Optional[str]' = '.', converter: 'ConverterType' = <ConverterType.PLAYWRIGHT: 'playwright'>, timestamp_files: 'bool' = False) -> 'None'
Initialize exporter
Args: scene: The VScene to export output_dir: Directory to save exported files converter: ConverterType enum for PNG/PDF conversion timestamp_files: Whether to prefix filenames with timestamps
Methods
export(self, filename: 'str', frame_time: 'float' = 0.0, formats: 'Optional[list[str]]' = None, png_width_px: 'Optional[int]' = None, png_height_px: 'Optional[int]' = None, png_thumb_width_px: 'Optional[int]' = None, png_thumb_height_px: 'Optional[int]' = None, pdf_inch_width: 'Optional[int]' = None, pdf_inch_height: 'Optional[int]' = None) -> 'dict'
Export scene at specific time point to various formats.
Args: filename: Output filename (extension determines default format) frame_time: Time point to render (0.0 to 1.0) formats: List of formats to export (e.g. ["png", "pdf", "svg"]) png_width_px: Width in pixels for PNG export png_height_px: Height in pixels for PNG export png_thumb_width_px: Width for PNG thumbnail png_thumb_height_px: Height for PNG thumbnail pdf_inch_width: Width in inches for PDF export pdf_inch_height: Height in inches for PDF export
Returns: Dictionary with paths to exported files by format
to_frames(self, output_dir: 'str', filename_pattern: 'str' = 'frame_{:04d}', total_frames: 'int' = 60, format: 'str' = 'svg', easing: 'Optional[Callable[[float], float]]' = None, png_width_px: 'Optional[int]' = None, png_height_px: 'Optional[int]' = None, cleanup_intermediate: 'bool' = True)
Export animation as frame sequence.
Args: output_dir: Directory to save frames filename_pattern: Pattern for frame filenames (must include {:04d} or similar) total_frames: Number of frames to generate format: Format for frames ("svg", "png", or "pdf") easing: Optional easing function for animation png_width_px: Width for PNG frames png_height_px: Height for PNG frames cleanup_intermediate: If format is PNG, whether to delete SVG files
Yields: Tuple of (frame_num, time) for progress tracking
to_mp4(self, filename: 'str', total_frames: 'int' = 60, framerate: 'int' = 30, easing: 'Optional[Callable[[float], float]]' = None, width_px: 'Optional[int]' = None, height_px: 'Optional[int]' = None, cleanup_intermediate_files: 'bool' = True, codec: 'str' = 'libx264') -> 'str'
Export scene as video file.
Args: filename: Output video filename (without extension) total_frames: Number of frames to generate framerate: Video framerate (fps) easing: Optional easing function png_width_px: Width for video frames png_height_px: Height for video frames cleanup_intermediate_files: Whether to delete frame images after encoding codec: Video codec (default: libx264 for MP4)
Returns: Path to the exported video file
to_pdf(self, filename: 'str', frame_time: 'float' = 0.0, pdf_inch_width: 'Optional[int]' = None, pdf_inch_height: 'Optional[int]' = None) -> 'str'
Export scene to PDF at specific time point.
Convenience method for PDF-only export.
to_png(self, filename: 'str', frame_time: 'float' = 0.0, width_px: 'Optional[int]' = None, height_px: 'Optional[int]' = None) -> 'str'
Export scene to PNG at specific time point.
Convenience method for PNG-only export.