python-lottie  0.6.10+dev2509936
A framework to work with lottie files and telegram animated stickers (tgs)
easing.py
Go to the documentation of this file.
1 import math
2 from .base import LottieObject, LottieProp, PseudoList, PseudoBool
3 
4 
5 ## @ingroup Lottie
7  """!
8  Bezier handle for keyframe interpolation
9  """
10  _props = [
11  LottieProp("x", "x", list=PseudoList),
12  LottieProp("y", "y", list=PseudoList),
13  ]
14 
15  def __init__(self, x=0, y=0):
16  ## x position of the handle.
17  ## This represents the change in time of the keyframe
18  self.x = x
19  ## y position of the handle.
20  ## This represents the change in value of the keyframe
21  self.y = y
22 
23 
24 class Linear:
25  """!
26  Linear easing, the value will change from start to end in a straight line
27  """
28  def __call__(self, keyframe):
29  keyframe.out_value = KeyframeBezierHandle(
30  0,
31  0
32  )
33  keyframe.in_value = KeyframeBezierHandle(
34  1,
35  1
36  )
37 
38 
39 class EaseIn:
40  """!
41  The value lingers near the start before accelerating towards the end
42  """
43  def __init__(self, delay=1/3):
44  self.delay = delay
45 
46  def __call__(self, keyframe):
47  keyframe.out_value = KeyframeBezierHandle(
48  self.delay,
49  0
50  )
51  keyframe.in_value = KeyframeBezierHandle(
52  1,
53  1
54  )
55 
56 
57 class EaseOut:
58  """!
59  The value starts fast before decelerating towards the end
60  """
61  def __init__(self, delay=1/3):
62  self.delay = delay
63 
64  def __call__(self, keyframe):
65  keyframe.out_value = KeyframeBezierHandle(
66  0,
67  0
68  )
69  keyframe.in_value = KeyframeBezierHandle(
70  1-self.delay,
71  1
72  )
73 
74 
75 class Jump:
76  """!
77  Jumps to the end value at the end of the keyframe
78  """
79  def __call__(self, keyframe):
80  keyframe.jump = True
81 
82 
83 class Sigmoid:
84  """!
85  Combines the effects of EaseIn and EaseOut
86  """
87  def __init__(self, delay=1/3):
88  self.delay = delay
89 
90  def __call__(self, keyframe):
91  keyframe.out_value = KeyframeBezierHandle(
92  self.delay,
93  0
94  )
95  keyframe.in_value = KeyframeBezierHandle(
96  1 - self.delay,
97  1
98  )
99 
100 
101 class Split:
102  """
103  Uses different easing methods for in/out
104  """
105 
106  def __init__(self, out_ease, in_ease):
107  self.out_ease = out_ease
108  self.in_ease = in_ease
109 
110  def __call__(self, keyframe):
111  self.out_ease(keyframe)
112  t = keyframe.out_value
113  self.in_ease(keyframe)
114  keyframe.out_value = t
lottie.objects.easing.EaseOut.__call__
def __call__(self, keyframe)
Definition: easing.py:64
lottie.objects.easing.Jump.__call__
def __call__(self, keyframe)
Definition: easing.py:79
lottie.objects.easing.EaseOut.delay
delay
Definition: easing.py:62
lottie.objects.base.LottieObject
Base class for mapping Python classes into Lottie JSON objects.
Definition: base.py:224
lottie.objects.easing.Sigmoid.__init__
def __init__(self, delay=1/3)
Definition: easing.py:87
lottie.objects.easing.EaseOut.__init__
def __init__(self, delay=1/3)
Definition: easing.py:61
lottie.objects.easing.KeyframeBezierHandle.y
y
y position of the handle.
Definition: easing.py:21
lottie.objects.easing.Linear.__call__
def __call__(self, keyframe)
Definition: easing.py:28
lottie.objects.easing.EaseOut
The value starts fast before decelerating towards the end.
Definition: easing.py:57
lottie.objects.easing.Linear
Linear easing, the value will change from start to end in a straight line.
Definition: easing.py:24
lottie.objects.easing.KeyframeBezierHandle
Bezier handle for keyframe interpolation.
Definition: easing.py:6
lottie.objects.base.LottieProp
Lottie <-> Python property mapper.
Definition: base.py:88
lottie.objects.easing.Sigmoid.__call__
def __call__(self, keyframe)
Definition: easing.py:90
lottie.objects.easing.EaseIn.__call__
def __call__(self, keyframe)
Definition: easing.py:46
lottie.objects.easing.EaseIn.__init__
def __init__(self, delay=1/3)
Definition: easing.py:43
lottie.objects.easing.EaseIn
The value lingers near the start before accelerating towards the end.
Definition: easing.py:39
lottie.objects.easing.KeyframeBezierHandle.x
x
x position of the handle.
Definition: easing.py:18
lottie.objects.easing.Split.__init__
def __init__(self, out_ease, in_ease)
Definition: easing.py:106
lottie.objects.easing.Split.out_ease
out_ease
Definition: easing.py:107
lottie.objects.easing.Sigmoid
Combines the effects of EaseIn and EaseOut.
Definition: easing.py:83
lottie.objects.easing.KeyframeBezierHandle.__init__
def __init__(self, x=0, y=0)
Definition: easing.py:15
lottie.objects.easing.Split
Definition: easing.py:101
lottie.objects.easing.Split.__call__
def __call__(self, keyframe)
Definition: easing.py:110
lottie.objects.easing.EaseIn.delay
delay
Definition: easing.py:44
lottie.objects.easing.Split.in_ease
in_ease
Definition: easing.py:108
lottie.objects.easing.Sigmoid.delay
delay
Definition: easing.py:88
lottie.objects.easing.Jump
Jumps to the end value at the end of the keyframe.
Definition: easing.py:75