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

0001 #!/usr/bin/env python3
0002 import sys
0003 import os
0004 import math
0005 sys.path.insert(0, os.path.join(
0006     os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
0007     "lib"
0008 ))
0009 from lottie.utils import script
0010 from lottie import objects
0011 from lottie.utils import animation as anutils
0012 from lottie import Point, Color, Point3D, Size
0013 
0014 an = objects.Animation(120)
0015 
0016 layer = objects.ShapeLayer()
0017 an.add_layer(layer)
0018 
0019 # Build a sphere out of circles
0020 balls = []
0021 axes = [
0022     Point(1, 0),
0023     Point(0, 1),
0024 ]
0025 for i in range(20):
0026     a = i/20 * math.pi * 2
0027     for axis in axes:
0028         g = layer.add_shape(objects.Group())
0029         b = g.add_shape(objects.Ellipse())
0030         b.size.value = Size(20, 20)
0031         xz = axis * math.sin(a)*128
0032         pos = Point3D(256+xz[0], 256+math.cos(a)*128, xz[1])
0033         b.position.value = pos
0034         balls.append(b)
0035         g.add_shape(objects.Fill(Color(0, 1, 0)))
0036 
0037 # Animate the circles using depth rotation
0038 dr = anutils.DepthRotationDisplacer(Point3D(256, 256, 0), 0, 120, 10, Point3D(0, 2, -1))
0039 for b in balls:
0040     dr.animate_point(b.position)
0041 
0042 script.script_main(an)