python-lottie  0.6.10+devbd5499b
A framework to work with lottie files and telegram animated stickers (tgs)
text.py
Go to the documentation of this file.
1 from .base import LottieObject, LottieProp, LottieEnum
2 from .properties import Value, MultiDimensional
3 from ..nvector import NVector
4 from .helpers import Transform
5 
6 
7 ## @ingroup Lottie
8 ## @ingroup LottieCheck
10  _props = [
11  LottieProp("mask", "m", float),
12  LottieProp("f", "f", Value),
13  LottieProp("l", "l", Value),
14  LottieProp("r", "r", float),
15  ]
16 
17  def __init__(self):
18  ## Type?
19  self.mask = None
20  ## First?
21  self.f = None
22  ## Last?
23  self.l = None
24  ## ??
25  self.r = None
26 
27 
28 ## @ingroup Lottie
29 ## @ingroup LottieCheck
31  _props = [
32  LottieProp("rx", "rx", Value),
33  LottieProp("ry", "ry", Value),
34  LottieProp("stroke_width", "sw", Value),
35  LottieProp("stroke_color", "sc", MultiDimensional),
36  LottieProp("fill_color", "fc", MultiDimensional),
37  LottieProp("fh", "fh", Value),
38  LottieProp("fs", "fs", Value),
39  LottieProp("fb", "fb", Value),
40  LottieProp("tracking", "t", Value),
41  LottieProp("scale", "s", MultiDimensional),
42  ]
43 
44  def __init__(self):
45  super().__init__()
46  ## Angle?
47  self.rx = Value()
48  ## Angle?
49  self.ry = Value()
50  ## Stroke width
52  ## Stroke color
54  ## Fill color
56  self.fh = Value()
57  ## 0-100?
58  self.fs = Value()
59  ## 0-100?
60  self.fb = Value()
61  ## Tracking
62  self.tracking = Value()
63 
64 
65 ## @ingroup Lottie
66 ## @ingroup LottieCheck
68  _props = [
69  LottieProp("alignment", "a", MultiDimensional),
70  LottieProp("g", "g", float),
71  ]
72 
73  def __init__(self):
75  self.g = None
76 
77 
78 ## @ingroup Lottie
80  Left = 0
81  Right = 1
82  Center = 2
83 
84 
85 ## @ingroup Lottie
87  """!
88  @see http://docs.aenhancers.com/other/textdocument/
89 
90  Note that for multi-line text, lines are separated by \\r
91  """
92  _props = [
93  LottieProp("font_family", "f", str),
94  LottieProp("color", "fc", NVector),
95  LottieProp("font_size", "s", float),
96  LottieProp("line_height", "lh", float),
97  LottieProp("wrap_size", "sz", NVector),
98  LottieProp("text", "t", str),
99  LottieProp("justify", "j", TextJustify),
100  # ls?
101  ]
102 
103  def __init__(self, text="", font_size=10, color=None, font_family=""):
104  self.font_family = font_family
105  ## Text color
106  self.color = color or NVector(0, 0, 0)
107  ## Line height when wrapping
108  self.line_height = None
109  ## Text alignment
110  self.justify = TextJustify.Left
111  ## Size of the box containing the text
112  self.wrap_size = None
113  ## Text
114  self.text = text
115  ## Font Size
116  self.font_size = font_size
117 
118 
119 ## @ingroup Lottie
121  _props = [
122  LottieProp("start", "s", TextDocument),
123  LottieProp("time", "t", float),
124  ]
125 
126  def __init__(self, time=0, start=None):
127  ## Start value of keyframe segment.
128  self.start = start
129  ## Start time of keyframe segment.
130  self.time = time
131 
132 
133 ## @ingroup Lottie
135  _props = [
136  LottieProp("keyframes", "k", TextDataKeyframe, True),
137  ]
138 
139  def __init__(self):
140  self.keyframes = []
141 
142  def get_value(self, time):
143  for kf in self.keyframes:
144  if kf.time >= time:
145  return kf.start
146  return None
147 
148 
149 ## @ingroup Lottie
151  _props = [
152  LottieProp("properties", "a", TextAnimatorDataProperty, True),
153  LottieProp("data", "d", TextData, False),
154  LottieProp("more_options", "m", TextMoreOptions, False),
155  LottieProp("masked_path", "p", MaskedPath),
156  ]
157 
158  def __init__(self):
159  self.properties = []
160  self.data = TextData()
163 
164  def add_keyframe(self, time, item):
165  self.data.keyframes.append(TextDataKeyframe(time, item))
166 
167  def get_value(self, time):
168  return self.data.get_value(time)
169 
170 
171 ## @ingroup Lottie
173  Unknown = 0
174  CssUrl = 1
175  ScriptUrl = 2
176  FontUrl = 3
177 
178 
179 ## @ingroup Lottie
181  _props = [
182  LottieProp("ascent", "ascent", float),
183  LottieProp("font_family", "fFamily", str),
184  LottieProp("name", "fName", str),
185  LottieProp("font_style", "fStyle", str),
186  LottieProp("path", "fPath", str),
187  LottieProp("weight", "fWeight", str),
188  LottieProp("origin", "origin", FontPathOrigin),
189  ]
190 
191  def __init__(self, font_family="sans", font_style="Regular", name=None):
192  self.ascent = None
193  self.font_family = font_family
194  self.font_style = font_style
195  self.name = name or "%s-%s" % (font_family, font_style)
196  self.path = None
197  self.weight = None
198  self.origin = None
199 
200 
201 ## @ingroup Lottie
203  _props = [
204  LottieProp("list", "list", Font, True),
205  ]
206 
207  def __init__(self):
208  self.list = []
209 
210  def append(self, font):
211  self.list.append(font)
lottie.objects.text.TextAnimatorData.masked_path
masked_path
Definition: text.py:162
lottie.objects.text.MaskedPath.l
l
Last?
Definition: text.py:23
lottie.objects.text.TextAnimatorData.more_options
more_options
Definition: text.py:161
lottie.objects.properties.Value
An animatable property that holds a float.
Definition: properties.py:608
lottie.objects.text.FontList
Definition: text.py:202
lottie.objects.text.TextAnimatorData.data
data
Definition: text.py:160
lottie.objects.text.TextDataKeyframe.start
start
Start value of keyframe segment.
Definition: text.py:128
lottie.objects.text.TextAnimatorDataProperty.fill_color
fill_color
Fill color.
Definition: text.py:55
lottie.objects.text.TextMoreOptions
Definition: text.py:67
lottie.objects.text.TextDocument.font_size
font_size
Font Size.
Definition: text.py:116
lottie.objects.text.TextAnimatorDataProperty
Definition: text.py:30
lottie.objects.text.TextData.__init__
def __init__(self)
Definition: text.py:139
lottie.objects.text.Font.path
path
Definition: text.py:196
lottie.objects.text.FontPathOrigin
Definition: text.py:172
lottie.objects.text.TextData.keyframes
keyframes
Definition: text.py:140
lottie.objects.text.TextDocument.justify
justify
Text alignment.
Definition: text.py:110
lottie.objects.text.TextAnimatorDataProperty.__init__
def __init__(self)
Definition: text.py:44
lottie.objects.text.Font
Definition: text.py:180
lottie.objects.text.TextAnimatorDataProperty.fs
fs
0-100?
Definition: text.py:58
lottie.objects.text.TextData.get_value
def get_value(self, time)
Definition: text.py:142
lottie.objects.text.FontList.list
list
Definition: text.py:208
lottie.objects.text.TextMoreOptions.g
g
Definition: text.py:75
lottie.objects.text.TextDocument.line_height
line_height
Line height when wrapping.
Definition: text.py:108
lottie.objects.base.LottieObject
Base class for mapping Python classes into Lottie JSON objects.
Definition: base.py:224
lottie.objects.text.TextDataKeyframe.__init__
def __init__(self, time=0, start=None)
Definition: text.py:126
lottie.objects.text.TextDocument.color
color
Text color.
Definition: text.py:106
lottie.objects.text.TextDocument.text
text
Text.
Definition: text.py:114
lottie.objects.text.MaskedPath.r
r
??
Definition: text.py:25
lottie.objects.text.TextJustify
Definition: text.py:79
lottie.objects.text.TextAnimatorDataProperty.stroke_color
stroke_color
Stroke color.
Definition: text.py:53
lottie.objects.text.Font.name
name
Definition: text.py:195
lottie.objects.base.LottieProp
Lottie <-> Python property mapper.
Definition: base.py:88
lottie.objects.text.Font.ascent
ascent
Definition: text.py:192
lottie.objects.text.Font.origin
origin
Definition: text.py:198
lottie.objects.text.TextDataKeyframe
Definition: text.py:120
lottie.objects.text.TextAnimatorDataProperty.tracking
tracking
Tracking.
Definition: text.py:62
lottie.objects.text.TextAnimatorData.get_value
def get_value(self, time)
Definition: text.py:167
lottie.objects.text.TextAnimatorData.__init__
def __init__(self)
Definition: text.py:158
lottie.objects.text.TextDocument.__init__
def __init__(self, text="", font_size=10, color=None, font_family="")
Definition: text.py:103
lottie.objects.text.FontList.append
def append(self, font)
Definition: text.py:210
lottie.objects.text.TextDocument
Definition: text.py:86
lottie.objects.text.Font.__init__
def __init__(self, font_family="sans", font_style="Regular", name=None)
Definition: text.py:191
lottie.objects.text.TextData
Definition: text.py:134
lottie.objects.text.Font.font_style
font_style
Definition: text.py:194
lottie.objects.text.TextDocument.font_family
font_family
Definition: text.py:104
lottie.objects.base.LottieEnum
Base class for enum-like types in the Lottie JSON structure.
Definition: base.py:42
lottie.objects.text.TextDataKeyframe.time
time
Start time of keyframe segment.
Definition: text.py:130
lottie.objects.text.TextAnimatorDataProperty.rx
rx
Angle?
Definition: text.py:47
lottie.objects.text.TextAnimatorDataProperty.stroke_width
stroke_width
Stroke width.
Definition: text.py:51
lottie.objects.text.MaskedPath.f
f
First?
Definition: text.py:21
lottie.objects.text.MaskedPath.__init__
def __init__(self)
Definition: text.py:17
lottie.objects.helpers.Transform
Layer transform.
Definition: helpers.py:7
lottie.objects.text.TextAnimatorData.properties
properties
Definition: text.py:159
lottie.objects.text.Font.font_family
font_family
Definition: text.py:193
lottie.objects.text.FontList.__init__
def __init__(self)
Definition: text.py:207
lottie.objects.text.TextMoreOptions.__init__
def __init__(self)
Definition: text.py:73
lottie.objects.text.TextDocument.wrap_size
wrap_size
Size of the box containing the text.
Definition: text.py:112
lottie.objects.text.Font.weight
weight
Definition: text.py:197
lottie.objects.text.TextAnimatorDataProperty.ry
ry
Angle?
Definition: text.py:49
lottie.objects.properties.MultiDimensional
An animatable property that holds a NVector.
Definition: properties.py:385
lottie.objects.text.MaskedPath
Definition: text.py:9
lottie.objects.text.MaskedPath.mask
mask
Type?
Definition: text.py:19
lottie.objects.text.TextMoreOptions.alignment
alignment
Definition: text.py:74
lottie.objects.text.TextAnimatorDataProperty.fb
fb
0-100?
Definition: text.py:60
lottie.objects.text.TextAnimatorData.add_keyframe
def add_keyframe(self, time, item)
Definition: text.py:164
lottie.nvector.NVector
Definition: nvector.py:9
lottie.objects.text.TextAnimatorData
Definition: text.py:150
lottie.objects.text.TextAnimatorDataProperty.fh
fh
Definition: text.py:56