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
219
220
221
222
223
224
225
226
227
228
229
230
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_on_call = True instance-attribute

refresh() -> None

Refreshes the layer color data.

Source code in pytvpaint\layer.py
232
233
234
235
236
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
263
264
265
266
267
268
269
@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 if color != self)
    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
280
281
282
283
@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
291
292
293
294
295
296
297
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
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
316
317
318
319
320
321
322
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)