|
AnishGulati |
8de8c0 |
"""
|
|
AnishGulati |
8de8c0 |
Will store all the functions corresponding to shapes which will be masked as
|
|
AnishGulati |
8de8c0 |
shapes in lottie
|
|
AnishGulati |
8de8c0 |
"""
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
8de8c0 |
import sys
|
|
AnishGulati |
8de8c0 |
import settings
|
|
AnishGulati |
8de8c0 |
from helpers.transform import gen_helpers_transform
|
|
AnishGulati |
8de8c0 |
from helpers.blendMode import get_blend
|
|
AnishGulati |
8de8c0 |
from helpers.mask import gen_mask
|
|
AnishGulati |
ac3983 |
from common.misc import get_color_hex, is_animated
|
|
AnishGulati |
1f6b9a |
from common.Count import Count
|
|
AnishGulati |
1292be |
from common.Layer import Layer
|
|
AnishGulati |
8de8c0 |
from effects.fill import gen_effects_fill
|
|
AnishGulati |
034bbe |
from synfig.group import get_additional_width, get_additional_height
|
|
AnishGulati |
8de8c0 |
sys.path.append("..")
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
ac3983 |
def gen_layer_shape_solid(lottie, layer, idx):
|
|
AnishGulati |
8de8c0 |
"""
|
|
AnishGulati |
8de8c0 |
Generates the dictionary corresponding to layers/shapes.json
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
8de8c0 |
Args:
|
|
AnishGulati |
1292be |
lottie (dict) : Lottie generated solid layer stored here
|
|
AnishGulati |
a3579e |
layer (common.Layer.Layer) : Synfig format solid layer
|
|
AnishGulati |
1292be |
idx (int) : Stores the index(number of) of solid layer
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
8de8c0 |
Returns:
|
|
AnishGulati |
8de8c0 |
(None)
|
|
AnishGulati |
8de8c0 |
"""
|
|
AnishGulati |
034bbe |
layer.add_offset()
|
|
AnishGulati |
5e53c0 |
|
|
AnishGulati |
8de8c0 |
# Setting the solid layer which will be masked
|
|
AnishGulati |
8de8c0 |
index = Count()
|
|
AnishGulati |
8de8c0 |
lottie["ddd"] = settings.DEFAULT_3D
|
|
AnishGulati |
8de8c0 |
lottie["ind"] = idx
|
|
AnishGulati |
8de8c0 |
lottie["ty"] = settings.LAYER_SOLID_TYPE
|
|
AnishGulati |
ac3983 |
lottie["nm"] = layer.get_description()
|
|
AnishGulati |
8de8c0 |
lottie["sr"] = settings.LAYER_DEFAULT_STRETCH
|
|
AnishGulati |
8de8c0 |
lottie["ks"] = {} # Transform properties to be filled
|
|
AnishGulati |
8de8c0 |
lottie["ef"] = [] # Stores the effects
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
2a69d4 |
pos = [settings.lottie_format["w"]/2 + get_additional_width()/2,
|
|
AnishGulati |
0635b5 |
settings.lottie_format["h"]/2 + get_additional_height()/2]
|
|
AnishGulati |
8de8c0 |
anchor = pos
|
|
AnishGulati |
a3579e |
gen_helpers_transform(lottie["ks"], pos, anchor)
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
8de8c0 |
lottie["ef"].append({})
|
|
AnishGulati |
a3579e |
gen_effects_fill(lottie["ef"][-1], layer, index.inc())
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
8de8c0 |
lottie["ao"] = settings.LAYER_DEFAULT_AUTO_ORIENT
|
|
AnishGulati |
2a69d4 |
lottie["sw"] = settings.lottie_format["w"] + get_additional_width() # Solid Width
|
|
AnishGulati |
2a69d4 |
lottie["sh"] = settings.lottie_format["h"] + get_additional_height() # Solid Height
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
1d9f57 |
lottie["sc"] = get_color_hex(layer.get_param("color").get()[0])
|
|
AnishGulati |
1292be |
|
|
AnishGulati |
8de8c0 |
invert = False
|
|
AnishGulati |
1d9f57 |
Inv = layer.get_param("invert").get()
|
|
AnishGulati |
1292be |
if Inv is not None:
|
|
AnishGulati |
1292be |
is_animate = is_animated(Inv[0])
|
|
AnishGulati |
1292be |
if is_animate == 0:
|
|
AnishGulati |
1292be |
val = Inv[0].attrib["value"]
|
|
AnishGulati |
1292be |
elif is_animate == 1:
|
|
AnishGulati |
1292be |
val = Inv[0][0][0].attrib["value"]
|
|
AnishGulati |
1292be |
else:
|
|
AnishGulati |
1292be |
# If animated, always set invert to false
|
|
AnishGulati |
1292be |
val = "false"
|
|
AnishGulati |
1292be |
if val == "true":
|
|
AnishGulati |
1292be |
invert = True
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
8de8c0 |
lottie["ip"] = settings.lottie_format["ip"]
|
|
AnishGulati |
8de8c0 |
lottie["op"] = settings.lottie_format["op"]
|
|
AnishGulati |
8de8c0 |
lottie["st"] = 0 # Don't know yet
|
|
AnishGulati |
a3579e |
get_blend(lottie, layer)
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
8de8c0 |
hasMask = True
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
8de8c0 |
lottie["hasMask"] = hasMask
|
|
AnishGulati |
8de8c0 |
lottie["masksProperties"] = []
|
|
AnishGulati |
8de8c0 |
lottie["masksProperties"].append({})
|
|
AnishGulati |
8de8c0 |
|
|
AnishGulati |
ac3983 |
if layer.get_type() in {"star", "circle", "rectangle", "filled_rectangle"}:
|
|
AnishGulati |
7c2169 |
bline_point = layer
|
|
AnishGulati |
1292be |
else:
|
|
AnishGulati |
28ce21 |
bline_point = layer.get_param("bline", "vector_list")
|
|
AnishGulati |
0eb03b |
|
|
AnishGulati |
8f8d53 |
gen_mask(lottie["masksProperties"][0], invert, bline_point, index.inc())
|