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.utils import animation as anutils 0012 from lottie import Color, Point 0013 from lottie.objects import easing 0014 0015 0016 rot_time = 45 0017 an = objects.Animation(rot_time*4) 0018 0019 0020 layer = objects.ShapeLayer() 0021 an.add_layer(layer) 0022 0023 0024 def add_shape(shape, color, parent): 0025 g = parent.add_shape(objects.Group()) 0026 s = g.add_shape(shape) 0027 g.add_shape(objects.Fill(color)) 0028 return s 0029 0030 0031 face1 = add_shape(objects.Ellipse(), Color(1, 1, 0), layer) 0032 face2 = add_shape(objects.Ellipse(), Color(0, 1, 0), layer) 0033 0034 side = layer.add_shape(objects.Group()) 0035 side1 = add_shape(objects.Ellipse(), Color(1, 0, 0), side) 0036 side2 = add_shape(objects.Ellipse(), Color(1, 0, 0), side) 0037 sider = add_shape(objects.Rect(), Color(1, 0, 0), side) 0038 0039 0040 width = 10 0041 0042 face1.size.add_keyframe(rot_time*0, Point(256, 256), easing.EaseIn()) 0043 face1.size.add_keyframe(rot_time*1, Point(0, 256)) 0044 face1.size.add_keyframe(rot_time*2, Point(0, 256)) 0045 face1.size.add_keyframe(rot_time*3, Point(0, 256), easing.EaseOut()) 0046 face1.size.add_keyframe(rot_time*4, Point(256, 256)) 0047 face1.position.add_keyframe(rot_time*0, Point(256, 256), easing.EaseIn()) 0048 face1.position.add_keyframe(rot_time*1, Point(256-width, 256)) 0049 face1.position.add_keyframe(rot_time*2, Point(256-width, 256)) 0050 face1.position.add_keyframe(rot_time*3, Point(256+width, 256), easing.EaseOut()) 0051 face1.position.add_keyframe(rot_time*4, Point(256, 256)) 0052 0053 0054 face2.size.add_keyframe(rot_time*0, Point(0, 256)) 0055 face2.size.add_keyframe(rot_time*1, Point(0, 256), easing.EaseOut()) 0056 face2.size.add_keyframe(rot_time*2, Point(256, 256), easing.EaseIn()) 0057 face2.size.add_keyframe(rot_time*3, Point(0, 256)) 0058 face2.position.add_keyframe(rot_time*0, Point(256+width, 256)) 0059 face2.position.add_keyframe(rot_time*1, Point(256+width, 256), easing.EaseOut()) 0060 face2.position.add_keyframe(rot_time*2, Point(256, 256), easing.EaseIn()) 0061 face2.position.add_keyframe(rot_time*3, Point(256-width, 256)) 0062 0063 0064 side1.size = face1.size 0065 side1.position.add_keyframe(rot_time*0, Point(256, 256), easing.EaseIn()) 0066 side1.position.add_keyframe(rot_time*1, Point(256+width, 256)) 0067 side1.position.add_keyframe(rot_time*2, Point(256-width, 256)) 0068 side1.position.add_keyframe(rot_time*3, Point(256-width, 256), easing.EaseOut()) 0069 side1.position.add_keyframe(rot_time*4, Point(256, 256)) 0070 0071 sider.position.value = Point(256, 256) 0072 sider.size.add_keyframe(rot_time*0, Point(0, 256)) 0073 sider.size.add_keyframe(rot_time*1, Point(2*width, 256)) 0074 sider.size.add_keyframe(rot_time*2, Point(0, 256)) 0075 sider.size.add_keyframe(rot_time*3, Point(2*width, 256)) 0076 0077 side2.size = face2.size 0078 side2.position.add_keyframe(rot_time*0, Point(256-width, 256)) 0079 side2.position.add_keyframe(rot_time*1, Point(256-width, 256), easing.EaseOut()) 0080 side2.position.add_keyframe(rot_time*2, Point(256, 256), easing.EaseIn()) 0081 side2.position.add_keyframe(rot_time*3, Point(256+width, 256)) 0082 side2.position.add_keyframe(rot_time*4, Point(256-width, 256)) 0083 0084 0085 script.script_main(an)