vsketch.sketch_class#

Overview#

Classes#

SketchClass

Base class for sketch managed with the vsk CLI tool.

Param

Generic parameter for SketchClass.

Classes#

class vsketch.sketch_class.SketchClass#

Base class for sketch managed with the vsk CLI tool.

Subclass must override draw() and finalize().

Overview

Methods#

execute_draw()

-

ensure_finalized()

-

execute(seed, finalize)

class -

display(*args, **kwargs)

class Execute the sketch class and display the results using Vsketch.display().

draw(vsk)

abc Draws the sketch.

finalize(vsk)

abc Finalize the sketch before export.

post_finalize(vsk, path)

Called after export, optional in subclasses.

get_params()

class -

set_param_set(param_set)

class -

Members

execute_draw() None#
ensure_finalized() None#
classmethod execute(seed: int | None = None, finalize: bool = False) SketchClass | None#
classmethod display(*args: Any, **kwargs: Any) None#

Execute the sketch class and display the results using Vsketch.display().

All parameters are forwarded to Vsketch.display().

abstract draw(vsk: vsketch.vsketch.Vsketch) None#

Draws the sketch.

This function must be implemented by subclasses.

abstract finalize(vsk: vsketch.vsketch.Vsketch) None#

Finalize the sketch before export.

This function must be implemented by subclasses.

post_finalize(vsk: vsketch.vsketch.Vsketch, path: pathlib.Path) None#

Called after export, optional in subclasses.

Intended to allow for including post-processing on saved files.

classmethod get_params() dict[str, Param]#
classmethod set_param_set(param_set: dict[str, Any]) None#
class vsketch.sketch_class.Param(value: _T, min_value: _T | None = None, max_value: _T | None = None, *, choices: Iterable[_T] | None = None, step: None | float | int = None, unit: str = '', decimals: int | None = None)#

Bases: Generic[_T]

Generic parameter for SketchClass.

This class implements a generic parameter for SketchClass instances. Parameters can be interacted with in the vsk viewer and support functionalities such as saved configuration and parameter space exploration with vsk save.

Overview

Methods#

set_value(value)

Assign a value without validation.

set_value_with_validation(v)

Assign a value to the parameter provided that the value can be validated.

Members

set_value(value: _T) None#

Assign a value without validation.

set_value_with_validation(v: Any) bool#

Assign a value to the parameter provided that the value can be validated.

The value must be of a compatible type and comply with the parameter’s choices and bounds if defined.

Returns:

returns True if the value was successfully updated