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
0011 from lottie.utils import color
0012 
0013 
0014 an = objects.Animation(59)
0015 
0016 layer = objects.ShapeLayer()
0017 an.add_layer(layer)
0018 
0019 heart = objects.Bezier()
0020 heart.add_point(Point(50, 20), Point(50, -20), Point(-50, -20))
0021 heart.add_smooth_point(Point(0, 50), Point(-5, -10))
0022 heart.add_smooth_point(Point(50, 100), Point(-10, 0))
0023 heart.add_smooth_point(Point(100, 50), Point(-5, 10))
0024 heart.closed = True
0025 antiheart = (
0026     objects.Bezier()
0027     .add_smooth_point(Point(50, 0), Point(10, 0))
0028     .add_smooth_point(Point(0, 50), Point(0, -20))
0029     .add_point(Point(50, 80), Point(-50, 20), Point(50, 20))
0030     .add_smooth_point(Point(100, 50), Point(0, 20))
0031     .close()
0032 )
0033 
0034 g1 = layer.add_shape(objects.Group())
0035 g1.transform.position.value = Point(100, 200)
0036 shape = g1.add_shape(objects.Path())
0037 shape.shape.value = heart
0038 
0039 g2 = layer.add_shape(objects.Group())
0040 g2.transform.position.value = Point(300, 200)
0041 animated = g2.add_shape(objects.Path())
0042 animated.shape.add_keyframe(0, heart)
0043 animated.shape.add_keyframe(30, antiheart)
0044 animated.shape.add_keyframe(59, heart)
0045 
0046 
0047 fill = layer.add_shape(objects.Fill(color.from_uint8(255, 0, 0)))
0048 stroke = layer.add_shape(objects.Stroke(Color(0, 0, 0), 5))
0049 
0050 
0051 script.script_main(an)