From 1e575daad3179364f96588a69cd5fd5aa271b67d Mon Sep 17 00:00:00 2001 From: AnishGulati Date: Nov 25 2019 20:34:21 +0000 Subject: Add exponent convert method --- diff --git a/synfig-studio/plugins/lottie-exporter/common/Param.py b/synfig-studio/plugins/lottie-exporter/common/Param.py index 692bdc2..3277719 100644 --- a/synfig-studio/plugins/lottie-exporter/common/Param.py +++ b/synfig-studio/plugins/lottie-exporter/common/Param.py @@ -172,7 +172,7 @@ class Param: If this parameter is not animated, it generates dummy waypoints and animates this parameter """ - if anim_type == "vector": # This will never happen, can remove this latter + if anim_type in {"vector", "group_layer_scale"}: # This will never happen, can remove this latter self.dimension = 2 # Check if we are dealing with convert methods @@ -206,7 +206,7 @@ class Param: """ Internal private method for animating """ - if anim_type == "vector": + if anim_type in {"vector", "group_layer_scale"}: self.dimension = 2 # Check if we are dealing with convert methods @@ -298,6 +298,17 @@ class Param: self.expression = ret return ret, self.expression_controllers # Might have to return copy.deepcopy because these expressions are destroyed on animating this parameter again, and this param might be child to 2 params + elif self.param[0].tag == "exp": + self.subparams["exp"].extract_subparams() + exp, effects_1 = self.subparams["exp"].subparams["exp"].recur_animate("scalar_multiply") + scale, effects_2 = self.subparams["exp"].subparams["scale"].recur_animate(anim_type) + self.expression_controllers.extend(effects_1) + self.expression_controllers.extend(effects_2) + ret = "mul(Math.exp({exp}), {scale})" + ret = ret.format(exp=exp, scale=scale) + self.expression = ret + return ret, self.expression_controllers + elif self.param[0].tag == "average": self.subparams["average"].extract_subparams() # Entries will be extracted here lst = self.subparams["average"].subparams["entry"] @@ -639,6 +650,11 @@ class Param: ret += ret2 ret *= mul + elif self.param[0].tag == "exp": + exp = self.subparams["exp"].subparams["exp"].__get_value(frame) + scale = self.subparams["exp"].subparams["scale"].__get_value(frame) + ret = scale * math.exp(exp) + elif self.param[0].tag == "average": lst = self.subparams["average"].subparams["entry"] if not isinstance(lst, list): @@ -843,6 +859,11 @@ class Param: for it in self.subparams["average"]: it.update_frame_window(window) + elif node.tag == "exp": + self.subparams["exp"].extract_subparams() + self.subparams["exp"].subparams["exp"].update_frame_window(window) + self.subparams["exp"].subparams["scale"].update_frame_window(window) + elif node.tag == "weighted_average": self.subparams["weighted_average"].extract_subparams() for it in self.subparams["weighted_average"].subparams["entry"]: diff --git a/synfig-studio/plugins/lottie-exporter/effects/controller.py b/synfig-studio/plugins/lottie-exporter/effects/controller.py index 12b001d..8d1ed75 100644 --- a/synfig-studio/plugins/lottie-exporter/effects/controller.py +++ b/synfig-studio/plugins/lottie-exporter/effects/controller.py @@ -23,7 +23,7 @@ def gen_effects_controller(lottie, value, anim_type): lottie["ef"] = [] lottie["ef"].append({}) - if anim_type == "vector": + if anim_type in {"vector", "group_layer_scale"}: gen_effects_point(lottie["ef"][-1], value, idx) else: gen_effects_slider(lottie["ef"][-1], value, idx) diff --git a/synfig-studio/plugins/lottie-exporter/settings.py b/synfig-studio/plugins/lottie-exporter/settings.py index 64d476a..54a4548 100644 --- a/synfig-studio/plugins/lottie-exporter/settings.py +++ b/synfig-studio/plugins/lottie-exporter/settings.py @@ -69,7 +69,7 @@ PRE_COMP_LAYER = {"rotate", "zoom", "translate"} GROUP_LAYER = {"group", "switch"} SKELETON_LAYER = {"skeleton"} UNKNOWN_LAYER = "unknown_layer" -CONVERT_METHODS = {"add", "average", "composite", "linear", "radial_composite", "scale", "subtract", "switch", "weighted_average", "bone_link", "bone", "bone_root"} +CONVERT_METHODS = {"add", "average", "composite", "exp", "linear", "radial_composite", "scale", "subtract", "switch", "weighted_average", "bone_link", "bone", "bone_root"} BONES = {"bone", "bone_root"}