File indexing completed on 2025-01-19 04:00:00

0001 #!/usr/bin/env python3
0002 import sys
0003 import os
0004 sys.path.insert(0, os.path.join(
0005     os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
0006     "lib"
0007 ))
0008 import math
0009 from lottie.utils import script
0010 from lottie import objects
0011 from lottie.parsers.svg import parse_svg_file
0012 from lottie import Color
0013 
0014 last_frame = 60
0015 an = parse_svg_file(os.path.join(
0016     os.path.dirname(os.path.abspath(__file__)),
0017     "blep.svg"
0018 ), 0, last_frame)
0019 
0020 layer = an.find("durg")
0021 
0022 n_frames = 24
0023 for fill in layer.find_all((objects.Fill, objects.Stroke)):
0024     if isinstance(fill.color.value, list):
0025         import pdb; pdb.set_trace(); pass
0026     color = fill.color.value.converted(Color.Mode.LCH_uv)
0027 
0028     for frame in range(n_frames):
0029         off = frame / (n_frames-1)
0030         color.hue = (color.hue + math.tau / (n_frames-1)) % math.tau
0031         fill.color.add_keyframe(off * last_frame, color.to_rgb())
0032 
0033 
0034 script.script_main(an)