INNER CODE UNIT · Python
clean_shapes
OpenVGLab/OmniLottie · app.py:322
def clean_shapes(shapes):
if not isinstance(shapes, list):
return shapes
cleaned = []
for sh in shapes:
if not isinstance(sh, dict):
continue
if sh.get("ty") == "gr":
sh["it"] = clean_shapes(sh.get("it", []))
if not sh["it"]:
continue
has_tr = any(item.get("ty") == "tr" for item in sh["it"] if isinstance(item, dict))
if not has_tr:
sh["it"].append({
"ty": "tr", "nm": "",
"a": {"a": 0, "k": [0, 0], "ix": 1},
"p": {"a": 0, "k": [0, 0], "ix": 2},
"s": {"a": 0, "k": [100, 100], "ix": 3},