5 sys.path.insert(0, os.path.join(
6 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
10 from lottie
import objects
12 from lottie
import Point, Color, Size
14 an = objects.Animation(180)
16 layer = objects.ShapeLayer()
20 (easing.Linear(), Color(1, 1, 1)),
21 (easing.Jump(), Color(0, 0, 0)),
22 (easing.EaseOut(1), Color(1, 0, 0)),
23 (easing.EaseOut(1 / 2), Color(1 / 2, 0, 0)),
24 (easing.EaseOut(1 / 3), Color(1 / 3, 0, 0)),
25 (easing.EaseOut(1 / 5), Color(1 / 5, 0, 0)),
26 (easing.EaseOut(1 / 10), Color(1 / 19, 0, 0)),
27 (easing.EaseIn(1), Color(0, 1, 0)),
28 (easing.EaseIn(1 / 2), Color(0, 1 / 2, 0)),
29 (easing.EaseIn(1 / 3), Color(0, 1 / 3, 0)),
30 (easing.EaseIn(1 / 5), Color(0, 1 / 5, 0)),
31 (easing.EaseIn(1 / 10), Color(0, 1 / 10, 0)),
32 (easing.Sigmoid(1), Color(0, 0, 1)),
33 (easing.Sigmoid(1 / 2), Color(0, 0, 1 / 2)),
34 (easing.Sigmoid(1 / 3), Color(0, 0, 1 / 3)),
35 (easing.Sigmoid(1 / 5), Color(0, 0, 1 / 5)),
36 (easing.Sigmoid(1 / 10), Color(0, 0, 1 / 10)),
38 height = 512 / len(easings)
41 for i
in range(len(easings)):
42 group = layer.add_shape(objects.Group())
44 rectgroup = group.add_shape(objects.Group())
45 rect = rectgroup.add_shape(objects.Rect())
46 rect.size.value =
Size(width, height)
47 y = i * height + height / 2
48 group.transform.position.add_keyframe(0,
Point(width / 2, y), easings[i][0])
49 group.transform.position.add_keyframe(90,
Point(512 - width / 2, y), easings[i][0])
50 group.transform.position.add_keyframe(180,
Point(width / 2, y), easings[i][0])
51 rectgroup.add_shape(objects.Fill(easings[i][1]))
53 bezgroup = group.insert_shape(0, objects.Group())
54 bez = group.transform.position.keyframes[0].bezier()
55 bezgroup.transform.scale.value =
Size(100*width, -100*height)
56 bezgroup.transform.position.value =
Point(-width/2, width/2)
57 bezgroup.add_shape(objects.Path()).shape.value = bez
58 sc = Color(0, 0, 0)
if easings[i][1].length == math.sqrt(3)
else Color(1, 1, 1)
59 bezgroup.add_shape(objects.Stroke(sc, 0.1))
63 script.script_main(an)
Package with all the Lottie Python bindings.