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.utils.animation import follow_path
0011 from lottie import Point, Color
0012 
0013 an = objects.Animation(180)
0014 
0015 layer = objects.ShapeLayer()
0016 an.add_layer(layer)
0017 
0018 group = layer.add_shape(objects.Group())
0019 ball = group.add_shape(objects.Ellipse())
0020 ball.size.value = Point(10, 10)
0021 
0022 r1 = group.add_shape(objects.Rect())
0023 r1.size.value = Point(50, 10)
0024 
0025 r2 = group.add_shape(objects.Group())
0026 r2.add_shape(objects.Rect()).size.value = Point(50, 10)
0027 r2 = r2.transform
0028 
0029 group.add_shape(objects.Fill(Color(0, 1, 0)))
0030 
0031 group = layer.add_shape(objects.Group())
0032 bez = group.add_shape(objects.Path())
0033 bez.shape.value.add_point(Point(256, 128), Point(0, 0), Point(64, 64))
0034 bez.shape.value.add_point(Point(256, 256), Point(-64, -64), Point(-64, 64))
0035 bez.shape.value.add_point(Point(256, 256+120), Point(0, 0), Point(0, 0))
0036 group.add_shape(objects.Stroke(Color(1, 0, 0), 10))
0037 
0038 follow_path(ball.position, bez.shape.value,  0,  90, 30, False, Point(0, 0))
0039 follow_path(ball.position, bez.shape.value, 90, 180, 30,  True, Point(0, 0))
0040 
0041 follow_path(r1.position, bez.shape.value,  0,  90, 30, False, Point(150, 0))
0042 follow_path(r1.position, bez.shape.value, 90, 180, 30,  True, Point(150, 0))
0043 
0044 follow_path(r2.position, bez.shape.value,  0,  90, 30, False, Point(-150, 0), 0, r2.rotation, 90)
0045 follow_path(r2.position, bez.shape.value, 90, 180, 30,  True, Point(-150, 0), 0, r2.rotation, 90)
0046 
0047 script.script_main(an)