INNER CODE UNIT · Python
collect_pos
OpenVGLab/OmniLottie · app.py:292
def collect_pos(layer):
nonlocal max_x, max_y
p = layer.get("ks", {}).get("p", {})
if isinstance(p, dict):
if p.get("a", 0) == 0:
pv = p.get("k", [0, 0])
if isinstance(pv, list) and len(pv) >= 2:
max_x = max(max_x, float(pv[0]))
max_y = max(max_y, float(pv[1]))
else:
for kf in p.get("k", []):
if isinstance(kf, dict):
for sv in (kf.get("s", []), kf.get("e", [])):
if isinstance(sv, list) and len(sv) >= 2:
max_x = max(max_x, float(sv[0]))
max_y = max(max_y, float(sv[1]))
for sub in layer.get("layers", []):
collect_pos(sub)