python-lottie  0.6.10+dev42a5126
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, ColorValue, Color
3 from ..nvector import NVector
4 from .helpers import Transform
5 from .shapes import ShapeElement
6 
7 
8 ## @ingroup Lottie
9 ## @ingroup LottieCheck
11  _props = [
12  LottieProp("mask", "m", float),
13  LottieProp("f", "f", Value),
14  LottieProp("l", "l", Value),
15  LottieProp("r", "r", float),
16  ]
17 
18  def __init__(self):
19  ## Type?
20  self.mask = None
21  ## First?
22  self.f = None
23  ## Last?
24  self.l = None
25  ## ??
26  self.r = None
27 
28 
29 ## @ingroup Lottie
30 ## @ingroup LottieCheck
32  _props = [
33  LottieProp("rotate_x", "rx", Value),
34  LottieProp("rotate_y", "ry", Value),
35  LottieProp("stroke_width", "sw", Value),
36  LottieProp("stroke_color", "sc", ColorValue),
37  LottieProp("fill_color", "fc", ColorValue),
38  LottieProp("fill_hue", "fh", Value),
39  LottieProp("fill_saturation", "fs", Value),
40  LottieProp("fill_brightness", "fb", Value),
41  LottieProp("tracking", "t", Value),
42  LottieProp("scale", "s", MultiDimensional),
43  ]
44 
45  def __init__(self):
46  super().__init__()
47  ## Angle?
48  self.rx = Value()
49  ## Angle?
50  self.ry = Value()
51  ## Stroke width
53  ## Stroke color
55  ## Fill color
57  ## Hue
58  self.fill_hue = Value()
59  ## Saturation 0-100
61  ## Brightness 0-100
63  ## Tracking
64  self.tracking = Value()
65 
66 
67 ## @ingroup Lottie
69  Characters = 1
70  Word = 2
71  Line = 3
72  All = 4
73 
74  @classmethod
75  def default(cls):
76  return cls.Characters
77 
78 
79 ## @ingroup Lottie
80 ## @ingroup LottieCheck
82  _props = [
83  LottieProp("alignment", "a", MultiDimensional),
84  LottieProp("grouping", "g", TextGrouping),
85  ]
86 
87  def __init__(self):
89  self.grouping = TextGrouping.default()
90 
91 
92 ## @ingroup Lottie
94  Left = 0
95  Right = 1
96  Center = 2
97  JustifyWithLastLineLeft = 3
98  JustifyWithLastLineRight = 4
99  JustifyWithLastLineCenter = 5
100  JustifyWithLastLineFull = 6
101 
102 
103 #ingroup Lottie
105  Regular = 0
106  AllCaps = 1
107  SmallCaps = 2
108 
109 
110 ## @ingroup Lottie
112  """!
113  @see http://docs.aenhancers.com/other/textdocument/
114 
115  Note that for multi-line text, lines are separated by \\r
116  """
117  _props = [
118  LottieProp("font_family", "f", str),
119  LottieProp("color", "fc", Color),
120  LottieProp("font_size", "s", float),
121  LottieProp("line_height", "lh", float),
122  LottieProp("wrap_size", "sz", NVector),
123  LottieProp("text", "t", str),
124  LottieProp("justify", "j", TextJustify),
125  LottieProp("text_caps", "ca", TextCaps, False),
126  LottieProp("tracking", "tr", float, False),
127  ]
128 
129  def __init__(self, text="", font_size=10, color=None, font_family=""):
130  self.font_family = font_family
131  ## Text color
132  self.color = color or Color(0, 0, 0)
133  ## Line height when wrapping
134  self.line_height = None
135  ## Text alignment
136  self.justify = TextJustify.Left
137  ## Size of the box containing the text
138  self.wrap_size = None
139  ## Text
140  self.text = text
141  ## Font Size
142  self.font_size = font_size
143  ## Text caps
144  self.text_caps = None
145  ## Text Tracking
146  self.tracking = None
147 
148 
149 ## @ingroup Lottie
151  _props = [
152  LottieProp("start", "s", TextDocument),
153  LottieProp("time", "t", float),
154  ]
155 
156  def __init__(self, time=0, start=None):
157  ## Start value of keyframe segment.
158  self.start = start
159  ## Start time of keyframe segment.
160  self.time = time
161 
162 
163 ## @ingroup Lottie
165  _props = [
166  LottieProp("keyframes", "k", TextDataKeyframe, True),
167  ]
168 
169  def __init__(self):
170  self.keyframes = []
171 
172  def get_value(self, time):
173  for kf in self.keyframes:
174  if kf.time >= time:
175  return kf.start
176  return None
177 
178 
179 ## @ingroup Lottie
181  _props = [
182  LottieProp("properties", "a", TextAnimatorDataProperty, True),
183  LottieProp("data", "d", TextData, False),
184  LottieProp("more_options", "m", TextMoreOptions, False),
185  LottieProp("masked_path", "p", MaskedPath),
186  ]
187 
188  def __init__(self):
189  self.properties = []
190  self.data = TextData()
193 
194  def add_keyframe(self, time, item):
195  self.data.keyframes.append(TextDataKeyframe(time, item))
196 
197  def get_value(self, time):
198  return self.data.get_value(time)
199 
200 
201 ## @ingroup Lottie
203  Local = 0
204  CssUrl = 1
205  ScriptUrl = 2
206  FontUrl = 3
207 
208 
209 ## @ingroup Lottie
211  _props = [
212  LottieProp("ascent", "ascent", float),
213  LottieProp("font_family", "fFamily", str),
214  LottieProp("name", "fName", str),
215  LottieProp("font_style", "fStyle", str),
216  LottieProp("path", "fPath", str),
217  LottieProp("weight", "fWeight", str),
218  LottieProp("origin", "origin", FontPathOrigin),
219  LottieProp("css_class", "fClass", str),
220  ]
221 
222  def __init__(self, font_family="sans", font_style="Regular", name=None):
223  self.ascent = None
224  self.font_family = font_family
225  self.font_style = font_style
226  self.name = name or "%s-%s" % (font_family, font_style)
227  self.path = None
228  self.weight = None
229  self.origin = None
230  self.css_class = None
231 
232 
233 ## @ingroup Lottie
235  _props = [
236  LottieProp("list", "list", Font, True),
237  ]
238 
239  def __init__(self):
240  self.list = []
241 
242  def append(self, font):
243  self.list.append(font)
244 
245 
246 ## @ingroup Lottie
248  """!
249  Character shapes
250  """
251  _props = [
252  LottieProp("shapes", "shapes", ShapeElement, True),
253  ]
254 
255  def __init__(self):
256  self.shapes = []
257 
258 
259 ## @ingroup Lottie
261  """!
262  Defines character shapes to avoid loading system fonts
263  """
264  _props = [
265  LottieProp("character", "ch", str, False),
266  LottieProp("font_family", "fFamily", str, False),
267  LottieProp("font_size", "size", float, False),
268  LottieProp("font_style", "style", str, False),
269  LottieProp("width", "w", float, False),
270  LottieProp("data", "data", CharacterData, False),
271  ]
272 
273  def __init__(self):
274  ## Character Value
275  self.character = ""
276  ## Character Font Family
277  self.font_family = ""
278  ## Character Font Size
279  self.font_size = 0
280  ## Character Font Style
281  self.font_style = "" # Regular
282  ## Character Width
283  self.width = 0
284  ## Character Data
286 
287  @property
288  def shapes(self):
289  return self.data.shapes
lottie.objects.text.TextAnimatorData.masked_path
masked_path
Definition: text.py:192
lottie.objects.text.MaskedPath.l
l
Last?
Definition: text.py:24
lottie.utils.color.Color
Definition: color.py:368
lottie.objects.text.TextGrouping.default
def default(cls)
Definition: text.py:75
lottie.objects.text.TextAnimatorData.more_options
more_options
Definition: text.py:191
lottie.objects.properties.Value
An animatable property that holds a float.
Definition: properties.py:622
lottie.objects.text.TextDocument.tracking
tracking
Text Tracking.
Definition: text.py:146
lottie.objects.text.Chars.shapes
def shapes(self)
Definition: text.py:288
lottie.objects.text.Chars.__init__
def __init__(self)
Definition: text.py:273
lottie.objects.text.Chars.data
data
Character Data.
Definition: text.py:285
lottie.objects.text.TextAnimatorDataProperty.fill_hue
fill_hue
Hue.
Definition: text.py:58
lottie.objects.text.FontList
Definition: text.py:234
lottie.objects.text.TextAnimatorData.data
data
Definition: text.py:190
lottie.objects.text.TextDataKeyframe.start
start
Start value of keyframe segment.
Definition: text.py:158
lottie.objects.text.TextAnimatorDataProperty.fill_color
fill_color
Fill color.
Definition: text.py:56
lottie.objects.text.TextMoreOptions
Definition: text.py:81
lottie.objects.text.TextDocument.font_size
font_size
Font Size.
Definition: text.py:142
lottie.objects.text.Chars.font_size
font_size
Character Font Size.
Definition: text.py:279
lottie.objects.text.TextAnimatorDataProperty
Definition: text.py:31
lottie.objects.text.TextAnimatorDataProperty.fill_brightness
fill_brightness
Brightness 0-100.
Definition: text.py:62
lottie.objects.text.TextData.__init__
def __init__(self)
Definition: text.py:169
lottie.objects.text.Font.path
path
Definition: text.py:227
lottie.objects.text.FontPathOrigin
Definition: text.py:202
lottie.objects.text.TextData.keyframes
keyframes
Definition: text.py:170
lottie.objects.text.TextGrouping.Characters
int Characters
Definition: text.py:69
lottie.objects.text.TextDocument.justify
justify
Text alignment.
Definition: text.py:136
lottie.objects.text.TextAnimatorDataProperty.__init__
def __init__(self)
Definition: text.py:45
lottie.objects.text.Font
Definition: text.py:210
lottie.objects.text.TextData.get_value
def get_value(self, time)
Definition: text.py:172
lottie.objects.text.Chars.font_style
font_style
Character Font Style.
Definition: text.py:281
lottie.objects.text.FontList.list
list
Definition: text.py:240
lottie.objects.text.TextDocument.line_height
line_height
Line height when wrapping.
Definition: text.py:134
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:156
lottie.objects.text.TextDocument.color
color
Text color.
Definition: text.py:132
lottie.objects.text.TextDocument.text
text
Text.
Definition: text.py:140
lottie.objects.text.MaskedPath.r
r
??
Definition: text.py:26
lottie.objects.text.TextJustify
Definition: text.py:93
lottie.objects.text.TextAnimatorDataProperty.stroke_color
stroke_color
Stroke color.
Definition: text.py:54
lottie.objects.text.Font.name
name
Definition: text.py:226
lottie.objects.base.LottieProp
Lottie <-> Python property mapper.
Definition: base.py:88
lottie.objects.text.Chars.width
width
Character Width.
Definition: text.py:283
lottie.objects.text.Font.ascent
ascent
Definition: text.py:223
lottie.objects.text.Font.origin
origin
Definition: text.py:229
lottie.objects.text.TextDataKeyframe
Definition: text.py:150
lottie.objects.text.Chars.character
character
Character Value.
Definition: text.py:275
lottie.objects.text.TextAnimatorDataProperty.tracking
tracking
Tracking.
Definition: text.py:64
lottie.objects.text.TextAnimatorData.get_value
def get_value(self, time)
Definition: text.py:197
lottie.objects.text.CharacterData.__init__
def __init__(self)
Definition: text.py:255
lottie.objects.text.TextAnimatorData.__init__
def __init__(self)
Definition: text.py:188
lottie.objects.text.TextDocument.__init__
def __init__(self, text="", font_size=10, color=None, font_family="")
Definition: text.py:129
lottie.objects.text.FontList.append
def append(self, font)
Definition: text.py:242
lottie.objects.text.TextDocument
Definition: text.py:111
lottie.objects.text.Font.__init__
def __init__(self, font_family="sans", font_style="Regular", name=None)
Definition: text.py:222
lottie.objects.text.TextData
Definition: text.py:164
lottie.objects.text.Font.font_style
font_style
Definition: text.py:225
lottie.objects.text.TextDocument.font_family
font_family
Definition: text.py:130
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:160
lottie.objects.text.TextAnimatorDataProperty.rx
rx
Angle?
Definition: text.py:48
lottie.objects.text.TextGrouping
Definition: text.py:68
lottie.objects.text.TextAnimatorDataProperty.fill_saturation
fill_saturation
Saturation 0-100.
Definition: text.py:60
lottie.objects.text.CharacterData
Character shapes.
Definition: text.py:247
lottie.objects.text.TextAnimatorDataProperty.stroke_width
stroke_width
Stroke width.
Definition: text.py:52
lottie.objects.text.MaskedPath.f
f
First?
Definition: text.py:22
lottie.objects.text.MaskedPath.__init__
def __init__(self)
Definition: text.py:18
lottie.objects.helpers.Transform
Layer transform.
Definition: helpers.py:7
lottie.objects.text.Chars
Defines character shapes to avoid loading system fonts.
Definition: text.py:260
lottie.objects.text.TextAnimatorData.properties
properties
Definition: text.py:189
lottie.objects.text.Chars.font_family
font_family
Character Font Family.
Definition: text.py:277
lottie.objects.text.Font.font_family
font_family
Definition: text.py:224
lottie.objects.text.FontList.__init__
def __init__(self)
Definition: text.py:239
lottie.objects.text.TextDocument.text_caps
text_caps
Text caps.
Definition: text.py:144
lottie.objects.text.TextMoreOptions.__init__
def __init__(self)
Definition: text.py:87
lottie.objects.text.TextDocument.wrap_size
wrap_size
Size of the box containing the text.
Definition: text.py:138
lottie.objects.text.Font.weight
weight
Definition: text.py:228
lottie.objects.text.TextCaps
Definition: text.py:104
lottie.objects.text.TextMoreOptions.grouping
grouping
Definition: text.py:89
lottie.objects.text.TextAnimatorDataProperty.ry
ry
Angle?
Definition: text.py:50
lottie.objects.properties.MultiDimensional
An animatable property that holds a NVector.
Definition: properties.py:385
lottie.objects.text.Font.css_class
css_class
Definition: text.py:230
lottie.objects.text.CharacterData.shapes
shapes
Definition: text.py:256
lottie.objects.text.MaskedPath
Definition: text.py:10
lottie.objects.text.MaskedPath.mask
mask
Type?
Definition: text.py:20
lottie.objects.text.TextMoreOptions.alignment
alignment
Definition: text.py:88
lottie.objects.text.TextAnimatorData.add_keyframe
def add_keyframe(self, time, item)
Definition: text.py:194
lottie.nvector.NVector
Definition: nvector.py:9
lottie.objects.text.TextAnimatorData
Definition: text.py:180