예제 #1
0
def gen_properties_multi_dimensional_keyframed(lottie, animated, idx):
    """
    Generates the dictionary corresponding to
    properties/multiDimensionalKeyframed.json

    Args:
        lottie   (dict)                : Lottie generated keyframes will be stored here
        animated (lxml.etree._Element) : Synfig format animation
        idx      (int)                 : Index/Count of animation

    Returns:
        (None)
    """
    lottie["a"] = 1
    lottie["ix"] = idx
    lottie["k"] = []
    for i in range(len(animated) - 1):
        lottie["k"].append({})
        gen_properties_offset_keyframe(lottie["k"], animated, i)
    last_waypoint_frame = get_frame(animated[-1])
    lottie["k"].append({})
    lottie["k"][-1]["t"] = last_waypoint_frame

    if "h" in lottie["k"][-2].keys():
        lottie["k"][-1]["h"] = 1
        lottie["k"][-1]["s"] = lottie["k"][-2]["e"]

    # Time adjust of the curves
    time_adjust(lottie, animated)
예제 #2
0
def gen_value_Keyframed(lottie, animated, idx):
    """
    Generates the dictionary corresponding to properties/valueKeyframed.json in
    lottie documentation

    Args:
        lottie (dict)                  : Lottie bezier curve stored in this
        animated (lxml.etree._Element) : Synfig format animation
        idx      (int)                 : Index of animation

    Returns:
        (None)
    """
    lottie["ix"] = idx
    lottie["a"] = 1
    lottie["k"] = []
    for i in range(len(animated) - 1):
        lottie["k"].append({})
        gen_value_Keyframe(lottie["k"], animated, i)
    last_waypoint_frame = get_frame(animated[-1])
    lottie["k"].append({})
    lottie["k"][-1]["t"] = last_waypoint_frame

    if "h" in lottie["k"][-2].keys():
        lottie["k"][-1]["h"] = 1
        lottie["k"][-1]["s"] = lottie["k"][-2]["e"]

        # specific case for points when prev_points > cur_points
        if animated.attrib["type"] == "points":
            if lottie["k"][-2]["s"][0] > lottie["k"][-1]["s"][0]:
                # Adding 1 frame to the previous time
                prev_frames = get_frame(animated[-2])
                lottie["k"][-1]["t"] = prev_frames + 1

    time_adjust(lottie, animated)