Skip to content

Miscellaneous George functions

All George values as enum and functions which are not specific to any TVPaint element.

T = TypeVar('T', bound=(Callable[..., Any])) module-attribute

Entry: TypeAlias = 'str | tuple[str, list[Entry]]' module-attribute

GrgErrorValue

Common George error values.

Attributes:

Name Type Description
EMPTY str

See tv_clipinfo for example

NONE str

See tv_clipenumid for example

ERROR str

See tv_setapen for example

EMPTY = '' class-attribute instance-attribute

NONE = 'none' class-attribute instance-attribute

ERROR = 'error' class-attribute instance-attribute

GrgBoolState

Bases: enum.Enum

George booleans.

Attributes:

Name Type Description
ON
OFF

ON = 'on' class-attribute instance-attribute

OFF = 'off' class-attribute instance-attribute

FieldOrder

Bases: enum.Enum

Field order of the camera.

Attributes:

Name Type Description
NONE
LOWER
UPPER

NONE = 'none' class-attribute instance-attribute

LOWER = 'lower' class-attribute instance-attribute

UPPER = 'upper' class-attribute instance-attribute

MarkType

Bases: enum.Enum

The mark command.

Attributes:

Name Type Description
MARKIN
MARKOUT

MARKIN = 'tv_markin' class-attribute instance-attribute

MARKOUT = 'tv_markout' class-attribute instance-attribute

MarkReference

Bases: enum.Enum

The object to mark.

Attributes:

Name Type Description
PROJECT
CLIP

PROJECT = 'project' class-attribute instance-attribute

CLIP = 'clip' class-attribute instance-attribute

MarkAction

Bases: enum.Enum

The mark action.

Attributes:

Name Type Description
SET
CLEAR

SET = 'set' class-attribute instance-attribute

CLEAR = 'clear' class-attribute instance-attribute

RectButton

Bases: enum.Enum

The rect button when drawing.

Attributes:

Name Type Description
LEFT
RIGHT

LEFT = 0 class-attribute instance-attribute

RIGHT = 1 class-attribute instance-attribute

TVPShape

Bases: enum.Enum

The shape tools.

Attributes:

Name Type Description
B_SPLINE
BEZIER
BEZIER_FILL
CAMERA
CIRCLE
CIRCLE_2PTS
CIRCLE_3PTS
CIRCLE_FILL
CIRCLE_2PTS_FILL
CIRCLE_3PTS_FILL
CROP
CUT_RECT
CUT_POLY
CUT_FREE_HAND
CUT_FLOOD
DOT
FLOOD
FREE_HAND_LINE
FREE_HAND_FILL
ELLIPSE
ELLIPSE_FILL
ELLIPSE_2PTS
ELLIPSE_2PTS_FILL
LINE
LINE_FILL
PLANNING
POSITION
RECTANGLE
RECTANGLE_FILL
SELECT_RECTANGLE
SELECT_ELLIPSE
SELECT_2PTS
SELECT_3PTS
SELECT_POLY
SELECT_FREE_HAND
SELECT_FLOOD
SELECT_COLOR
SELECT_BEZIER
SELECT_B_SPLINE
SINGLE_DOT
SPLIT_3PTS
SPLINE_FILL
WARP
WRAP
ZOOM_IN
ZOOM_OUT
ZOOM_HAND
ZOOM_RECT

B_SPLINE = 'bspline' class-attribute instance-attribute

BEZIER = 'bezier' class-attribute instance-attribute

BEZIER_FILL = 'bezierfill' class-attribute instance-attribute

CAMERA = 'camera' class-attribute instance-attribute

CIRCLE = 'circle' class-attribute instance-attribute

CIRCLE_2PTS = 'circle2pts' class-attribute instance-attribute

CIRCLE_3PTS = 'circle3pts' class-attribute instance-attribute

CIRCLE_FILL = 'circlefill' class-attribute instance-attribute

CIRCLE_2PTS_FILL = 'circle2ptsfill' class-attribute instance-attribute

CIRCLE_3PTS_FILL = 'circle3ptsfill' class-attribute instance-attribute

CROP = 'crop' class-attribute instance-attribute

CUT_RECT = 'cutrect' class-attribute instance-attribute

CUT_POLY = 'cutpoly' class-attribute instance-attribute

CUT_FREE_HAND = 'cutfreehand' class-attribute instance-attribute

CUT_FLOOD = 'cutflood' class-attribute instance-attribute

DOT = 'dot' class-attribute instance-attribute

FLOOD = 'flood' class-attribute instance-attribute

FREE_HAND_LINE = 'freehandline' class-attribute instance-attribute

FREE_HAND_FILL = 'freehandfill' class-attribute instance-attribute

ELLIPSE = 'ellipse' class-attribute instance-attribute

ELLIPSE_FILL = 'ellipsefill' class-attribute instance-attribute

ELLIPSE_2PTS = 'ellipse2pts' class-attribute instance-attribute

ELLIPSE_2PTS_FILL = 'ellipse2ptsfill' class-attribute instance-attribute

LINE = 'line' class-attribute instance-attribute

LINE_FILL = 'linefill' class-attribute instance-attribute

PLANNING = 'panning' class-attribute instance-attribute

POSITION = 'position' class-attribute instance-attribute

RECTANGLE = 'rectangle' class-attribute instance-attribute

RECTANGLE_FILL = 'rectanglefill' class-attribute instance-attribute

SELECT_RECTANGLE = 'selectrectangle' class-attribute instance-attribute

SELECT_ELLIPSE = 'selectellipse' class-attribute instance-attribute

SELECT_2PTS = 'select2pts' class-attribute instance-attribute

SELECT_3PTS = 'select3pts' class-attribute instance-attribute

SELECT_POLY = 'selectpoly' class-attribute instance-attribute

SELECT_FREE_HAND = 'selectfreehand' class-attribute instance-attribute

SELECT_FLOOD = 'selectflood' class-attribute instance-attribute

SELECT_COLOR = 'selectcolor' class-attribute instance-attribute

SELECT_BEZIER = 'selectbezier' class-attribute instance-attribute

SELECT_B_SPLINE = 'selectbspline' class-attribute instance-attribute

SINGLE_DOT = 'singledot' class-attribute instance-attribute

SPLIT_3PTS = 'spline3pts' class-attribute instance-attribute

SPLINE_FILL = 'splinefill' class-attribute instance-attribute

WARP = 'warp' class-attribute instance-attribute

WRAP = 'wrap' class-attribute instance-attribute

ZOOM_IN = 'zoomin' class-attribute instance-attribute

ZOOM_OUT = 'zoomout' class-attribute instance-attribute

ZOOM_HAND = 'zoomhand' class-attribute instance-attribute

ZOOM_RECT = 'zoomrect' class-attribute instance-attribute

ResizeOption

Bases: enum.Enum

Resize options for projects.

Attributes:

Name Type Description
EMPTY
CROP
STRETCH

EMPTY = 0 class-attribute instance-attribute

CROP = 1 class-attribute instance-attribute

STRETCH = 2 class-attribute instance-attribute

SpriteLayout

Bases: enum.Enum

Sprite layout when exporting as sprites.

Attributes:

Name Type Description
RECTANGLE
HORIZONTAL
VERTICAL
DIAGONAL
ANTI_DIAGONAL

RECTANGLE = 'rectangle' class-attribute instance-attribute

HORIZONTAL = 'horizontal' class-attribute instance-attribute

VERTICAL = 'vertical' class-attribute instance-attribute

DIAGONAL = 'diagonal' class-attribute instance-attribute

ANTI_DIAGONAL = 'antidiagonal' class-attribute instance-attribute

AlphaMode

Bases: enum.Enum

The alpha load mode.

Attributes:

Name Type Description
PREMULTIPLY
NO_PREMULTIPLY
NO_ALPHA
ALPHA_ONLY
GUESS

PREMULTIPLY = 'premultiply' class-attribute instance-attribute

NO_PREMULTIPLY = 'nopremultiply' class-attribute instance-attribute

NO_ALPHA = 'noalpha' class-attribute instance-attribute

ALPHA_ONLY = 'alphaonly' class-attribute instance-attribute

GUESS = 'guess' class-attribute instance-attribute

AlphaSaveMode

Bases: enum.Enum

The alpha save mode.

Attributes:

Name Type Description
PREMULTIPLY
NO_PREMULTIPLY
NO_ALPHA
ALPHA_ONLY
GUESS
ALPHA_BINARY

PREMULTIPLY = 'premultiply' class-attribute instance-attribute

NO_PREMULTIPLY = 'nopremultiply' class-attribute instance-attribute

NO_ALPHA = 'noalpha' class-attribute instance-attribute

ALPHA_ONLY = 'alphaonly' class-attribute instance-attribute

GUESS = 'guess' class-attribute instance-attribute

ALPHA_BINARY = 'alphabinary' class-attribute instance-attribute

SaveFormat

Bases: enum.Enum

All save formats.

Attributes:

Name Type Description
AVI
BMP
CINEON
DEEP
DPX
FLI
GIF
ILBM
JPG

jpeg

MKV

Mode=1017

MOV

Mode=1015

MP4

Mode=1016

PCX
PDF
PNG
PSD
SGI

Mode=16

SOFTIMAGE

Mode=10

SUNRASTER

sun

TGA

tga

TIFF

Mode=15

VPB
WEBM

Mode=1018

AVI = 'avi' class-attribute instance-attribute

BMP = 'bmp' class-attribute instance-attribute

CINEON = 'cin' class-attribute instance-attribute

DEEP = 'deep' class-attribute instance-attribute

DPX = 'dpx' class-attribute instance-attribute

FLI = 'flc' class-attribute instance-attribute

GIF = 'gif' class-attribute instance-attribute

ILBM = 'ilbm' class-attribute instance-attribute

JPG = 'jpeg' class-attribute instance-attribute

MKV = 'Mode=1017' class-attribute instance-attribute

MOV = 'Mode=1015' class-attribute instance-attribute

MP4 = 'Mode=1016' class-attribute instance-attribute

PCX = 'pcx' class-attribute instance-attribute

PDF = 'pdf' class-attribute instance-attribute

PNG = 'png' class-attribute instance-attribute

PSD = 'psd' class-attribute instance-attribute

SGI = 'Mode=16' class-attribute instance-attribute

SOFTIMAGE = 'Mode=10' class-attribute instance-attribute

SUNRASTER = 'sun' class-attribute instance-attribute

TGA = 'tga' class-attribute instance-attribute

TIFF = 'Mode=15' class-attribute instance-attribute

VPB = 'vpb' class-attribute instance-attribute

WEBM = 'Mode=1018' class-attribute instance-attribute

from_extension(extension: str) -> SaveFormat classmethod

Returns the correct tvpaint format value from a string extension.

Source code in pytvpaint/george/grg_base.py
343
344
345
346
347
348
349
@classmethod
def from_extension(cls, extension: str) -> SaveFormat:
    """Returns the correct tvpaint format value from a string extension."""
    extension = extension.replace(".", "").upper()
    if not hasattr(SaveFormat, extension):
        raise ValueError(f"Could not find format ({extension}) in accepted formats ({SaveFormat})")
    return cast(SaveFormat, getattr(cls, extension.upper()))

to_extension(save_format: SaveFormat) -> str classmethod

Returns the typical tvpaint file extension for the provided format.

Source code in pytvpaint/george/grg_base.py
351
352
353
354
355
356
357
358
359
360
361
362
363
364
@classmethod
def to_extension(cls, save_format: SaveFormat) -> str:
    """Returns the typical tvpaint file extension for the provided format."""
    image_formats = {
        SaveFormat.JPG: "jpg",
        SaveFormat.MKV: "mkv",
        SaveFormat.MOV: "mov",
        SaveFormat.MP4: "mp4",
        SaveFormat.SGI: "sgi",
        SaveFormat.SOFTIMAGE: "pic",
        SaveFormat.TIFF: "tiff",
        SaveFormat.WEBM: "webm",
    }
    return f".{image_formats.get(save_format, save_format.value)}"

is_image(extension: str) -> bool classmethod

Returns True if the extension correspond to an image format.

Source code in pytvpaint/george/grg_base.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
@classmethod
def is_image(cls, extension: str) -> bool:
    """Returns True if the extension correspond to an image format."""
    extension = extension.replace(".", "").lower()
    image_formats = [
        "bmp",
        "cin",
        "deep",
        "dpx",
        "ilbm",
        "jpg",
        "jpeg",
        "pcx",
        "png",
        "psd",
        "sgi",
        "pic",
        "ras",
        "sun",
        "tga",
        "tiff",
    ]
    return extension in image_formats

RGBColor(r: int, g: int, b: int) dataclass

RGB color with 0-255 range values.

r: int instance-attribute

g: int instance-attribute

b: int instance-attribute

RGBAColor(r: int, g: int, b: int, a: int) dataclass

Bases: pytvpaint.george.grg_base.RGBColor

RGBA color with 0-255 range values.

a: int instance-attribute

r: int instance-attribute

g: int instance-attribute

b: int instance-attribute

HSLColor(h: int, s: int, l: int) dataclass

HSL color. Maximum values are (360, 100, 100) for h, s, l.

h: int instance-attribute

s: int instance-attribute

l: int instance-attribute

BlendingMode

Bases: enum.Enum

All the blending modes.

Attributes:

Name Type Description
COLOR
BEHIND
ERASE
SHADE
LIGHT
COLORIZE
HUE
SATURATION
VALUE
ADD
SUB
MULTIPLY
SCREEN
REPLACE
COPY
DIFFERENCE
DIVIDE
OVERLAY
OVERLAY2
LIGHT2
SHADE2
HARDLIGHT
SOFTLIGHT
GRAIN_EXTRACT
GRAIN_MERGE
SUB2
DARKEN
LIGHTEN

COLOR = 'color' class-attribute instance-attribute

BEHIND = 'behind' class-attribute instance-attribute

ERASE = 'erase' class-attribute instance-attribute

SHADE = 'shade' class-attribute instance-attribute

LIGHT = 'light' class-attribute instance-attribute

COLORIZE = 'colorize' class-attribute instance-attribute

HUE = 'hue' class-attribute instance-attribute

SATURATION = 'saturation' class-attribute instance-attribute

VALUE = 'value' class-attribute instance-attribute

ADD = 'add' class-attribute instance-attribute

SUB = 'sub' class-attribute instance-attribute

MULTIPLY = 'multiply' class-attribute instance-attribute

SCREEN = 'screen' class-attribute instance-attribute

REPLACE = 'replace' class-attribute instance-attribute

COPY = 'copy' class-attribute instance-attribute

DIFFERENCE = 'difference' class-attribute instance-attribute

DIVIDE = 'divide' class-attribute instance-attribute

OVERLAY = 'overlay' class-attribute instance-attribute

OVERLAY2 = 'overlay2' class-attribute instance-attribute

LIGHT2 = 'light2' class-attribute instance-attribute

SHADE2 = 'shade2' class-attribute instance-attribute

HARDLIGHT = 'hardlight' class-attribute instance-attribute

SOFTLIGHT = 'softlight' class-attribute instance-attribute

GRAIN_EXTRACT = 'grainextract' class-attribute instance-attribute

GRAIN_MERGE = 'grainmerge' class-attribute instance-attribute

SUB2 = 'sub2' class-attribute instance-attribute

DARKEN = 'darken' class-attribute instance-attribute

LIGHTEN = 'lighten' class-attribute instance-attribute

DrawingMode

Bases: enum.Enum

All the drawing modes.

Attributes:

Name Type Description
COLOR
BEHIND
ERASE
PANTO
MERGE
SHADE
LIGHT
COLORIZE
TINT
GRAIN
BLUR
NOISE
NEGATIVE
SHARP
EMBOSS
SOLARIZE
SATURATE
UNSATURATE
ADD
SUB
MULTIPLY
SCREEN
DIFF
HEALING
BURN
DODGE
DARKEN
LIGHTEN

COLOR = 'color' class-attribute instance-attribute

BEHIND = 'behind' class-attribute instance-attribute

ERASE = 'erase' class-attribute instance-attribute

PANTO = 'panto' class-attribute instance-attribute

MERGE = 'merge' class-attribute instance-attribute

SHADE = 'shade' class-attribute instance-attribute

LIGHT = 'light' class-attribute instance-attribute

COLORIZE = 'colorize' class-attribute instance-attribute

TINT = 'tint' class-attribute instance-attribute

GRAIN = 'grain' class-attribute instance-attribute

BLUR = 'blur' class-attribute instance-attribute

NOISE = 'noise' class-attribute instance-attribute

NEGATIVE = 'negative' class-attribute instance-attribute

SHARP = 'sharp' class-attribute instance-attribute

EMBOSS = 'emboss' class-attribute instance-attribute

SOLARIZE = 'solarize' class-attribute instance-attribute

SATURATE = 'saturate' class-attribute instance-attribute

UNSATURATE = 'unsaturate' class-attribute instance-attribute

ADD = 'add' class-attribute instance-attribute

SUB = 'sub' class-attribute instance-attribute

MULTIPLY = 'multiply' class-attribute instance-attribute

SCREEN = 'screen' class-attribute instance-attribute

DIFF = 'diff' class-attribute instance-attribute

HEALING = 'healing' class-attribute instance-attribute

BURN = 'burn' class-attribute instance-attribute

DODGE = 'dodge' class-attribute instance-attribute

DARKEN = 'darken' class-attribute instance-attribute

LIGHTEN = 'lighten' class-attribute instance-attribute

MenuElement

Bases: enum.Enum

All the TVPaint menu elements.

Attributes:

Name Type Description
SHOW_UI
HIDE_UI
RESIZE_UI
CENTER_DISPLAY
FIT_DISPLAY
FRONT
BACK
ASPECT_RATIO
CLIP
PROJECT
XSHEET
NOTES

SHOW_UI = 'showui' class-attribute instance-attribute

HIDE_UI = 'hideui' class-attribute instance-attribute

RESIZE_UI = 'resizeui' class-attribute instance-attribute

CENTER_DISPLAY = 'centerdisplay' class-attribute instance-attribute

FIT_DISPLAY = 'fitdisplay' class-attribute instance-attribute

FRONT = 'front' class-attribute instance-attribute

BACK = 'back' class-attribute instance-attribute

ASPECT_RATIO = 'aspectratio' class-attribute instance-attribute

CLIP = 'clip' class-attribute instance-attribute

PROJECT = 'project' class-attribute instance-attribute

XSHEET = 'xsheet' class-attribute instance-attribute

NOTES = 'notes' class-attribute instance-attribute

FileMode

Bases: enum.Enum

File mode save or load.

Attributes:

Name Type Description
SAVE
LOAD

SAVE = '<' class-attribute instance-attribute

LOAD = '>' class-attribute instance-attribute

TVPPenBrush(mode: DrawingMode, size: float, power: int, opacity: int, dry: bool, anti_aliasing: bool, gradient: bool, c_size: str, c_power: str) dataclass

A TVPaint brush.

mode: DrawingMode instance-attribute

size: float instance-attribute

power: int instance-attribute

opacity: int instance-attribute

dry: bool instance-attribute

anti_aliasing: bool = field(metadata={'alt_name': 'aaliasing'}) class-attribute instance-attribute

gradient: bool instance-attribute

c_size: str instance-attribute

c_power: str instance-attribute

TVPSound(offset: float, volume: float, mute: bool, fade_in_start: float, fade_in_stop: float, fade_out_start: float, fade_out_stop: float, path: Path, sound_in: float, sound_out: float, color_index: int) dataclass

A TVPaint sound (clip and project).

offset: float instance-attribute

volume: float instance-attribute

mute: bool instance-attribute

fade_in_start: float instance-attribute

fade_in_stop: float instance-attribute

fade_out_start: float instance-attribute

fade_out_stop: float instance-attribute

path: Path instance-attribute

sound_in: float instance-attribute

sound_out: float instance-attribute

color_index: int instance-attribute

undoable(func: T) -> T

Decorator to register actions in the TVPaint undo stack.

Source code in pytvpaint/george/grg_base.py
623
624
625
626
627
628
629
630
631
632
def undoable(func: T) -> T:
    """Decorator to register actions in the TVPaint undo stack."""

    def wrapper(*args: Any, **kwargs: Any) -> T:
        tv_undo_open_stack()
        res = func(*args, **kwargs)
        tv_undo_close_stack(func.__name__)
        return cast(T, res)

    return cast(T, wrapper)

undoable_stack() -> Generator[None, None, None]

Context manager that creates an undo stack. Useful to undo a sequence of George actions.

Source code in pytvpaint/george/grg_base.py
635
636
637
638
639
640
@contextlib.contextmanager
def undoable_stack() -> Generator[None, None, None]:
    """Context manager that creates an undo stack. Useful to undo a sequence of George actions."""
    tv_undo_open_stack()
    yield
    tv_undo_close_stack()

tv_warn(msg: str) -> None

Display a warning message.

Source code in pytvpaint/george/grg_base.py
643
644
645
def tv_warn(msg: str) -> None:
    """Display a warning message."""
    send_cmd("tv_Warn", msg)

tv_version() -> tuple[str, str, str]

Returns TVPaint version and language info.

Returns:

Name Type Description
software_name str

software full name (ex: TVPaint Animation 12.0.0 Pro)

tvp_version str

version number (ex: 12.0.0)

language str

language (ex: fr, en, etc...)

Source code in pytvpaint/george/grg_base.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def tv_version() -> tuple[str, str, str]:
    """Returns TVPaint version and language info.

    Returns:
        software_name (str): software full name (ex: TVPaint Animation 12.0.0 Pro)
        tvp_version (str): version number (ex: 12.0.0)
        language (str): language (ex: fr, en, etc...)
    """
    cmd_fields: FieldTypes = [
        ("software_name", str),
        ("version", str),
        ("language", str),
    ]
    res = tv_parse_list(send_cmd("tv_Version"), with_fields=cmd_fields)
    software_name, tvp_version, language = res.values()
    return software_name, tvp_version, language

is_tvp_version_below_12() -> bool

Helper function to check if the connected tvpaint instance version is below v12.

Source code in pytvpaint/george/grg_base.py
666
667
668
669
def is_tvp_version_below_12() -> bool:
    """Helper function to check if the connected tvpaint instance version is below v12."""
    _, tvp_version, _ = tv_version()
    return version.parse(tvp_version).major < 12

min_version_compatible(min_version: str) -> Callable[[T], T]

Decorator to apply on methods.

Given a minimum version, checks if the current tvpaint version is above the minimum requirement otherwise it raises a NotImplemented error

Parameters:

Name Type Description Default
min_version str

minimum version required to run this version

required

Returns:

Type Description
typing.Callable[[pytvpaint.george.grg_base.T], pytvpaint.george.grg_base.T]

the decorated function

Source code in pytvpaint/george/grg_base.py
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
def min_version_compatible(min_version: str) -> Callable[[T], T]:
    """Decorator to apply on methods.

    Given a minimum version, checks if the current tvpaint version is above the minimum requirement otherwise it
    raises a NotImplemented error

    Args:
        min_version (str): minimum version required to run this version

    Returns:
        the decorated function
    """

    def decorate(func: T) -> T:
        @functools.wraps(func)
        def applicator(*args: Any, **kwargs: Any) -> Any:
            _, tvp_version, _ = tv_version()
            current_version = version.parse(tvp_version)
            min_version_parse = version.parse(min_version)

            if current_version < min_version_parse:
                msg = f"This function is only available in TVPaint version ({min_version}) and above."
                raise NotImplementedError(msg)

            return func(*args, **kwargs)

        return cast(T, applicator)

    return decorate

deprecated_warning(msg: str) -> Callable[[T], T]

Decorator to apply on methods.

Prints a deprecation message/warning when decorated function is called

Parameters:

Name Type Description Default
msg str

deprecation message

required

Returns:

Type Description
typing.Callable[[pytvpaint.george.grg_base.T], pytvpaint.george.grg_base.T]

the decorated function

Source code in pytvpaint/george/grg_base.py
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
def deprecated_warning(msg: str) -> Callable[[T], T]:
    """Decorator to apply on methods.

    Prints a deprecation message/warning when decorated function is called

    Args:
        msg (str): deprecation message

    Returns:
        the decorated function
    """

    def decorate(func: T) -> T:
        @functools.wraps(func)
        def applicator(*args: Any, **kwargs: Any) -> Any:
            warnings.warn(msg, DeprecationWarning)
            log.warning(f"DEPRECTED: {msg}")
            return func(*args, **kwargs)

        return cast(T, applicator)

    return decorate

tv_quit() -> None

Closes the TVPaint instance.

Source code in pytvpaint/george/grg_base.py
727
728
729
def tv_quit() -> None:
    """Closes the TVPaint instance."""
    send_cmd("tv_Quit")

tv_host2back() -> None

Minimize the TVPaint window.

Source code in pytvpaint/george/grg_base.py
732
733
734
def tv_host2back() -> None:
    """Minimize the TVPaint window."""
    send_cmd("tv_Host2Back")

tv_host2front() -> None

Restore the TVPaint window after being minimized.

Source code in pytvpaint/george/grg_base.py
737
738
739
def tv_host2front() -> None:
    """Restore the TVPaint window after being minimized."""
    send_cmd("tv_Host2Front")

tv_menu_hide() -> None

Switch to inlay view and hide all non-docking panels.

Source code in pytvpaint/george/grg_base.py
742
743
744
def tv_menu_hide() -> None:
    """Switch to inlay view and hide all non-docking panels."""
    send_cmd("tv_MenuHide")

tv_menu_show(menu_element: MenuElement | None = None, *menu_options: Any, current: bool = False) -> None

For the complete documentation, see: https://www.tvpaint.com/doc/tvpaint-animation-11/george-commands#tv_menushow.

Source code in pytvpaint/george/grg_base.py
747
748
749
750
751
752
753
754
755
756
757
def tv_menu_show(menu_element: MenuElement | None = None, *menu_options: Any, current: bool = False) -> None:
    """For the complete documentation, see: https://www.tvpaint.com/doc/tvpaint-animation-11/george-commands#tv_menushow."""
    cmd_args: list[str] = []

    if current:
        cmd_args.append("current")

    if menu_element:
        cmd_args.append(menu_element.value)

    send_cmd("tv_MenuShow", *cmd_args, *menu_options)

add_some_magic(i_am_a_badass: bool = False, magic_number: int | None = None) -> None

Don't use this function ! It just might change your life forever !

Source code in pytvpaint/george/grg_base.py
760
761
762
763
764
765
766
767
def add_some_magic(i_am_a_badass: bool = False, magic_number: int | None = None) -> None:
    """Don't use this function ! It just might change your life forever !"""
    if not i_am_a_badass:
        log.warning("Sorry, you're not enough of a badass for this function !")

    magic_number = magic_number if magic_number is not None else 14
    send_cmd("tv_MagicNumber", magic_number)
    log.info("Totally worth it, right ?! ^^")

tv_request(msg: str, confirm_text: str = 'Yes', cancel_text: str = 'No') -> bool

Open a confirmation prompt with a message.

Parameters:

Name Type Description Default
msg str

the message to display

required
confirm_text str

the confirm button text. Defaults to "Yes".

'Yes'
cancel_text str

the cancel button text. Defaults to "No".

'No'

Returns:

Name Type Description
bool bool

True if clicked on "Yes"

Source code in pytvpaint/george/grg_base.py
770
771
772
773
774
775
776
777
778
779
780
781
def tv_request(msg: str, confirm_text: str = "Yes", cancel_text: str = "No") -> bool:
    """Open a confirmation prompt with a message.

    Args:
        msg: the message to display
        confirm_text: the confirm button text. Defaults to "Yes".
        cancel_text: the cancel button text. Defaults to "No".

    Returns:
        bool: True if clicked on "Yes"
    """
    return bool(int(send_cmd("tv_Request", msg, confirm_text, cancel_text)))

tv_req_num(value: int, min: int, max: int, title: str = 'Enter Value') -> int | None

Open a prompt to request an integer (within a range).

Parameters:

Name Type Description Default
value int

the initial value

required
min int

the minimum value

required
max int

the maximum value

required
title str

title of the prompt dialog. Defaults to "Enter Value".

'Enter Value'

Returns:

Type Description
int | None

the value or None if cancelled

Source code in pytvpaint/george/grg_base.py
784
785
786
787
788
789
790
791
792
793
794
795
796
797
def tv_req_num(value: int, min: int, max: int, title: str = "Enter Value") -> int | None:
    """Open a prompt to request an integer (within a range).

    Args:
        value: the initial value
        min: the minimum value
        max: the maximum value
        title: title of the prompt dialog. Defaults to "Enter Value".

    Returns:
        the value or None if cancelled
    """
    res = send_cmd("tv_ReqNum", value, min, max, title, handle_string=False)
    return None if res.lower() == "cancel" else int(res)

tv_req_angle(value: float, min: float, max: float, title: str = 'Enter Value') -> float | None

Open a prompt to request an angle (in degree).

Parameters:

Name Type Description Default
value float

the initial value

required
min float

the minimum value

required
max float

the maximum value

required
title str

title of the prompt. Defaults to "Enter Value".

'Enter Value'

Returns:

Type Description
float | None

the value or None if cancelled

Source code in pytvpaint/george/grg_base.py
800
801
802
803
804
805
806
807
808
809
810
811
812
813
def tv_req_angle(value: float, min: float, max: float, title: str = "Enter Value") -> float | None:
    """Open a prompt to request an angle (in degree).

    Args:
        value: the initial value
        min: the minimum value
        max: the maximum value
        title: title of the prompt. Defaults to "Enter Value".

    Returns:
        the value or None if cancelled
    """
    res = send_cmd("tv_ReqAngle", value, min, max, title, handle_string=False)
    return None if res.lower() == "cancel" else float(res)

tv_req_float(value: float, min: float, max: float, title: str = 'Enter value') -> float | None

Open a prompt to request a float.

Parameters:

Name Type Description Default
value float

the initial value

required
min float

the minimum value

required
max float

the maximum value

required
title str

title of the prompt. Defaults to "Enter Value".

'Enter value'

Returns:

Type Description
float | None

the value or None if cancelled

Source code in pytvpaint/george/grg_base.py
816
817
818
819
820
821
822
823
824
825
826
827
828
829
def tv_req_float(value: float, min: float, max: float, title: str = "Enter value") -> float | None:
    """Open a prompt to request a float.

    Args:
        value: the initial value
        min: the minimum value
        max: the maximum value
        title: title of the prompt. Defaults to "Enter Value".

    Returns:
        the value or None if cancelled
    """
    res = send_cmd("tv_ReqFloat", value, min, max, title, handle_string=False)
    return None if res.lower() == "cancel" else float(res)

tv_req_string(title: str, text: str) -> str | None

Open a prompt to request a string.

Parameters:

Name Type Description Default
title str

title of the requester. Defaults to "Enter Value".

required
text str

the initial value

required

Returns:

Type Description
str | None

the value or None if cancelled

Source code in pytvpaint/george/grg_base.py
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
def tv_req_string(title: str, text: str) -> str | None:
    """Open a prompt to request a string.

    Args:
        title: title of the requester. Defaults to "Enter Value".
        text: the initial value

    Returns:
        the value or None if cancelled
    """
    cmd_args = ["|".join([title, text])]
    if "\n" in text:
        cmd_args.insert(0, "multiline")
    res = send_cmd("tv_ReqString", *cmd_args, handle_string=False)
    return None if res.lower() == "cancel" else res

tv_list_request(entries: list[Entry]) -> tuple[int, str]

Open a prompt to request a selection in a list.

Parameters:

Name Type Description Default
entries list[pytvpaint.george.grg_base.Entry]

the list of entries (either a single entry or sub entries)

required

Returns:

Type Description
tuple[int, str]

the position, the entry

Source code in pytvpaint/george/grg_base.py
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
def tv_list_request(entries: list[Entry]) -> tuple[int, str]:
    """Open a prompt to request a selection in a list.

    Args:
        entries: the list of entries (either a single entry or sub entries)

    Returns:
        the position, the entry
    """
    entries_str = "|".join(map(_entry_to_str, entries))
    res = send_cmd("tv_ListRequest", entries_str, error_values=["-1 Cancel"])
    res_obj = tv_parse_list(
        res,
        with_fields=[
            ("index", int),
            ("entry", str),
        ],
    )
    index, entry = tuple(res_obj.values())
    return int(index), entry

tv_req_file(mode: FileMode, title: str = '', working_dir: Path | str | None = None, default_name: str | None = None, extension_filter: str | None = None) -> Path | None

Open a prompt to request a file.

Parameters:

Name Type Description Default
mode pytvpaint.george.grg_base.FileMode

save or load

required
title str

the title of the request

''
working_dir pathlib.Path | str | None

the default folder to go. Defaults to None.

None
default_name str | None

the default name. Defaults to None.

None
extension_filter str | None

display the files with this extension. Defaults to None.

None

Returns:

Type Description
pathlib.Path | None

the choosen path or None if cancelled

Source code in pytvpaint/george/grg_base.py
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
def tv_req_file(
    mode: FileMode,
    title: str = "",
    working_dir: Path | str | None = None,
    default_name: str | None = None,
    extension_filter: str | None = None,
) -> Path | None:
    """Open a prompt to request a file.

    Args:
        mode: save or load
        title: the title of the request
        working_dir: the default folder to go. Defaults to None.
        default_name: the default name. Defaults to None.
        extension_filter: display the files with this extension. Defaults to None.

    Returns:
        the choosen path or None if cancelled
    """
    cmd_args = [
        title,
        Path(working_dir).as_posix() if working_dir else None,
        default_name,
        extension_filter,
    ]

    arg_str = "|".join([v if v is not None else "" for v in cmd_args])
    res = send_cmd("tv_ReqFile", f"{mode.value} {arg_str}", handle_string=False)

    return None if res.lower() == "cancel" else Path(res)

tv_undo() -> None

Do an undo.

Source code in pytvpaint/george/grg_base.py
915
916
917
def tv_undo() -> None:
    """Do an undo."""
    send_cmd("tv_Undo")

tv_update_undo() -> None

Copies the contents of the current image in the current layer into the buffer undo memory.

None of the draw commands described in this section updates this buffer memory. If you click on the Undo button after executing a George program, everything that the program has drawn in your image will be deleted. With this function you can update the undo buffer memory whenever you wish (for example at the beginning of the program).

Source code in pytvpaint/george/grg_base.py
920
921
922
923
924
925
926
927
def tv_update_undo() -> None:
    """Copies the contents of the current image in the current layer into the buffer undo memory.

    None of the draw commands described in this section updates this buffer memory.
    If you click on the Undo button after executing a George program, everything that the program has drawn in your image will be deleted.
    With this function you can update the undo buffer memory whenever you wish (for example at the beginning of the program).
    """
    send_cmd("tv_UpdateUndo")

tv_undo_open_stack() -> None

Open an 'undo' stack.

Surround a piece of code with tv_undoopenstack ... tv_undoclosestack, then multiple undo will be added to this stack, and closing this stack will undo everything inside. (To be sure the script returns to the expected result use tv_updateundo before tv_undoopenstack)

Source code in pytvpaint/george/grg_base.py
930
931
932
933
934
935
936
def tv_undo_open_stack() -> None:
    """Open an 'undo' stack.

    Surround a piece of code with tv_undoopenstack ... tv_undoclosestack, then multiple undo will be added to this stack, and closing this stack will undo everything inside.
    (To be sure the script returns to the expected result use tv_updateundo before tv_undoopenstack)
    """
    send_cmd("tv_UndoOpenStack")

tv_undo_close_stack(name: str = '') -> None

Close an 'undo' stack (See tv_undo_open_stack).

Source code in pytvpaint/george/grg_base.py
939
940
941
def tv_undo_close_stack(name: str = "") -> None:
    """Close an 'undo' stack (See tv_undo_open_stack)."""
    send_cmd("tv_UndoCloseStack", name)

tv_save_mode_get() -> tuple[SaveFormat, list[str]]

Get the saving alpha mode.

Source code in pytvpaint/george/grg_base.py
944
945
946
947
948
949
def tv_save_mode_get() -> tuple[SaveFormat, list[str]]:
    """Get the saving alpha mode."""
    res = send_cmd("tv_SaveMode")
    res_split = res.split()
    save_format = tv_cast_to_type(res_split.pop(0), SaveFormat)
    return save_format, res_split

tv_save_mode_set(save_format: SaveFormat, *format_options: str | int | float) -> None

Set the saving alpha mode.

Source code in pytvpaint/george/grg_base.py
952
953
954
def tv_save_mode_set(save_format: SaveFormat, *format_options: str | int | float) -> None:
    """Set the saving alpha mode."""
    send_cmd("tv_SaveMode", save_format.value, *format_options)

tv_alpha_load_mode_get() -> AlphaMode

Set the loading alpha mode.

Source code in pytvpaint/george/grg_base.py
957
958
959
960
def tv_alpha_load_mode_get() -> AlphaMode:
    """Set the loading alpha mode."""
    res = send_cmd("tv_AlphaLoadMode")
    return tv_cast_to_type(res, AlphaMode)

tv_alpha_load_mode_set(mode: AlphaMode) -> None

Get the loading alpha mode.

Source code in pytvpaint/george/grg_base.py
963
964
965
def tv_alpha_load_mode_set(mode: AlphaMode) -> None:
    """Get the loading alpha mode."""
    send_cmd("tv_AlphaLoadMode", mode.value)

tv_alpha_save_mode_get() -> AlphaSaveMode

Get the saving alpha mode.

Source code in pytvpaint/george/grg_base.py
968
969
970
971
def tv_alpha_save_mode_get() -> AlphaSaveMode:
    """Get the saving alpha mode."""
    res = send_cmd("tv_AlphaSaveMode")
    return tv_cast_to_type(res, AlphaSaveMode)

tv_alpha_save_mode_set(mode: AlphaSaveMode) -> None

Set the saving alpha mode.

Source code in pytvpaint/george/grg_base.py
974
975
976
def tv_alpha_save_mode_set(mode: AlphaSaveMode) -> None:
    """Set the saving alpha mode."""
    send_cmd("tv_AlphaSaveMode", mode.value)

tv_mark_in_get(reference: MarkReference) -> tuple[int, MarkAction]

Get markin of the project / clip.

Source code in pytvpaint/george/grg_base.py
979
980
981
982
983
def tv_mark_in_get(
    reference: MarkReference,
) -> tuple[int, MarkAction]:
    """Get markin of the project / clip."""
    return _tv_mark(MarkType.MARKIN, reference)

tv_mark_in_set(reference: MarkReference, frame: int | None, action: MarkAction) -> tuple[int, MarkAction]

Set markin of the project / clip.

Source code in pytvpaint/george/grg_base.py
986
987
988
989
990
991
992
def tv_mark_in_set(
    reference: MarkReference,
    frame: int | None,
    action: MarkAction,
) -> tuple[int, MarkAction]:
    """Set markin of the project / clip."""
    return _tv_mark(MarkType.MARKIN, reference, frame, action)

tv_mark_out_get(reference: MarkReference) -> tuple[int, MarkAction]

Get markout of the project / clip.

Source code in pytvpaint/george/grg_base.py
995
996
997
998
999
def tv_mark_out_get(
    reference: MarkReference,
) -> tuple[int, MarkAction]:
    """Get markout of the project / clip."""
    return _tv_mark(MarkType.MARKOUT, reference)

tv_mark_out_set(reference: MarkReference, frame: int | None, action: MarkAction) -> tuple[int, MarkAction]

Set markout of the project / clip.

Source code in pytvpaint/george/grg_base.py
1002
1003
1004
def tv_mark_out_set(reference: MarkReference, frame: int | None, action: MarkAction) -> tuple[int, MarkAction]:
    """Set markout of the project / clip."""
    return _tv_mark(MarkType.MARKOUT, reference, frame, action)

tv_get_active_shape() -> TVPShape

Get the current shape.

Source code in pytvpaint/george/grg_base.py
1041
1042
1043
def tv_get_active_shape() -> TVPShape:
    """Get the current shape."""
    return tv_cast_to_type(send_cmd("tv_GetActiveShape"), TVPShape)

tv_set_active_shape(shape: TVPShape, **shape_kwargs: Any) -> None

Set the current shape and its tool parameters.

Parameters:

Name Type Description Default
shape pytvpaint.george.grg_base.TVPShape

the shape to set

required
**shape_kwargs typing.Any

the shape specific parameters as keyword arguments

{}
Source code in pytvpaint/george/grg_base.py
1046
1047
1048
1049
1050
1051
1052
1053
def tv_set_active_shape(shape: TVPShape, **shape_kwargs: Any) -> None:
    """Set the current shape and its tool parameters.

    Args:
        shape: the shape to set
        **shape_kwargs: the shape specific parameters as keyword arguments
    """
    send_cmd("tv_SetActiveShape", shape.value, *args_dict_to_list(shape_kwargs))

tv_set_a_pen_rgba(color: RGBColor, alpha: int | None = None) -> RGBColor

Set the APen RGBA color.

Source code in pytvpaint/george/grg_base.py
1101
1102
1103
def tv_set_a_pen_rgba(color: RGBColor, alpha: int | None = None) -> RGBColor:
    """Set the APen RGBA color."""
    return _tv_set_ab_pen("a", color.r, color.g, color.b, "rgb", a=alpha)

tv_set_a_pen_hsl(color: HSLColor) -> HSLColor

Set the A Pen HSL color.

Source code in pytvpaint/george/grg_base.py
1106
1107
1108
def tv_set_a_pen_hsl(color: HSLColor) -> HSLColor:
    """Set the A Pen HSL color."""
    return _tv_set_ab_pen("a", color.h, color.s, color.l, color_format="hsl")

tv_set_b_pen_rgba(color: RGBColor, alpha: int | None = None) -> RGBColor

Set the B Pen RGBA color.

Source code in pytvpaint/george/grg_base.py
1111
1112
1113
def tv_set_b_pen_rgba(color: RGBColor, alpha: int | None = None) -> RGBColor:
    """Set the B Pen RGBA color."""
    return _tv_set_ab_pen("b", color.r, color.g, color.b, color_format="rgb", a=alpha)

tv_set_b_pen_hsl(color: HSLColor) -> HSLColor

Set the B Pen HSL color.

Source code in pytvpaint/george/grg_base.py
1116
1117
1118
def tv_set_b_pen_hsl(color: HSLColor) -> HSLColor:
    """Set the B Pen HSL color."""
    return _tv_set_ab_pen("b", color.h, color.s, color.l, color_format="hsl")

tv_pen(size: float) -> float

Change current pen tool size.

Warning

DEPRECATED: Function tv_pen is deprecated, We advise using tv_penbrush instead.

Source code in pytvpaint/george/grg_base.py
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
@deprecated_warning(
    msg="Function `tv_pen` is most likely deprecated, it is undocumented in the George reference but still "
    "works. We advise using `tv_penbrush` instead."
)
def tv_pen(size: float) -> float:
    """Change current pen tool size.

    Warning:
        DEPRECATED: Function `tv_pen` is deprecated, We advise using `tv_penbrush` instead.
    """
    res: dict[str, Any] = tv_parse_dict(send_cmd("tv_Pen", size), with_fields=[("size", float)])
    return cast(float, res["size"])

tv_pen_brush_get(tool_mode: bool = False) -> TVPPenBrush

Get pen brush parameters.

Source code in pytvpaint/george/grg_base.py
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
def tv_pen_brush_get(tool_mode: bool = False) -> TVPPenBrush:
    """Get pen brush parameters."""
    args = ("toolmode", "backup") if tool_mode else ("backup",)
    result = send_cmd("tv_PenBrush", *args)

    # Remove the first value which is tv_penbrush
    result = result[(len("tv_penbrush") + 1) :]

    res: dict[str, Any] = tv_parse_dict(result, with_fields=TVPPenBrush)
    return TVPPenBrush(**res)

tv_pen_brush_set(mode: DrawingMode | None = None, size: int | None = None, opacity: int | None = None, tool_mode: bool = False, reset: bool = False) -> TVPPenBrush

Manage pen brush.

Source code in pytvpaint/george/grg_base.py
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
def tv_pen_brush_set(
    mode: DrawingMode | None = None,
    size: int | None = None,
    opacity: int | None = None,
    tool_mode: bool = False,
    reset: bool = False,
) -> TVPPenBrush:
    """Manage pen brush."""
    args = {
        "mode": mode.value if mode else None,
        "size": size,
        "opacity": opacity,
    }

    args_list = args_dict_to_list(args)

    if tool_mode:
        args_list.append("toolmode")
    if reset:
        args_list.append("reset")

    send_cmd("tv_PenBrush", *args_list)

    # Since TVPaint is returning only the values that were modified
    # this is almost impossible to parse so we call get
    return tv_pen_brush_get()

tv_line(xy1: tuple[int, int], xy2: tuple[int, int], right_click: bool = False, dry: bool = False) -> None

Draw a line (with the current brush).

Parameters:

Name Type Description Default
xy1 tuple[int, int]

start position as (x, y)

required
xy2 tuple[int, int]

end position as (x, y)

required
right_click bool

True to emulate right click, False to emulate left click. Default is False

False
dry bool

True for dry mode

False
Source code in pytvpaint/george/grg_base.py
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
def tv_line(
    xy1: tuple[int, int],
    xy2: tuple[int, int],
    right_click: bool = False,
    dry: bool = False,
) -> None:
    """Draw a line (with the current brush).

    Args:
        xy1: start position as (x, y)
        xy2: end position as (x, y)
        right_click: True to emulate right click, False to emulate left click. Default is False
        dry: True for dry mode
    """
    args = [
        *xy1,
        *xy2,
        right_click,
        dry,
    ]
    send_cmd("tv_Line", *args)

tv_text(text: str, x: int, y: int, use_b_pen: bool = False) -> None

Write text in a layer instance.

Parameters:

Name Type Description Default
text str

text to write

required
x int

text x position

required
y int

text y position

required
use_b_pen bool

True will use b pen, False will use A pen

False
Source code in pytvpaint/george/grg_base.py
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
def tv_text(text: str, x: int, y: int, use_b_pen: bool = False) -> None:
    """Write text in a layer instance.

    Args:
        text: text to write
        x: text x position
        y: text y position
        use_b_pen: True will use b pen, False will use A pen
    """
    send_cmd("tv_Text", x, y, int(use_b_pen), text)

tv_text_brush(text: str) -> None

Set the text for the text brush.

Parameters:

Name Type Description Default
text str

text to write

required
Source code in pytvpaint/george/grg_base.py
1210
1211
1212
1213
1214
1215
1216
def tv_text_brush(text: str) -> None:
    """Set the text for the text brush.

    Args:
        text: text to write
    """
    send_cmd("tv_TextBrush", text)

tv_rect(tlx: float, tly: float, brx: float, bry: float, button: RectButton | None = None) -> None

Draws an unfilled rectangle.

Parameters:

Name Type Description Default
tlx float

top left x coordinate

required
tly float

top left y coordinate

required
brx float

bottom right x coordinate

required
bry float

bottom right y coordinate

required
button pytvpaint.george.grg_base.RectButton | None

use left or right click button (left draws, right erases)

None
Source code in pytvpaint/george/grg_base.py
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
def tv_rect(
    tlx: float,
    tly: float,
    brx: float,
    bry: float,
    button: RectButton | None = None,
) -> None:
    """Draws an unfilled rectangle.

    Args:
        tlx: top left x coordinate
        tly: top left y coordinate
        brx: bottom right x coordinate
        bry: bottom right y coordinate
        button: use left or right click button (left draws, right erases)
    """
    args: list[float] = [tlx, tly, brx, bry]
    if button:
        args.append(button.value)
    send_cmd("tv_Rect", *args)

tv_rect_fill(tlx: float, tly: float, brx: float, bry: float, grx: float = 0, gry: float = 0, erase_mode: bool = False, tool_mode: bool = False) -> None

Draws a filled rectangle.

Parameters:

Name Type Description Default
tlx float

top left x coordinate

required
tly float

top left y coordinate

required
brx float

bottom right x coordinate

required
bry float

bottom right y coordinate

required
grx float

gradient vector x

0
gry float

gradient vector y

0
erase_mode bool

erase drawing mode

False
tool_mode bool

manage drawing mode

False
Source code in pytvpaint/george/grg_base.py
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
def tv_rect_fill(
    tlx: float,
    tly: float,
    brx: float,
    bry: float,
    grx: float = 0,
    gry: float = 0,
    erase_mode: bool = False,
    tool_mode: bool = False,
) -> None:
    """Draws a filled rectangle.

    Args:
        tlx: top left x coordinate
        tly: top left y coordinate
        brx: bottom right x coordinate
        bry: bottom right y coordinate
        grx: gradient vector x
        gry: gradient vector y
        erase_mode: erase drawing mode
        tool_mode: manage drawing mode
    """
    args: list[Any] = [tlx, tly, brx, bry, grx, gry, int(erase_mode)]
    if tool_mode:
        args.insert(0, "toolmode")
    send_cmd("tv_RectFill", *args)

tv_fast_line(x1: float, y1: float, x2: float, y2: float, r: int = 255, b: int = 255, g: int = 0, a: int = 255) -> None

Draw a line (1 pixel size and not antialiased).

Source code in pytvpaint/george/grg_base.py
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
def tv_fast_line(
    x1: float,
    y1: float,
    x2: float,
    y2: float,
    r: int = 255,
    b: int = 255,
    g: int = 0,
    a: int = 255,
) -> None:
    """Draw a line (1 pixel size and not antialiased)."""
    send_cmd("tv_fastline", x1, y1, x2, y2, r, g, b, a)

tv_pick_color() -> tuple[int, RGBAColor]

Pick a color from the UI using the mouse.

Returns:

Name Type Description
mouse_click int

mouse click (-1: cancel, 0: left button mouse, 1: right button mouse)

color pytvpaint.george.grg_base.RGBAColor

the selected RGBA Color

Source code in pytvpaint/george/grg_base.py
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
def tv_pick_color() -> tuple[int, RGBAColor]:
    """Pick a color from the UI using the mouse.

    Returns:
        mouse_click: mouse click (-1: cancel, 0: left button mouse, 1: right button mouse)
        color: the selected RGBA Color
    """
    result = send_cmd("tv_PicColor")
    mouse_click, r, g, b, a = result.split()

    return int(mouse_click), RGBAColor(*[int(c) for c in (r, g, b, a)])