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 import animation as anutils
0011 from lottie import Point, Color
0012 
0013 an = objects.Animation(60)
0014 
0015 layer = objects.ShapeLayer()
0016 an.add_layer(layer)
0017 g = layer.add_shape(objects.Group())
0018 
0019 sine_displacer = anutils.SineDisplacer(300, 50, 0, 60, 10, 1, 45)
0020 # Keep the left side fixed
0021 displacer = anutils.DisplacerDampener(sine_displacer, lambda p: p.x / 128 if p.x < 128 else 1)
0022 
0023 for i in range(0, 512+1, 16):
0024     b = g.add_shape(objects.Ellipse())
0025     b.size.value = Point(16, 16)
0026     b.position.value = Point(i, 100)
0027     displacer.animate_point(b.position)
0028 
0029 
0030 bez = g.add_shape(objects.Path())
0031 bez.shape.value.add_smooth_point(Point(256, 200), Point(50, 0))
0032 bez.shape.value.add_smooth_point(Point(156, 300), Point(0, -50))
0033 bez.shape.value.add_smooth_point(Point(256, 400), Point(-50, 0))
0034 bez.shape.value.add_smooth_point(Point(356, 300), Point(0, 50))
0035 bez.shape.value.close()
0036 bez.shape.value.split_self_chunks(8)
0037 displacer.animate_bezier(bez.shape)
0038 
0039 g.add_shape(objects.Fill(Color(1, 1, 0)))
0040 
0041 
0042 g = layer.add_shape(objects.Group())
0043 bez = g.add_shape(objects.Path())
0044 g.add_shape(objects.Stroke(Color(1, 0, 0), 5))
0045 g.add_shape(objects.Fill(Color(0, 0, 1)))
0046 for i in range(9):
0047     bez.shape.value.add_point(Point(i*64, 160), Point(-20, 0), Point(20, 0))
0048 
0049 for i in range(9):
0050     bez.shape.value.add_point(Point(512-i*64, 420), Point(20, 0), Point(-20, 0))
0051 bez.shape.value.close()
0052 displacer.animate_bezier(bez.shape)
0053 
0054 
0055 script.script_main(an)
0056 
0057