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 from lottie.utils import script
0009 from lottie import objects
0010 from lottie import Point, Color, NVector
0011 
0012 
0013 last_frame = 180
0014 an = objects.Animation(last_frame)
0015 
0016 
0017 layer = objects.ShapeLayer()
0018 an.add_layer(layer)
0019 layer.auto_orient = True
0020 
0021 group = layer.add_shape(objects.Group())
0022 star = objects.Star()
0023 star.inner_radius.value = 20
0024 star.outer_radius.value = 50
0025 star.position.value = Point(0, 0)
0026 group.add_shape(star)
0027 
0028 group.add_shape(objects.Ellipse(NVector(0, 35), NVector(16, 16)))
0029 
0030 layer.add_shape(objects.Fill(Color(1, 1, 0)))
0031 
0032 
0033 tl = 120
0034 layer.transform.position.add_keyframe(last_frame/4*0, Point(+50, 256), out_tan=NVector(0, -tl), in_tan=NVector(-tl, 0))
0035 layer.transform.position.add_keyframe(last_frame/4*1, Point(256, +50), out_tan=NVector(+tl, 0), in_tan=NVector(0, -tl))
0036 layer.transform.position.add_keyframe(last_frame/4*2, Point(462, 256), out_tan=NVector(0, +tl), in_tan=NVector(+tl, 0))
0037 layer.transform.position.add_keyframe(last_frame/4*3, Point(256, 462), out_tan=NVector(-tl, 0), in_tan=NVector(0, +tl))
0038 layer.transform.position.add_keyframe(last_frame/4*4, Point(+50, 256), out_tan=NVector(0, -tl), in_tan=NVector(-tl, 0))
0039 
0040 
0041 layer1 = objects.ShapeLayer()
0042 an.add_layer(layer1)
0043 layer1.add_shape(group)
0044 layer1.add_shape(objects.Fill(Color(1, 0, 0)))
0045 layer1.transform = layer.transform
0046 
0047 
0048 bg = an.add_layer(objects.ShapeLayer())
0049 track = bg.add_shape(objects.Path()).shape.value
0050 track.closed = True
0051 track.add_point(Point(+50, 256), NVector(0, +tl), NVector(0, -tl))
0052 track.add_point(Point(256, +50), NVector(-tl, 0), NVector(+tl, 0))
0053 track.add_point(Point(462, 256), NVector(0, -tl), NVector(0, +tl))
0054 track.add_point(Point(256, 462), NVector(+tl, 0), NVector(-tl, 0))
0055 bg.add_shape(objects.Stroke(Color(0, 0, 1), 50))
0056 
0057 
0058 script.script_main(an)
0059