python-lottie
0.6.11+devc144cca
A framework to work with lottie files and telegram animated stickers (tgs)
|
Go to the documentation of this file.
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
8 from ..utils.color
import Color, color_from_hex, color_to_hex
24 LottieProp(
"threedimensional",
"ddd", PseudoBool,
False),
27 LottieProp(
"parent_index",
"parent", int,
False),
30 LottieProp(
"transform",
"ks", Transform,
False),
31 LottieProp(
"auto_orient",
"ao", PseudoBool,
False),
36 LottieProp(
"blend_mode",
"bm", BlendMode,
False),
38 LottieProp(
"matte_mode",
"tt", MatteMode,
False),
44 LottieProp(
"has_masks",
"hasMask", bool,
False),
45 LottieProp(
"masks",
"masksProperties", Mask,
True),
57 Whether the layer has some masks applied
59 return bool(self.
masks)
if getattr(self,
"masks")
is not None else None
105 raise Exception(
"Must set composition / index first")
108 layer.parent_index = self.
index
111 def _child_inout_auto(self, layer):
112 if layer.in_point
is None:
114 if layer.out_point
is None:
129 layer._child_inout_auto(self)
134 if layer.parent_index == self.
index:
138 def _load_get_class(cls, lottiedict):
139 if not Layer._classses:
142 for sc
in Layer.__subclasses__()
144 type_id = lottiedict[
"ty"]
145 if type_id
not in Layer._classses:
146 warnings.warn(
"Unknown layer type: %s" % type_id)
148 return Layer._classses[type_id]
151 return "<%s %s %s>" % (
type(self).__name__, self.
index, self.
name)
161 @brief Removes this layer from the componsitin
169 Layer with no data, useful to group layers together
181 LottieProp(
"data",
"t", TextAnimatorData,
False),
195 Layer containing ShapeElement objects
198 LottieProp(
"shapes",
"shapes", ShapeElement,
True),
213 self.
shapes.insert(index, shape)
235 LottieProp(
"reference_id",
"refId", str,
False),
236 LottieProp(
"time_remapping",
"tm", Value,
False),
261 Layer with a solid color rectangle
264 LottieProp(
"color",
"sc", ColorString,
False),
271 def __init__(self, color=Color(), width=512, height=512):
transform
Transform properties.
auto_orient
Auto-Orient along path AE property.
reference_id
id pointing to the source composition defined on 'assets' object
motion_blur
Whether motion blur is enabled for the layer.
Layer with no data, useful to group layers together.
height
Height of the layer.
def __init__(self, image_id="")
def __init__(self, reference_id="")
time_remapping
Comp's Time remapping.
def __init__(self, color=Color(), width=512, height=512)
Lottie <-> Python property mapper.
parent_index
Layer Parent.
def _child_inout_auto(self, layer)
Base class for enum-like types in the Lottie JSON structure.
in_point
In Point of layer.
image_id
id pointing to the source image defined on 'assets' object
def add_child(self, layer)
css_class
CSS class used by the SVG renderer.
stretch
Layer Time Stretching.
start_time
Start Time of layer.
out_point
Out Point of layer.
shapes
Shape list of items.
Factory for property types that require special conversions.
def add_shape(self, shape)
color
Color of the layer as a #rrggbb hex.
matte_mode
Matte mode, the layer will inherit the transparency from the layer above.
def remove(self)
Removes this layer from the componsitin.
layer_xml_id
id attribute used by the SVG renderer
threedimensional
3d layer flag
def has_masks(self)
Whether the layer has some masks applied.
def insert_shape(self, index, shape)
Layer with a solid color rectangle.
composition
Composition owning the layer, set by add_layer.
Layer containing ShapeElement objects.