python-lottie  0.7.0+dev54c8cce
A framework to work with lottie files and telegram animated stickers (tgs)
masks.py
1 #!/usr/bin/env python3
2 
3 import sys
4 import os
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.parsers.svg import parse_svg_file
12 from lottie import Point, Color
13 
14 
15 an = parse_svg_file(os.path.join(
16  os.path.dirname(os.path.abspath(__file__)),
17  "blep.svg"
18 ))
19 
20 
21 maskshape = objects.Star()
22 maskshape.inner_radius.value = 100
23 maskshape.outer_radius.value = 200
24 maskshape.rotation.value = 180
25 maskshape.position.value = Point(256, 256)
26 #maskshape.size.value = Point(256, 256)
27 maskbez = maskshape.to_bezier()
28 
29 mask = objects.Mask(maskbez.shape.value)
30 an.layers[0].masks = [mask]
31 
32 
33 g = an.layers[0].add_shape(objects.Group())
34 r = g.add_shape(objects.Rect())
35 r.position.value = Point(256, 256)
36 r.size.value = Point(512, 512)
37 g.add_shape(objects.Fill(Color(1, 1, 1)))
38 
39 
40 script.script_main(an)
def Point(x, y)
Definition: nvector.py:135
def parse_svg_file(file, layer_frames=0, *args, **kwargs)
Definition: importer.py:1321