Layer class¶
Bases: pytvpaint.utils.Removable
A Layer is inside a clip and contains drawings.
Source code in pytvpaint/layer.py
334 335 336 337 338 339 340 |
|
id: int
property
¶
The layers unique identifier.
Warning
layer ids are not persistent across project load/close
project: Project
property
¶
The project containing this layer.
scene: Scene
property
¶
The scene containing this layer.
clip: Clip
property
¶
The clip containing this layer.
position: int
property
writable
¶
The position in the layer stack.
Note
layer positions start at 0
opacity: int
property
writable
¶
Get the layer opacity value.
Note
In George, this is called density, we renamed it to opacity
as it seems more appropriate
color: LayerColor
property
writable
¶
Get the layer color.
is_current: bool
property
¶
Returns True if the layer is the current one in the clip.
is_selected: bool
property
writable
¶
Returns True if the layer is selected.
is_visible: bool
property
writable
¶
Returns True if the layer is visible.
is_locked: bool
property
writable
¶
Returns True if the layer is locked.
is_collapsed: bool
property
writable
¶
Returns True if the layer is collapsed.
blending_mode: george.BlendingMode
property
writable
¶
Get the layer blending mode value.
stencil: george.StencilMode
property
writable
¶
Get the layer stencil mode value.
thumbnails_visible: bool
property
writable
¶
Returns True if thumbnails are shown on that layer.
auto_break_instance: bool
property
writable
¶
Get the auto break instance value.
auto_create_instance: bool
property
writable
¶
Get the auto create instance value.
pre_behavior: george.LayerBehavior
property
writable
¶
Get the pre-behavior value.
post_behavior: george.LayerBehavior
property
writable
¶
Get the post-behavior value.
is_position_locked: bool
property
writable
¶
Returns True if the layer position is locked.
preserve_transparency: george.LayerTransparency
property
writable
¶
Get the preserve transparency value.
is_anim_layer: bool
property
¶
Returns True if the layer is an animation layer.
marks: Iterator[tuple[int, LayerColor]]
property
¶
Iterator over the layer marks including the frame and the color.
Yields:
Name | Type | Description |
---|---|---|
frame |
int
|
the mark frame |
color |
pytvpaint.layer.LayerColor
|
the mark color |
selected_frames: list[int]
property
¶
refresh() -> None
¶
Refreshes the layer data.
Source code in pytvpaint/layer.py
342 343 344 345 346 347 348 349 350 351 |
|
name(value: str) -> None
¶
Set the layer name.
Note
it uses get_unique_name
to find a unique layer name across all the layers in the clip
Source code in pytvpaint/layer.py
420 421 422 423 424 425 426 427 428 429 430 431 |
|
layer_type() -> george.LayerType
¶
The layer type.
Source code in pytvpaint/layer.py
433 434 435 436 |
|
start() -> int
¶
The layer start frame according to the project's start frame.
Source code in pytvpaint/layer.py
454 455 456 457 |
|
end() -> int
¶
The layer end frame according to the project's start frame.
Source code in pytvpaint/layer.py
459 460 461 462 |
|
make_current() -> None
¶
Make the layer current, it also makes the clip current.
Source code in pytvpaint/layer.py
480 481 482 483 484 485 486 |
|
convert_to_anim_layer() -> None
¶
Converts the layer to an animation layer.
Source code in pytvpaint/layer.py
626 627 628 629 |
|
load_dependencies() -> None
¶
Load all dependencies of the layer in memory.
Source code in pytvpaint/layer.py
636 637 638 |
|
current_layer_id() -> int
staticmethod
¶
Returns the current layer id.
Source code in pytvpaint/layer.py
640 641 642 643 |
|
current_layer() -> Layer
classmethod
¶
Returns the current layer object.
Source code in pytvpaint/layer.py
645 646 647 648 649 650 |
|
shift(new_start: int) -> None
¶
Move the layer to a new frame.
Source code in pytvpaint/layer.py
652 653 654 655 |
|
merge(layer: Layer, blending_mode: george.BlendingMode, stamp: bool = False, erase: bool = False, keep_color_grp: bool = True, keep_img_mark: bool = True, keep_instance_name: bool = True) -> None
¶
Merge this layer with the given one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer |
pytvpaint.layer.Layer
|
the layer to merge with |
required |
blending_mode |
pytvpaint.george.BlendingMode
|
the blending mode to use |
required |
stamp |
bool
|
Use stamp mode |
False
|
erase |
bool
|
Remove the source layer |
False
|
keep_color_grp |
bool
|
Keep the color group |
True
|
keep_img_mark |
bool
|
Keep the image mark |
True
|
keep_instance_name |
bool
|
Keep the instance name |
True
|
Source code in pytvpaint/layer.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 |
|
merge_all(keep_color_grp: bool = True, keep_img_mark: bool = True, keep_instance_name: bool = True) -> None
staticmethod
¶
Merge all the layers in the stack.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keep_color_grp |
bool
|
Keep the color group |
True
|
keep_img_mark |
bool
|
Keep the image mark |
True
|
keep_instance_name |
bool
|
Keep the instance name |
True
|
Source code in pytvpaint/layer.py
689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
|
new(name: str, clip: Clip | None = None, color: LayerColor | None = None) -> Layer
staticmethod
¶
Create a new layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the name of the new layer |
required |
clip |
pytvpaint.clip.Clip | None
|
the parent clip |
None
|
color |
pytvpaint.layer.LayerColor | None
|
the layer color |
None
|
Returns:
Name | Type | Description |
---|---|---|
Layer |
pytvpaint.layer.Layer
|
the new layer |
Note
The layer name is checked against all other layers to have a unique name using get_unique_name
.
This can take a while if you have a lot of layers.
Source code in pytvpaint/layer.py
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 |
|
new_anim_layer(name: str, clip: Clip | None = None, color: LayerColor | None = None) -> Layer
classmethod
¶
Create a new animation layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the name of the new layer |
required |
clip |
pytvpaint.clip.Clip | None
|
the parent clip |
None
|
color |
pytvpaint.layer.LayerColor | None
|
the layer color |
None
|
Returns:
Name | Type | Description |
---|---|---|
Layer |
pytvpaint.layer.Layer
|
the new animation layer |
Note
It activates the thumbnail visibility
Source code in pytvpaint/layer.py
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
|
new_background_layer(name: str, clip: Clip | None = None, color: LayerColor | None = None, image: Path | str | None = None, stretch: bool = False) -> Layer
classmethod
¶
Create a new background layer with hold as pre- and post-behavior.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the name of the new layer |
required |
clip |
pytvpaint.clip.Clip | None
|
the parent clip |
None
|
color |
pytvpaint.layer.LayerColor | None
|
the layer color |
None
|
image |
pathlib.Path | str | None
|
the background image to load |
None
|
stretch |
bool
|
whether to stretch the image to fit the view |
False
|
Returns:
Name | Type | Description |
---|---|---|
Layer |
pytvpaint.layer.Layer
|
the new animation layer |
Source code in pytvpaint/layer.py
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
|
duplicate(name: str) -> Layer
¶
Duplicate this layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the duplicated layer name |
required |
Returns:
Name | Type | Description |
---|---|---|
Layer |
pytvpaint.layer.Layer
|
the duplicated layer |
Source code in pytvpaint/layer.py
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
|
remove() -> None
¶
Remove the layer from the clip.
Warning
The current instance won't be usable after this call since it will be mark removed.
Source code in pytvpaint/layer.py
819 820 821 822 823 824 825 826 827 828 |
|
render(output_path: Path | str | FileSequence, start: int | None = None, end: int | None = None, use_camera: bool = False, alpha_mode: george.AlphaSaveMode = george.AlphaSaveMode.PREMULTIPLY, background_mode: george.BackgroundMode | None = None, format_opts: list[str] | None = None) -> None
¶
Render the layer to a single frame or frame sequence or movie.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_path |
pathlib.Path | str | fileseq.filesequence.FileSequence
|
a single file or file sequence pattern |
required |
start |
int | None
|
the start frame to render the layer's start if None. Defaults to None. |
None
|
end |
int | None
|
the end frame to render or the layer's end if None. Defaults to None. |
None
|
use_camera |
bool
|
use the camera for rendering, otherwise render the whole canvas. Defaults to False. |
False
|
alpha_mode |
pytvpaint.george.AlphaSaveMode
|
the alpha mode for rendering. Defaults to george.AlphaSaveMode.PREMULTIPLY. |
pytvpaint.george.AlphaSaveMode.PREMULTIPLY
|
background_mode |
pytvpaint.george.BackgroundMode | None
|
the background mode for rendering. Defaults to None. |
None
|
format_opts |
list[str] | None
|
custom format options. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
if requested range (start-end) not in clip range/bounds |
ValueError
|
if output is a movie |
FileNotFoundError
|
if the render failed and no files were found on disk or missing frames |
Note
This functions uses the layer's range as a basis (start-end). This is different from a project range, which
uses the project timeline. For more details on the differences in frame ranges and the timeline in TVPaint,
please check the Usage/Rendering
section of the documentation.
Warning
Even tough pytvpaint does a pretty good job of correcting the frame ranges for rendering, we're still encountering some weird edge cases where TVPaint will consider the range invalid for seemingly no reason.
Source code in pytvpaint/layer.py
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 |
|
render_frame(export_path: Path | str, frame: int | None = None, alpha_mode: george.AlphaSaveMode = george.AlphaSaveMode.PREMULTIPLY, background_mode: george.BackgroundMode | None = george.BackgroundMode.NONE, format_opts: list[str] | None = None) -> Path
¶
Render a frame from the layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
export_path |
pathlib.Path | str
|
the frame export path (the extension determines the output format) |
required |
frame |
int | None
|
the frame to render or the current frame if None. Defaults to None. |
None
|
alpha_mode |
pytvpaint.george.AlphaSaveMode
|
the render alpha mode |
pytvpaint.george.AlphaSaveMode.PREMULTIPLY
|
background_mode |
pytvpaint.george.BackgroundMode | None
|
the render background mode |
pytvpaint.george.BackgroundMode.NONE
|
format_opts |
list[str] | None
|
custom output format options to pass when rendering |
None
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if the render failed or output not found on disk |
Returns:
Name | Type | Description |
---|---|---|
Path |
pathlib.Path
|
render output path |
Source code in pytvpaint/layer.py
879 880 881 882 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 913 914 915 916 917 918 919 920 921 922 923 924 |
|
render_instances(export_path: Path | str | FileSequence, start: int | None = None, end: int | None = None, alpha_mode: george.AlphaSaveMode = george.AlphaSaveMode.PREMULTIPLY, background_mode: george.BackgroundMode | None = None, format_opts: list[str] | None = None) -> FileSequence
¶
Render all layer instances in the provided range for the current layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
export_path |
pathlib.Path | str | fileseq.filesequence.FileSequence
|
the export path (the extension determines the output format) |
required |
start |
int | None
|
the start frame to render the layer's start if None. Defaults to None. |
None
|
end |
int | None
|
the end frame to render or the layer's end if None. Defaults to None. |
None
|
alpha_mode |
pytvpaint.george.AlphaSaveMode
|
the render alpha mode |
pytvpaint.george.AlphaSaveMode.PREMULTIPLY
|
background_mode |
pytvpaint.george.BackgroundMode | None
|
the render background mode |
None
|
format_opts |
list[str] | None
|
custom output format options to pass when rendering |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
if requested range (start-end) not in layer range/bounds |
ValueError
|
if output is a movie |
FileNotFoundError
|
if the render failed or output not found on disk |
Returns:
Name | Type | Description |
---|---|---|
FileSequence |
fileseq.filesequence.FileSequence
|
instances output sequence |
Source code in pytvpaint/layer.py
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 |
|
load_image(image_path: str | Path, frame: int | None = None, stretch: bool = False) -> None
¶
Load an image in the current layer at a given frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_path |
str | pathlib.Path
|
path to the image to load |
required |
frame |
int | None
|
the frame where the image will be loaded, if none provided, image will be loaded at current frame |
None
|
stretch |
bool
|
whether to stretch the image to fit the view |
False
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if the file doesn't exist at provided path |
Source code in pytvpaint/layer.py
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 |
|
get_mark_color(frame: int) -> LayerColor | None
¶
Get the mark color at a specific frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame |
int
|
frame with a mark |
required |
Returns:
Type | Description |
---|---|
pytvpaint.layer.LayerColor | None
|
LayerColor | None: the layer color if there was a mark |
Source code in pytvpaint/layer.py
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 |
|
add_mark(frame: int, color: LayerColor) -> None
¶
Add a mark to a frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame |
int
|
frame to put a mark on |
required |
color |
pytvpaint.layer.LayerColor
|
the color index |
required |
Raises:
Type | Description |
---|---|
TypeError
|
if the layer is not an animation layer |
Source code in pytvpaint/layer.py
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 |
|
remove_mark(frame: int) -> None
¶
Remove a mark.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame |
int
|
a frame number with a mark |
required |
Source code in pytvpaint/layer.py
1039 1040 1041 1042 1043 1044 1045 1046 |
|
clear_marks() -> None
¶
Clear all the marks in the layer.
Source code in pytvpaint/layer.py
1062 1063 1064 1065 |
|
select_frames(start: int, end: int) -> None
¶
Select the frames from a start and count.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
int
|
the selection start frame |
required |
end |
int
|
the selected end frame |
required |
Source code in pytvpaint/layer.py
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 |
|
select_all_frames() -> None
¶
Select all frames in the layer.
Source code in pytvpaint/layer.py
1082 1083 1084 1085 1086 |
|
clear_selection() -> None
¶
Clear frame selection in the layer.
Source code in pytvpaint/layer.py
1088 1089 1090 1091 1092 |
|
cut_selection() -> None
¶
Cut the selected instances.
Source code in pytvpaint/layer.py
1104 1105 1106 1107 |
|
copy_selection() -> None
¶
Copy the selected instances.
Source code in pytvpaint/layer.py
1109 1110 1111 1112 |
|
paste_selection() -> None
¶
Paste the previously copied instances.
Source code in pytvpaint/layer.py
1114 1115 1116 1117 |
|
instances() -> Iterator[LayerInstance]
¶
Iterates over the layer instances.
Yields:
Type | Description |
---|---|
pytvpaint.layer.LayerInstance
|
each LayerInstance present in the layer |
Source code in pytvpaint/layer.py
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 |
|
get_instance(frame: int, strict: bool = False) -> LayerInstance | None
¶
Get the instance at that frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame |
int
|
the instance frame |
required |
strict |
bool
|
True will only return Instance if the given frame is the start of the instance. Default is False |
False
|
Returns:
Type | Description |
---|---|
pytvpaint.layer.LayerInstance | None
|
the instance if found else None |
Source code in pytvpaint/layer.py
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 |
|
get_instances(from_frame: int, to_frame: int) -> Iterator[LayerInstance]
¶
Iterates over the layer instances and returns the one in the range (from_frame-to_frame).
Yields:
Type | Description |
---|---|
pytvpaint.layer.LayerInstance
|
each LayerInstance in the range (from_frame-to_frame) |
Source code in pytvpaint/layer.py
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 |
|
add_instance(start: int | None = None, nb_frames: int = 1, direction: george.InsertDirection | None = None, split: bool = False) -> LayerInstance
¶
Crates a new instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
int | None
|
start frame. Defaults to clip current frame if none provided |
None
|
nb_frames |
int
|
number of frames in the new instance. Default is 1, this is the total number of frames created. |
1
|
direction |
pytvpaint.george.InsertDirection | None
|
direction where new frames will be added/inserted |
None
|
split |
bool
|
True to make each added frame a new image |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
if the layer is not an animation layer |
ValueError
|
if the number of frames |
ValueError
|
if an instance already exists at the given range (start + nb_frames) |
Returns:
Name | Type | Description |
---|---|---|
LayerInstance |
pytvpaint.layer.LayerInstance
|
new layer instance |
Source code in pytvpaint/layer.py
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 |
|
rename_instances(mode: george.InstanceNamingMode, prefix: str | None = None, suffix: str | None = None, process: george.InstanceNamingProcess | None = None) -> None
¶
Rename all the instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode |
pytvpaint.george.InstanceNamingMode
|
the instance renaming mode |
required |
prefix |
str | None
|
the prefix to add to each name |
None
|
suffix |
str | None
|
the suffix to add to each name |
None
|
process |
pytvpaint.george.InstanceNamingProcess | None
|
the instance naming process |
None
|
Source code in pytvpaint/layer.py
1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 |
|