python-lottie  0.6.10+dev2509936
A framework to work with lottie files and telegram animated stickers (tgs)
spring.py
1 #!/usr/bin/env python3
2 import sys
3 import os
4 sys.path.insert(0, os.path.join(
5  os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
6  "lib"
7 ))
8 from lottie.utils import script
9 from lottie import objects
10 from lottie.utils.animation import spring_pull
11 from lottie import Point, Color
12 
13 
14 an = objects.Animation(100)
15 
16 layer = objects.ShapeLayer()
17 an.add_layer(layer)
18 
19 settings = [
20  (Color(1, 1, 0), 128, 7),
21  (Color(1, 0, 0), 256, 15),
22  (Color(0, .5, 1), 384, 30),
23 ]
24 
25 for color, x, falloff in settings:
26  group = layer.add_shape(objects.Group())
27  ball = group.add_shape(objects.Ellipse())
28  ball.size.value = Point(100, 100)
29  group.add_shape(objects.Fill(color))
30  group.transform.position.value = Point(x, -100)
31  spring_pull(group.transform.position, Point(x, 256), 0, 60, falloff, 7)
32  group.transform.position.add_keyframe(85, Point(x, -100))
33 
34 
35 script.script_main(an)
lottie.utils.animation
Definition: animation.py:1
lottie.utils.animation.spring_pull
def spring_pull(position_prop, point, start_time, end_time, falloff=15, oscillations=7)
Definition: animation.py:43
lottie.nvector.Point
def Point(x, y)
Definition: nvector.py:135
lottie.utils
Definition: __init__.py:1