Skip to content

Camera related George functions

Camera related George functions.

TVPCamera(width: int, height: int, field_order: FieldOrder, frame_rate: float, pixel_aspect_ratio: float, anti_aliasing: int = 1) dataclass

TVPaint camera info values.

width: int instance-attribute

height: int instance-attribute

field_order: FieldOrder instance-attribute

frame_rate: float instance-attribute

pixel_aspect_ratio: float instance-attribute

anti_aliasing: int = 1 class-attribute instance-attribute

TVPCameraPoint(x: float, y: float, angle: float, scale: float) dataclass

camera 2D point info.

x: float instance-attribute

y: float instance-attribute

angle: float instance-attribute

scale: float instance-attribute

tv_camera_info_get() -> TVPCamera

Get the information of the camera.

Source code in pytvpaint/george/grg_camera.py
40
41
42
43
44
45
46
47
48
49
50
51
52
def tv_camera_info_get() -> TVPCamera:
    """Get the information of the camera."""
    fields = get_dataclass_fields(cast(DataclassInstance, TVPCamera))
    if not is_tvp_version_below_12():
        # values of pixel aspect ratio and fps have been swapped in versions > 12
        fields_keys = list(dict(fields).keys())
        pixel_aspect_index, fps_index = fields_keys.index("pixel_aspect_ratio"), fields_keys.index("frame_rate")
        fields[pixel_aspect_index], fields[fps_index] = (
            fields[fps_index],
            fields[pixel_aspect_index],
        )

    return TVPCamera(**tv_parse_list(send_cmd("tv_CameraInfo"), with_fields=fields))

tv_camera_info_set(width: int | None = None, height: int | None = None, field_order: FieldOrder | None = None, frame_rate: float | None = None, pixel_aspect_ratio: float | None = None) -> TVPCamera

Set the information of the camera.

Source code in pytvpaint/george/grg_camera.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def tv_camera_info_set(
    width: int | None = None,
    height: int | None = None,
    field_order: FieldOrder | None = None,
    frame_rate: float | None = None,
    pixel_aspect_ratio: float | None = None,
) -> TVPCamera:
    """Set the information of the camera."""
    optional_args = [
        (width, height),
        field_order.value if field_order else None,
        frame_rate,
        pixel_aspect_ratio,
    ]

    args = validate_args_list(optional_args)

    result = send_cmd("tv_CameraInfo", *args)
    return TVPCamera(**tv_parse_list(result, with_fields=TVPCamera))

tv_camera_enum_points(index: int) -> TVPCameraPoint

Get the position/angle/scale values of the n-th point of the camera path.

Source code in pytvpaint/george/grg_camera.py
76
77
78
79
def tv_camera_enum_points(index: int) -> TVPCameraPoint:
    """Get the position/angle/scale values of the n-th point of the camera path."""
    res = send_cmd("tv_CameraEnumPoints", index, error_values=[GrgErrorValue.NONE])
    return TVPCameraPoint(**tv_parse_list(res, with_fields=TVPCameraPoint))

tv_camera_interpolation(position: float) -> TVPCameraPoint

Get the position/angle/scale values at the given position on the camera path (between 0 and 1).

Source code in pytvpaint/george/grg_camera.py
82
83
84
85
86
87
88
def tv_camera_interpolation(position: float) -> TVPCameraPoint:
    """Get the position/angle/scale values at the given position on the camera path (between 0 and 1)."""
    res = tv_parse_list(
        send_cmd("tv_CameraInterpolation", position),
        with_fields=TVPCameraPoint,
    )
    return TVPCameraPoint(**res)

tv_camera_info_frame(frame: int) -> TVPCameraPoint

Get the position/angle/scale values at the given frame.

Source code in pytvpaint/george/grg_camera.py
91
92
93
94
95
96
97
98
def tv_camera_info_frame(frame: int) -> TVPCameraPoint:
    """Get the position/angle/scale values at the given frame."""
    errors = ["The provided frame is out of the camera range"]
    res = tv_parse_list(
        send_cmd("tv_CameraInfoFrame", frame, error_values=errors),
        with_fields=TVPCameraPoint,
    )
    return TVPCameraPoint(**res)

tv_camera_insert_point(index: int, x: float, y: float, angle: float, scale: float) -> None

Add a point to the camera path before the given index.

Source code in pytvpaint/george/grg_camera.py
101
102
103
104
105
106
107
108
109
def tv_camera_insert_point(
    index: int,
    x: float,
    y: float,
    angle: float,
    scale: float,
) -> None:
    """Add a point to the camera path *before* the given index."""
    send_cmd("tv_CameraInsertPoint", index, x, y, angle, scale)

tv_camera_remove_point(index: int) -> None

Remove a point at the given index.

Source code in pytvpaint/george/grg_camera.py
112
113
114
def tv_camera_remove_point(index: int) -> None:
    """Remove a point at the given index."""
    send_cmd("tv_CameraRemovePoint", index)

tv_camera_set_point(index: int, x: float, y: float, angle: float, scale: float) -> None

Set position/angle/scale value of a point at the given index and make it current.

Source code in pytvpaint/george/grg_camera.py
117
118
119
120
121
122
123
124
125
def tv_camera_set_point(
    index: int,
    x: float,
    y: float,
    angle: float,
    scale: float,
) -> None:
    """Set position/angle/scale value of a point at the given index and make it current."""
    send_cmd("tv_CameraSetPoint", index, x, y, angle, scale)