Skip to content

LayerColor class

Bases: pytvpaint.utils.Refreshable

The color of a layer identified by an index. Layer colors are specific to a clip.

Construct a LayerColor from an index and a clip (if None it gets the current clip).

Source code in pytvpaint/layer.py
226
227
228
229
230
231
232
233
234
235
236
237
def __init__(
    self,
    color_index: int,
    clip: Clip | None = None,
) -> None:
    """Construct a LayerColor from an index and a clip (if None it gets the current clip)."""
    from pytvpaint.clip import Clip

    super().__init__()
    self._index = color_index
    self._clip = clip or Clip.current_clip()
    self._data = george.tv_layer_color_get_color(self.clip.id, self._index)

index: int property

The layer color index.

clip: Clip property

The layer color clip.

is_visible: bool property

Get the visibility of the color index.

refresh() -> None

Refreshes the layer color data.

Source code in pytvpaint/layer.py
239
240
241
242
243
def refresh(self) -> None:
    """Refreshes the layer color data."""
    if not self.refresh_on_call and self._data:
        return
    self._data = george.tv_layer_color_get_color(self._clip.id, self._index)

name(value: str) -> None

Set the name of the color.

Source code in pytvpaint/layer.py
270
271
272
273
274
275
@name.setter
def name(self, value: str) -> None:
    """Set the name of the color."""
    clip_layer_color_names = (color.name for color in self.clip.layer_colors)
    value = utils.get_unique_name(clip_layer_color_names, value)
    george.tv_layer_color_set_color(self.clip.id, self.index, self.color, value)

color(value: george.RGBColor) -> None

Set the color value.

Source code in pytvpaint/layer.py
286
287
288
289
@color.setter
def color(self, value: george.RGBColor) -> None:
    """Set the color value."""
    george.tv_layer_color_set_color(self.clip.id, self.index, value)

lock_layers(lock: bool) -> None

Lock or unlock all layers with this color.

Source code in pytvpaint/layer.py
297
298
299
300
301
302
303
def lock_layers(self, lock: bool) -> None:
    """Lock or unlock all layers with this color."""
    self.clip.make_current()
    if lock:
        george.tv_layer_color_lock(self.index)
    else:
        george.tv_layer_color_unlock(self.index)

show_layers(show: bool, mode: george.LayerColorDisplayOpt = george.LayerColorDisplayOpt.DISPLAY) -> None

Show or hide layers with this color.

Parameters:

Name Type Description Default
show bool

whether to show the layers using this color or not

required
mode pytvpaint.george.LayerColorDisplayOpt

the display mode. Defaults to george.LayerColorDisplayOpt.DISPLAY.

pytvpaint.george.LayerColorDisplayOpt.DISPLAY
Source code in pytvpaint/layer.py
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
def show_layers(
    self,
    show: bool,
    mode: george.LayerColorDisplayOpt = george.LayerColorDisplayOpt.DISPLAY,
) -> None:
    """Show or hide layers with this color.

    Args:
        show: whether to show the layers using this color or not
        mode: the display mode. Defaults to george.LayerColorDisplayOpt.DISPLAY.
    """
    self.clip.make_current()
    if show:
        george.tv_layer_color_show(mode, self.index)
    else:
        george.tv_layer_color_hide(mode, self.index)

select_layers(select: bool) -> None

Select or unselect layers with this color.

Source code in pytvpaint/layer.py
322
323
324
325
326
327
328
def select_layers(self, select: bool) -> None:
    """Select or unselect layers with this color."""
    self.clip.make_current()
    if select:
        george.tv_layer_color_select(self.index)
    else:
        george.tv_layer_color_unselect(self.index)