Workspace

class ez_pil.workspace.Workspace(size)

Workspace class for working with layers and components.

add_component(*, layer_name=None, identifier=None, func, options)

Add component to a layer.

Parameters:
  • layer_name (str | None) – name of the layer

  • identifier (str | None) – unique name for a component

  • func (Callable | str) – the function or function name from editor class

  • options (ComponentKwargs) – keyword arguments for the func

Raises:

ValueError – if the layer is not available in the workspace

create_layer(name, background=(0, 0, 0, 0))

Create a layer.

Parameters:
  • name (str) – name of the layer

  • background (int | str | tuple[int, int, int] | tuple[int, int, int, int]) – background color of the layer

generate_image()

Generate image from the layers.

Returns:

The editor instance

Return type:

Editor

remove_component(*, layer_name=None, identifier)

Remove component from a layer.

Parameters:
  • layer_name (str | None) – name of the layer

  • identifier (str) – unique name for a component

Raises:

ValueError – if the layer is not available in the workspace

remove_layer(name)

Remove a layer.

Parameters:

name (str) – name of the layer

Raises:

ValueError – if the layer is not available in the workspace

set_working_layer(name)

Set a layer as working layer.

Parameters:

name (str) – name of the layer

Raises:

ValueError – if the layer is not available in the workspace

update_component(*, layer_name=None, identifier, options)

Update component of a layer.

Parameters:
  • layer_name (str | None) – name of the layer

  • identifier (str) – unique name for a component

  • options (ComponentKwargs) – modified options

Raises:

ValueError – if the layer is not available in the workspace

update_layer(layer_name, new_layer_name=None, background=None)

Create a layer.

Parameters:
  • layer_name (str) – name of the layer

  • new_layer_name (str | None) – updated name of the layer, defaults to None

  • background (int | str | tuple[int, int, int] | tuple[int, int, int, int] | None) – background color of the layer, defaults to None

Raises:

ValueError – if the layer is not available in the workspace