Blame synfig-studio/plugins/lottie-exporter/layers/scale_layer.py

AnishGulati b66d21
"""
AnishGulati b66d21
Will store all the functions needed to export the scale layer
AnishGulati b66d21
"""
AnishGulati b66d21
AnishGulati b66d21
import sys
AnishGulati b66d21
import copy
AnishGulati b66d21
import settings
AnishGulati b66d21
from helpers.transform import gen_helpers_transform
AnishGulati b66d21
sys.path.append("..")
AnishGulati b66d21
AnishGulati b66d21
AnishGulati 9ae542
def gen_layer_scale(lottie, layer, layer_name="scale_layer"):
AnishGulati b66d21
    """
AnishGulati 0635b5
    Help generate transform properties of a scale layer
AnishGulati 0635b5
AnishGulati 0635b5
    Args:
AnishGulati 0635b5
        lottie (dict) : Store transform properties in lottie format
AnishGulati a3579e
        layer  (common.Layer.Layer) Transform properties in Synfig format
AnishGulati 0635b5
AnishGulati 0635b5
    Returns:
AnishGulati 0635b5
        (None)
AnishGulati b66d21
    """
AnishGulati 9ae542
    animation_type = "scale_layer_zoom"
AnishGulati 9ae542
    if layer_name == "stretch_layer":
AnishGulati 9ae542
        animation_type = "stretch_layer_scale"
AnishGulati 9ae542
AnishGulati 79e77d
    center = layer.get_param("center")
AnishGulati 44202f
    center.animate("vector")
AnishGulati 0f157e
    anchor = copy.deepcopy(center)
AnishGulati 552877
    # deep copy changes address of parent layer also
AnishGulati 552877
    anchor.parent = center.parent
AnishGulati 034bbe
    pos = center
AnishGulati 1292be
AnishGulati 44202f
    scale = layer.get_param("amount")  # This is scale amount
AnishGulati 9ae542
    scale.animate(animation_type)
AnishGulati b66d21
AnishGulati 034bbe
    anchor.add_offset()
AnishGulati b66d21
    if settings.INSIDE_PRECOMP:
AnishGulati 034bbe
        pos.add_offset()
AnishGulati d4c500
    anchor.animate("vector", True)
AnishGulati d4c500
    pos.animate("vector", True)
AnishGulati 0f157e
    gen_helpers_transform(lottie, pos, anchor, scale)