|
AnishGulati |
0635b5 |
# pylint: disable=line-too-long
|
|
AnishGulati |
5b8f00 |
"""
|
|
AnishGulati |
5b8f00 |
Store all functions corresponding to pre composition in lottie
|
|
AnishGulati |
5b8f00 |
"""
|
|
AnishGulati |
5b8f00 |
|
|
AnishGulati |
5b8f00 |
import sys
|
|
AnishGulati |
5b8f00 |
import settings
|
|
AnishGulati |
1292be |
from common.Layer import Layer
|
|
AnishGulati |
5b8f00 |
from sources.precomp import add_precomp_asset
|
|
AnishGulati |
b66d21 |
from layers.rotate_layer import gen_layer_rotate
|
|
AnishGulati |
b66d21 |
from layers.scale_layer import gen_layer_scale
|
|
AnishGulati |
fa0d7a |
from layers.translate_layer import gen_layer_translate
|
|
AnishGulati |
5b8f00 |
sys.path.append("..")
|
|
AnishGulati |
5b8f00 |
|
|
AnishGulati |
5b8f00 |
|
|
AnishGulati |
ac3983 |
def gen_layer_precomp(lottie, layer, idx):
|
|
AnishGulati |
5b8f00 |
"""
|
|
AnishGulati |
0635b5 |
Generates a pre-composition layer depending upon the layers inside that
|
|
AnishGulati |
0635b5 |
pre-comp
|
|
AnishGulati |
5b8f00 |
Here idx represents the position of layer in the .sif file also
|
|
AnishGulati |
0635b5 |
|
|
AnishGulati |
0635b5 |
Args:
|
|
AnishGulati |
0635b5 |
lottie (dict) : Will store the pre-comp layer
|
|
AnishGulati |
a3579e |
layer (common.Layer.Layer) : Specifies which layer it is
|
|
AnishGulati |
0635b5 |
idx (int) : Index of the layer
|
|
AnishGulati |
0635b5 |
|
|
AnishGulati |
0635b5 |
Returns:
|
|
AnishGulati |
0635b5 |
(None)
|
|
AnishGulati |
5b8f00 |
"""
|
|
AnishGulati |
5b8f00 |
lottie["ddd"] = settings.DEFAULT_3D
|
|
AnishGulati |
5b8f00 |
lottie["ind"] = idx
|
|
AnishGulati |
5b8f00 |
lottie["ty"] = settings.LAYER_PRECOMP_TYPE
|
|
AnishGulati |
ac3983 |
lottie["nm"] = layer.get_description()
|
|
AnishGulati |
5b8f00 |
lottie["sr"] = settings.LAYER_DEFAULT_STRETCH
|
|
AnishGulati |
5b8f00 |
lottie["ks"] = {} # Transform properties to be filled
|
|
AnishGulati |
5b8f00 |
|
|
AnishGulati |
ac3983 |
if layer.get_type() == "rotate":
|
|
AnishGulati |
ebc879 |
# transform properties will be written inside this now
|
|
AnishGulati |
ac3983 |
gen_layer_rotate(lottie["ks"], layer)
|
|
AnishGulati |
b66d21 |
settings.INSIDE_PRECOMP = True
|
|
AnishGulati |
ac3983 |
elif layer.get_type() == "zoom":
|
|
AnishGulati |
9ae542 |
gen_layer_scale(lottie["ks"], layer, "scale_layer")
|
|
AnishGulati |
ebc879 |
settings.INSIDE_PRECOMP = True
|
|
AnishGulati |
ac3983 |
elif layer.get_type() == "translate":
|
|
AnishGulati |
ac3983 |
gen_layer_translate(lottie["ks"], layer)
|
|
AnishGulati |
fa0d7a |
settings.INSIDE_PRECOMP = True
|
|
AnishGulati |
9ae542 |
elif layer.get_type() == "stretch":
|
|
AnishGulati |
9ae542 |
gen_layer_scale(lottie["ks"], layer, "stretch_layer")
|
|
AnishGulati |
9ae542 |
settings.INSIDE_PRECOMP = True
|
|
AnishGulati |
ebc879 |
|
|
AnishGulati |
5b8f00 |
settings.lottie_format["assets"].append({})
|
|
AnishGulati |
8a6b29 |
asset = add_precomp_asset(settings.lottie_format["assets"][-1], layer.getparent(), idx)
|
|
AnishGulati |
5b8f00 |
lottie["refId"] = asset
|
|
AnishGulati |
5b8f00 |
|
|
AnishGulati |
5b8f00 |
|
|
AnishGulati |
5e53c0 |
lottie["w"] = settings.lottie_format["w"] + settings.ADDITIONAL_PRECOMP_WIDTH # Experimental increase in width and height of precomposition
|
|
AnishGulati |
5e53c0 |
lottie["h"] = settings.lottie_format["h"] + settings.ADDITIONAL_PRECOMP_HEIGHT
|
|
AnishGulati |
5b8f00 |
lottie["ao"] = settings.LAYER_DEFAULT_AUTO_ORIENT
|
|
AnishGulati |
5b8f00 |
lottie["ip"] = settings.lottie_format["ip"]
|
|
AnishGulati |
5b8f00 |
lottie["op"] = settings.lottie_format["op"]
|
|
AnishGulati |
5b8f00 |
lottie["st"] = 0 # Don't know yet
|
|
AnishGulati |
0635b5 |
lottie["bm"] = settings.DEFAULT_BLEND # Always have the default blend
|