python-lottie  0.7.0+dev66cafb9
A framework to work with lottie files and telegram animated stickers (tgs)
bezier_segment.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 import animation as anutils
11 from lottie import Point, Color
12 
13 
14 an = objects.Animation(180)
15 
16 layer = objects.ShapeLayer()
17 an.add_layer(layer)
18 
19 group = layer.add_shape(objects.Group())
20 bez = group.add_shape(objects.Path())
21 bez.shape.value.add_point(Point(256, 128), Point(0, 0), Point(64, 64))
22 bez.shape.value.add_smooth_point(Point(256, 256+120), Point(32, -32))
23 bez.shape.value.add_point(Point(256, 256), Point(-64, -64), Point(-64, 64))
24 bez.shape.value.add_point(Point(128, 256+120), Point(64, 64), Point(0, 0))
25 group.add_shape(objects.Stroke(Color(1, 0, 0), 10))
26 
27 
28 group = layer.add_shape(objects.Group())
29 sh = anutils.generate_path_segment(bez.shape.value, 0, 180, 60, 180, 60, True)
30 group.add_shape(sh)
31 group.add_shape(objects.Stroke(Color(0, 1, 0), 20))
32 
33 
34 script.script_main(an)
35 
def Point(x, y)
Definition: nvector.py:135