python-lottie  0.6.10+dev2509936
A framework to work with lottie files and telegram animated stickers (tgs)
fill_rule.py
1 #!/usr/bin/env python3
2 import os
3 import sys
4 import math
5 sys.path.insert(0, os.path.join(
6  os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
7  "lib"
8 ))
9 from lottie.utils import script
10 from lottie import objects
11 from lottie.nvector import Point, PolarVector
12 from lottie.utils import color
13 
14 
15 an = objects.Animation(59)
16 
17 layer = objects.ShapeLayer()
18 an.add_layer(layer)
19 
20 
21 bezier = objects.Bezier()
22 radius = 128
23 angle = -math.pi / 2
24 for i in range(5+1):
25  bezier.add_point(PolarVector(radius, angle))
26  angle += 2 * math.pi * 2 / 5
27 bezier.closed = True
28 bezier.reverse()
29 
30 g = layer.add_shape(objects.Group())
31 g.transform.position.value = Point(radius, radius)
32 g.add_shape(objects.Path(bezier))
33 fill = g.add_shape(objects.Fill(color.from_uint8(255, 0, 100)))
34 fill.fill_rule = objects.FillRule.NonZero
35 
36 g = layer.add_shape(objects.Group())
37 g.transform.position.value = Point(512-radius, 512-radius)
38 g.add_shape(objects.Path(bezier))
39 fill = g.add_shape(objects.Fill(color.from_uint8(255, 100, 0)))
40 fill.fill_rule = objects.FillRule.EvenOdd
41 
42 script.script_main(an)
43 
lottie.nvector
Definition: nvector.py:1
lottie.nvector.PolarVector
def PolarVector(length, theta)
Definition: nvector.py:147
lottie.nvector.Point
def Point(x, y)
Definition: nvector.py:135
lottie.utils
Definition: __init__.py:1