File indexing completed on 2025-01-19 04:00:00
0001 #!/usr/bin/env python3 0002 import sys 0003 import os 0004 import math 0005 sys.path.insert(0, os.path.join( 0006 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 0007 "lib" 0008 )) 0009 from lottie.utils import script 0010 from lottie import objects 0011 from lottie.objects import easing 0012 from lottie import Point, Color, Size 0013 0014 an = objects.Animation(180) 0015 0016 layer = objects.ShapeLayer() 0017 an.add_layer(layer) 0018 0019 easings = [ 0020 (easing.Linear(), Color(1, 1, 1)), 0021 (easing.Jump(), Color(0, 0, 0)), 0022 (easing.EaseOut(1), Color(1, 0, 0)), 0023 (easing.EaseOut(1 / 2), Color(1 / 2, 0, 0)), 0024 (easing.EaseOut(1 / 3), Color(1 / 3, 0, 0)), 0025 (easing.EaseOut(1 / 5), Color(1 / 5, 0, 0)), 0026 (easing.EaseOut(1 / 10), Color(1 / 19, 0, 0)), 0027 (easing.EaseIn(1), Color(0, 1, 0)), 0028 (easing.EaseIn(1 / 2), Color(0, 1 / 2, 0)), 0029 (easing.EaseIn(1 / 3), Color(0, 1 / 3, 0)), 0030 (easing.EaseIn(1 / 5), Color(0, 1 / 5, 0)), 0031 (easing.EaseIn(1 / 10), Color(0, 1 / 10, 0)), 0032 (easing.Sigmoid(1), Color(0, 0, 1)), 0033 (easing.Sigmoid(1 / 2), Color(0, 0, 1 / 2)), 0034 (easing.Sigmoid(1 / 3), Color(0, 0, 1 / 3)), 0035 (easing.Sigmoid(1 / 5), Color(0, 0, 1 / 5)), 0036 (easing.Sigmoid(1 / 10), Color(0, 0, 1 / 10)), 0037 ] 0038 height = 512 / len(easings) 0039 width = height 0040 0041 for i in range(len(easings)): 0042 group = layer.add_shape(objects.Group()) 0043 0044 rectgroup = group.add_shape(objects.Group()) 0045 rect = rectgroup.add_shape(objects.Rect()) 0046 rect.size.value = Size(width, height) 0047 y = i * height + height / 2 0048 group.transform.position.add_keyframe(0, Point(width / 2, y), easings[i][0]) 0049 group.transform.position.add_keyframe(90, Point(512 - width / 2, y), easings[i][0]) 0050 group.transform.position.add_keyframe(180, Point(width / 2, y), easings[i][0]) 0051 rectgroup.add_shape(objects.Fill(easings[i][1])) 0052 0053 bezgroup = group.insert_shape(0, objects.Group()) 0054 bez = group.transform.position.keyframes[0].bezier() 0055 bezgroup.transform.scale.value = Size(100*width, -100*height) 0056 bezgroup.transform.position.value = Point(-width/2, width/2) 0057 bezgroup.add_shape(objects.Path()).shape.value = bez 0058 sc = Color(0, 0, 0) if easings[i][1].length == math.sqrt(3) else Color(1, 1, 1) 0059 bezgroup.add_shape(objects.Stroke(sc, 0.1)) 0060 0061 0062 0063 script.script_main(an)