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 base = an.add_layer(objects.NullLayer())
0018 base.transform.anchor_point.value = base.transform.position.value = Point(256, 256)
0019 base.transform.rotation.add_keyframe(0, 0)
0020 base.transform.rotation.add_keyframe(last_frame, 360)
0021 
0022 
0023 star_layer = objects.ShapeLayer()
0024 base.add_child(star_layer)
0025 star = star_layer.add_shape(objects.Star())
0026 star.inner_radius.value = 20
0027 star.outer_radius.value = 50
0028 star.position.value = Point(50, 50)
0029 star_layer.add_shape(objects.Fill(Color(1, 1, 0)))
0030 star_layer.add_shape(objects.Stroke(Color(0, 0, 0), 5))
0031 star_layer.transform.anchor_point = star.position
0032 star_layer.transform.position.value = Point(50, 256)
0033 star_layer.transform.rotation.add_keyframe(0, 0)
0034 star_layer.transform.rotation.add_keyframe(last_frame, -360)
0035 
0036 
0037 circle_layer = objects.ShapeLayer()
0038 an.add_layer(circle_layer)
0039 circle_layer.parent = base
0040 circle = circle_layer.add_shape(objects.Ellipse())
0041 circle.size.value = NVector(100, 100)
0042 circle_layer.add_shape(objects.Fill(Color(1, 0, 0)))
0043 circle_layer.add_shape(objects.Stroke(Color(0, 0, 0), 5))
0044 circle_layer.transform.position.add_keyframe(0, Point(256, 512-50))
0045 circle_layer.transform.position.add_keyframe(last_frame/2, Point(256, 50))
0046 circle_layer.transform.position.add_keyframe(last_frame, Point(256, 512-50))
0047 
0048 
0049 scl = base.add_child(objects.SolidColorLayer("#0000ff"))
0050 scl.transform.scale.value.x *= 0.2
0051 scl.transform.position.value.x = 205
0052 
0053 
0054 star_background = star_layer.add_child(objects.SolidColorLayer("#0000ff", 100, 100))
0055 
0056 
0057 script.script_main(an)
0058