2 from .base
import LottieObject, LottieProp, PseudoBool, LottieEnum, LottieValueConverter
3 from .effects
import Effect
4 from .helpers
import Transform, Mask, VisualObject, BlendMode
5 from .shapes
import ShapeElement
6 from .text
import TextAnimatorData
7 from .properties
import Value, MultiDimensional
8 from ..utils.color
import Color, color_from_hex, color_to_hex
9 from .styles
import LayerStyle
25 Base class for all layers
28 LottieProp(
"threedimensional",
"ddd", PseudoBool,
False),
33 LottieProp(
"parent_index",
"parent", int,
False),
34 LottieProp(
"time_stretch",
"sr", float,
False),
66 def _load_get_class(cls, lottiedict):
67 if not Layer._classses:
70 for sc
in Layer.__subclasses__() + VisualLayer.__subclasses__()
71 if sc.type
is not None
73 type_id = lottiedict[
"ty"]
74 if type_id
not in Layer._classses:
75 warnings.warn(
"Unknown layer type: %s" % type_id)
77 return Layer._classses[type_id]
83 Base class for layers that have a visual component
86 LottieProp(
"collapse_transform",
"cp", bool,
False),
87 LottieProp(
"transform",
"ks", Transform,
False),
88 LottieProp(
"auto_orient",
"ao", PseudoBool,
False),
90 LottieProp(
"blend_mode",
"bm", BlendMode,
False),
92 LottieProp(
"matte_mode",
"tt", MatteMode,
False),
97 LottieProp(
"layer_xml_tag_name",
"tg", str,
False),
100 LottieProp(
"layer_style",
"sy", LayerStyle,
True),
102 LottieProp(
"has_masks",
"hasMask", bool,
False),
103 LottieProp(
"masks",
"masksProperties", Mask,
True),
110 Whether the layer has some masks applied
112 return bool(self.
masksmasks)
if getattr(self,
"masks")
is not None else None
152 raise Exception(
"Must set composition / index first")
155 layer.parent_index = self.
indexindex
158 def _child_inout_auto(self, layer):
159 if layer.in_point
is None:
160 layer.in_point = self.
in_pointin_point
161 if layer.out_point
is None:
162 layer.out_point = self.
out_pointout_point
176 layer._child_inout_auto(self)
181 if layer.parent_index == self.
indexindex:
185 return "<%s %s %s>" % (
type(self).__name__, self.
indexindex, self.
namename)
190 self.
indexindex
if self.
indexindex
is not None else ""
195 @brief Removes this layer from the componsitin
203 Layer with no data, useful to group layers together
215 LottieProp(
"data",
"t", TextAnimatorData,
False),
229 Layer containing ShapeElement objects
232 LottieProp(
"shapes",
"shapes", ShapeElement,
True),
243 self.
shapesshapes.append(shape)
247 self.
shapesshapes.insert(index, shape)
269 LottieProp(
"reference_id",
"refId", str,
False),
270 LottieProp(
"time_remapping",
"tm", Value,
False),
295 Layer with a solid color rectangle
298 LottieProp(
"color",
"sc", ColorString,
False),
305 def __init__(self, color=Color(), width=512, height=512):
323 LottieProp(
"transform",
"ks", Transform,
False),
324 LottieProp(
"perspective",
"pe", Value,
False),
341 LottieProp(
"data_source_id",
"refId", str,
False),
355 LottieProp(
"level",
"lv", MultiDimensional,
False),
367 A layer playing sounds
371 LottieProp(
"audio_settings",
"au", AudioSettings,
False),
Base class for enum-like types in the Lottie JSON structure.
Base class for mapping Python classes into Lottie JSON objects.
Lottie <-> Python property mapper.
Factory for property types that require special conversions.
sound_id
ID of the sound as specified in the assets.
transform
Layer transform.
perspective
Distance from the Z=0 plane.
data_source_id
ID of the data source in assets.
image_id
id pointing to the source image defined on 'assets' object
def __init__(self, image_id="")
Base class for all layers.
in_point
Frame when the layer becomes visible.
out_point
Frame when the layer becomes invisible.
index
Index that can be used for parenting and referenced in expressions.
hidden
Whether the layer is hidden.
start_time
Start Time of layer.
parent_index
Must be the ind property of another layer.
threedimensional
Whether the layer is threedimensional.
is_guide
When true, the layer should not be rendered.
Layer with no data, useful to group layers together.
reference_id
id pointing to the source composition defined on 'assets' object
time_remapping
Comp's Time remapping.
def __init__(self, reference_id="")
Layer containing ShapeElement objects.
def insert_shape(self, index, shape)
shapes
Shape list of items.
def add_shape(self, shape)
Layer with a solid color rectangle.
def __init__(self, color=Color(), width=512, height=512)
height
Height of the layer.
color
Color of the layer as a #rrggbb hex.
Base class for layers that have a visual component.
auto_orient
Auto-Orient along path AE property.
layer_style
Styling effects for this layer.
composition
Composition owning the layer, set by add_layer.
transform
Transform properties.
layer_xml_id
id attribute used by the SVG renderer
stretch
Layer Time Stretching.
matte_mode
Matte mode, the layer will inherit the transparency from the layer above.
def has_masks(self)
Whether the layer has some masks applied.
css_class
CSS class used by the SVG renderer.
motion_blur
Whether motion blur is enabled for the layer.
def remove(self)
Removes this layer from the componsitin.
def add_child(self, layer)
layer_xml_tag_name
tag name used by the SVG renderer
def _child_inout_auto(self, layer)
An animatable property that holds a NVector.