python-lottie  0.6.10+devbd5499b
A framework to work with lottie files and telegram animated stickers (tgs)
shapes.py
Go to the documentation of this file.
1 import math
2 from .base import LottieObject, LottieProp, LottieEnum, NVector
3 from .properties import Value, MultiDimensional, GradientColors, ShapeProperty, Bezier, ColorValue
4 from ..utils.color import Color
5 from .helpers import Transform
6 
7 
8 class BoundingBox:
9  """!
10  Shape bounding box
11  """
12  def __init__(self, x1=None, y1=None, x2=None, y2=None):
13  self.x1 = x1
14  self.y1 = y1
15  self.x2 = x2
16  self.y2 = y2
17 
18  def include(self, x, y):
19  """!
20  Expands the box to include the point at x, y
21  """
22  if x is not None:
23  if self.x1 is None or self.x1 > x:
24  self.x1 = x
25  if self.x2 is None or self.x2 < x:
26  self.x2 = x
27  if y is not None:
28  if self.y1 is None or self.y1 > y:
29  self.y1 = y
30  if self.y2 is None or self.y2 < y:
31  self.y2 = y
32 
33  def expand(self, other):
34  """!
35  Expands the bounding box to include another bounding box
36  """
37  self.include(other.x1, other.y1)
38  self.include(other.x2, other.y2)
39 
40  def center(self):
41  """!
42  Center point of the bounding box
43  """
44  return NVector((self.x1 + self.x2) / 2, (self.y1 + self.y2) / 2)
45 
46  def isnull(self):
47  """!
48  Whether the box is default-initialized
49  """
50  return self.x1 is None or self.y2 is None
51 
52  def __repr__(self):
53  return "<BoundingBox [%s, %s] - [%s, %s]>" % (self.x1, self.y1, self.x2, self.y2)
54 
55  @property
56  def width(self):
57  if self.isnull():
58  return 0
59  return self.x2 - self.x1
60 
61  @property
62  def height(self):
63  if self.isnull():
64  return 0
65  return self.y2 - self.y1
66 
67  def size(self):
68  return NVector(self.width, self.height)
69 
70 
71 ## @ingroup Lottie
73  """!
74  Base class for all elements of ShapeLayer and Group
75  """
76  _props = [
77  #LottieProp("match_name", "mn", str, False),
78  LottieProp("hidden", "hd", bool, False),
79  LottieProp("name", "nm", str, False),
80  LottieProp("type", "ty", str, False),
81  LottieProp("property_index", "cix", int, False),
82  LottieProp("bm", "bm", int, False),
83  ]
84  ## %Shape type.
85  type = None
86  _shape_classses = None
87 
88  def __init__(self):
89  # After Effect's Match Name. Used for expressions.
90  #self.match_name = ""
91 
92  ## After Effect's Name. Used for expressions.
93  self.name = None
94  ## Property index
95  self.property_index = None
96  ## Hide element
97  self.hidden = None
98  ## @todo figure out?
99  self.bm = None
100 
101  def bounding_box(self, time=0):
102  """!
103  Bounding box of the shape element at the given time
104  """
105  return BoundingBox()
106 
107  @classmethod
108  def _load_get_class(cls, lottiedict):
109  if not ShapeElement._shape_classses:
110  ShapeElement._shape_classses = {}
111  ShapeElement._load_sub(ShapeElement._shape_classses)
112  return ShapeElement._shape_classses[lottiedict["ty"]]
113 
114  @classmethod
115  def _load_sub(cls, dict):
116  for sc in cls.__subclasses__():
117  if sc.type:
118  dict[sc.type] = sc
119  sc._load_sub(dict)
120 
121  def __str__(self):
122  return self.name or super().__str__()
123 
124 
125 ## @ingroup Lottie
127  """!
128  Drawable shape
129  """
130  _props = [
131  LottieProp("direction", "d", float, False),
132  ]
133 
134  def __init__(self):
135  ShapeElement.__init__(self)
136  ## After Effect's Direction. Direction how the shape is drawn. Used for trim path for example.
137  self.direction = 0
138 
139  def to_bezier(self):
140  """!
141  Returns a Path corresponding to this Shape
142  """
143  raise NotImplementedError()
144 
145 
146 ## @ingroup Lottie
147 class Rect(Shape):
148  """!
149  A simple rectangle shape
150  """
151  _props = [
152  LottieProp("position", "p", MultiDimensional, False),
153  LottieProp("size", "s", MultiDimensional, False),
154  LottieProp("rounded", "r", Value, False),
155  ]
156  ## %Shape type.
157  type = "rc"
158 
159  def __init__(self, pos=None, size=None, rounded=0):
160  Shape.__init__(self)
161  ## Rect's position
162  self.position = MultiDimensional(pos or NVector(0, 0))
163  ## Rect's size
164  self.size = MultiDimensional(size or NVector(0, 0))
165  ## Rect's rounded corners
166  self.rounded = Value(rounded)
167 
168  def bounding_box(self, time=0):
169  pos = self.position.get_value(time)
170  sz = self.size.get_value(time)
171 
172  return BoundingBox(
173  pos[0] - sz[0]/2,
174  pos[1] - sz[1]/2,
175  pos[0] + sz[0]/2,
176  pos[1] + sz[1]/2,
177  )
178 
179  def to_bezier(self):
180  """!
181  Returns a Shape corresponding to this rect
182  """
183  shape = Path()
184  kft = set()
185  if self.position.animated:
186  kft |= set(kf.time for kf in self.position.keyframes)
187  if self.size.animated:
188  kft |= set(kf.time for kf in self.size.keyframes)
189  if self.rounded.animated:
190  kft |= set(kf.time for kf in self.rounded.keyframes)
191  if not kft:
192  shape.shape.value = self._bezier_t(0)
193  else:
194  for time in sorted(kft):
195  shape.shape.add_keyframe(time, self._bezier_t(time))
196  return shape
197 
198  def _bezier_t(self, time):
199  bezier = Bezier()
200  bb = self.bounding_box(time)
201  rounded = self.rounded.get_value(time)
202  tl = NVector(bb.x1, bb.y1)
203  tr = NVector(bb.x2, bb.y1)
204  br = NVector(bb.x2, bb.y2)
205  bl = NVector(bb.x1, bb.y2)
206 
207  if not self.rounded.animated and rounded == 0:
208  bezier.add_point(tl)
209  bezier.add_point(tr)
210  bezier.add_point(br)
211  bezier.add_point(bl)
212  else:
213  hh = NVector(rounded/2, 0)
214  vh = NVector(0, rounded/2)
215  hd = NVector(rounded, 0)
216  vd = NVector(0, rounded)
217  bezier.add_point(tl+vd, outp=-vh)
218  bezier.add_point(tl+hd, -hh)
219  bezier.add_point(tr-hd, outp=hh)
220  bezier.add_point(tr+vd, -vh)
221  bezier.add_point(br-vd, outp=vh)
222  bezier.add_point(br-hd, hh)
223  bezier.add_point(bl+hd, outp=-hh)
224  bezier.add_point(bl-vd, vh)
225 
226  bezier.close()
227  return bezier
228 
229 
230 ## @ingroup Lottie
232  Star = 1
233  Polygon = 2
234 
235 
236 ## @ingroup Lottie
237 class Star(Shape):
238  """!
239  Star shape
240  """
241  _props = [
242  LottieProp("position", "p", MultiDimensional, False),
243  LottieProp("inner_radius", "ir", Value, False),
244  LottieProp("inner_roundness", "is", Value, False),
245  LottieProp("outer_radius", "or", Value, False),
246  LottieProp("outer_roundness", "os", Value, False),
247  LottieProp("rotation", "r", Value, False),
248  LottieProp("points", "pt", Value, False),
249  LottieProp("star_type", "sy", StarType, False),
250  ]
251  ## %Shape type.
252  type = "sr"
253 
254  def __init__(self):
255  Shape.__init__(self)
256  ## Star's position
258  ## Star's inner radius. (Star only)
260  ## Star's inner roundness. (Star only)
262  ## Star's outer radius.
264  ## Star's outer roundness.
266  ## Star's rotation.
267  self.rotation = Value()
268  ## Star's number of points.
269  self.points = Value(5)
270  ## Star's type. Polygon or Star.
271  self.star_type = StarType.Star
272 
273  def bounding_box(self, time=0):
274  pos = self.position.get_value(time)
275  r = self.outer_radius.get_value(time)
276 
277  return BoundingBox(
278  pos[0] - r,
279  pos[1] - r,
280  pos[0] + r,
281  pos[1] + r,
282  )
283 
284  def to_bezier(self):
285  """!
286  Returns a Shape corresponding to this star
287  """
288  shape = Path()
289  kft = set()
290  if self.position.animated:
291  kft |= set(kf.time for kf in self.position.keyframes)
292  if self.inner_radius.animated:
293  kft |= set(kf.time for kf in self.inner_radius.keyframes)
294  if self.inner_roundness.animated:
295  kft |= set(kf.time for kf in self.inner_roundness.keyframes)
296  if self.points.animated:
297  kft |= set(kf.time for kf in self.points.keyframes)
298  if self.rotation.animated:
299  kft |= set(kf.time for kf in self.rotation.keyframes)
300  # TODO inner_roundness / outer_roundness
301  if not kft:
302  shape.shape.value = self._bezier_t(0)
303  else:
304  for time in sorted(kft):
305  shape.shape.add_keyframe(time, self._bezier_t(time))
306  return shape
307 
308  def _bezier_t(self, time):
309  bezier = Bezier()
310  pos = self.position.get_value(time)
311  r1 = self.inner_radius.get_value(time)
312  r2 = self.outer_radius.get_value(time)
313  rot = -(self.rotation.get_value(time)) * math.pi / 180 + math.pi
314  p = self.points.get_value(time)
315  halfd = -math.pi / p
316 
317  for i in range(int(p)):
318  main_angle = rot + i * halfd * 2
319  dx = r2 * math.sin(main_angle)
320  dy = r2 * math.cos(main_angle)
321  bezier.add_point(NVector(pos.x + dx, pos.y + dy))
322 
323  if self.star_type == StarType.Star:
324  dx = r1 * math.sin(main_angle+halfd)
325  dy = r1 * math.cos(main_angle+halfd)
326  bezier.add_point(NVector(pos.x + dx, pos.y + dy))
327 
328  bezier.close()
329  return bezier
330 
331 
332 ## @ingroup Lottie
333 class Ellipse(Shape):
334  """!
335  Ellipse shape
336  """
337  _props = [
338  LottieProp("position", "p", MultiDimensional, False),
339  LottieProp("size", "s", MultiDimensional, False),
340  ]
341  ## %Shape type.
342  type = "el"
343 
344  def __init__(self, position=None, size=None):
345  Shape.__init__(self)
346  ## Ellipse's position
347  self.position = MultiDimensional(position or NVector(0, 0))
348  ## Ellipse's size
349  self.size = MultiDimensional(size or NVector(0, 0))
350 
351  def bounding_box(self, time=0):
352  pos = self.position.get_value(time)
353  sz = self.size.get_value(time)
354 
355  return BoundingBox(
356  pos[0] - sz[0]/2,
357  pos[1] - sz[1]/2,
358  pos[0] + sz[0]/2,
359  pos[1] + sz[1]/2,
360  )
361 
362  def to_bezier(self):
363  """!
364  Returns a Shape corresponding to this ellipse
365  """
366  shape = Path()
367  kft = set()
368  if self.position.animated:
369  kft |= set(kf.time for kf in self.position.keyframes)
370  if self.size.animated:
371  kft |= set(kf.time for kf in self.size.keyframes)
372  if not kft:
373  shape.shape.value = self._bezier_t(0)
374  else:
375  for time in sorted(kft):
376  shape.shape.add_keyframe(time, self._bezier_t(time))
377  return shape
378 
379  def _bezier_t(self, time):
380  from ..utils.ellipse import Ellipse as EllipseConverter
381 
382  bezier = Bezier()
383  position = self.position.get_value(time)
384  radii = self.size.get_value(time) / 2
385 
386  el = EllipseConverter(position, radii, 0)
387  points = el.to_bezier(0, math.pi*2)
388  for point in points[1:]:
389  bezier.add_point(point.vertex, point.in_tangent, point.out_tangent)
390 
391  bezier.close()
392  return bezier
393 
394 
395 ## @ingroup Lottie
396 class Path(Shape):
397  """!
398  Animatable Bezier curve
399  """
400  _props = [
401  LottieProp("shape", "ks", ShapeProperty, False),
402  LottieProp("index", "ind", int, False),
403  ]
404  ## %Shape type.
405  type = "sh"
406 
407  def __init__(self, bezier=None):
408  Shape.__init__(self)
409  ## Shape's vertices
410  self.shape = ShapeProperty(bezier or Bezier())
411  ## @todo Index?
412  self.index = None
413 
414  def bounding_box(self, time=0):
415  pos = self.shape.get_value(time)
416 
417  bb = BoundingBox()
418  for v in pos.vertices:
419  bb.include(*v)
420 
421  return bb
422 
423  def to_bezier(self):
424  return self.clone()
425 
426 
427 ## @ingroup Lottie
429  """!
430  ShapeElement that can contain other shapes
431  @note Shapes inside the same group will create "holes" in other shapes
432  """
433  _props = [
434  LottieProp("number_of_properties", "np", float, False),
435  LottieProp("shapes", "it", ShapeElement, True),
436  ]
437  ## %Shape type.
438  type = "gr"
439 
440  def __init__(self):
441  ShapeElement.__init__(self)
442  ## Group number of properties. Used for expressions.
444  ## Group list of items
446 
447  @property
448  def transform(self):
449  return self.shapes[-1]
450 
451  def bounding_box(self, time=0):
452  bb = BoundingBox()
453  for v in self.shapes:
454  bb.expand(v.bounding_box(time))
455 
456  if not bb.isnull():
457  mat = self.transform.to_matrix(time)
458  points = [
459  mat.apply(NVector(bb.x1, bb.y1)),
460  mat.apply(NVector(bb.x1, bb.y2)),
461  mat.apply(NVector(bb.x2, bb.y2)),
462  mat.apply(NVector(bb.x2, bb.y1)),
463  ]
464  x1 = min(p.x for p in points)
465  x2 = max(p.x for p in points)
466  y1 = min(p.y for p in points)
467  y2 = max(p.y for p in points)
468  return BoundingBox(x1, y1, x2, y2)
469  return bb
470 
471  def add_shape(self, shape):
472  self.shapes.insert(-1, shape)
473  return shape
474 
475  def insert_shape(self, index, shape):
476  self.shapes.insert(index, shape)
477  return shape
478 
479  @classmethod
480  def load(cls, lottiedict):
481  object = ShapeElement.load(lottiedict)
482 
483  shapes = []
484  transform = None
485  for obj in object.shapes:
486  if isinstance(obj, TransformShape):
487  if not transform:
488  transform = obj
489  else:
490  shapes.append(obj)
491 
492  object.shapes = shapes
493  object.shapes.append(transform)
494  return object
495 
496 
497 ## @ingroup Lottie
499  NonZero = 1
500  EvenOdd = 2
501 
502 
503 ## @ingroup Lottie
505  """!
506  Solid fill color
507  """
508  _props = [
509  LottieProp("opacity", "o", Value, False),
510  LottieProp("color", "c", ColorValue, False),
511  LottieProp("fill_rule", "r", FillRule, False),
512  ]
513  ## %Shape type.
514  type = "fl"
515 
516  def __init__(self, color=None):
517  ShapeElement.__init__(self)
518  ## Fill Opacity
519  self.opacity = Value(100)
520  ## Fill Color
521  self.color = ColorValue(color or Color(1, 1, 1))
522  ## Fill rule
523  self.fill_rule = None
524 
525 
526 ## @ingroup Lottie
528  Linear = 1
529  Radial = 2
530 
531 
532 ## @ingroup Lottie
534  _props = [
535  LottieProp("start_point", "s", MultiDimensional, False),
536  LottieProp("end_point", "e", MultiDimensional, False),
537  LottieProp("gradient_type", "t", GradientType, False),
538  LottieProp("highlight_length", "h", Value, False),
539  LottieProp("highlight_angle", "a", Value, False),
540  LottieProp("colors", "g", GradientColors, False),
541  ]
542 
543  def __init__(self, colors=[]):
544  ## Fill Opacity
545  self.opacity = Value(100)
546  ## Gradient Start Point
548  ## Gradient End Point
550  ## Gradient Type
551  self.gradient_type = GradientType.Linear
552  ## Gradient Highlight Length. Only if type is Radial
554  ## Highlight Angle. Only if type is Radial
556  ## Gradient Colors
557  self.colors = GradientColors(colors)
558 
559 
560 ## @ingroup Lottie
562  """!
563  Gradient fill
564  """
565  _props = [
566  LottieProp("opacity", "o", Value, False),
567  LottieProp("fill_rule", "r", FillRule, False),
568  ]
569  ## %Shape type.
570  type = "gf"
571 
572  def __init__(self, colors=[]):
573  ShapeElement.__init__(self)
574  Gradient.__init__(self, colors)
575  ## Fill Opacity
576  self.opacity = Value(100)
577  ## Fill rule
578  self.fill_rule = None
579 
580 
581 ## @ingroup Lottie
583  Miter = 1
584  Round = 2
585  Bevel = 3
586 
587 
588 ## @ingroup Lottie
590  Butt = 1
591  Round = 2
592  Square = 3
593 
594 
595 ## @ingroup Lottie
597  Dash = "d"
598  Gap = "g"
599  Offset = "o"
600 
601 
602 ## @ingroup Lottie
604  _props = [
605  LottieProp("name", "nm", str, False),
606  LottieProp("type", "n", StrokeDashType, False),
607  LottieProp("length", "v", Value, False),
608  ]
609 
610  def __init__(self, length=0, type=StrokeDashType.Dash):
611  self.name = type.name.lower()
612  self.type = type
613  self.length = Value(length)
614 
615  def __str__(self):
616  return self.name or super().__str__()
617 
618 
619 ## @ingroup Lottie
621  _props = [
622  LottieProp("line_cap", "lc", LineCap, False),
623  LottieProp("line_join", "lj", LineJoin, False),
624  LottieProp("miter_limit", "ml", float, False),
625  LottieProp("opacity", "o", Value, False),
626  LottieProp("width", "w", Value, False),
627  LottieProp("dashes", "d", StrokeDash, True),
628  ]
629 
630  def __init__(self, width=1):
631  ## Stroke Line Cap
632  self.line_cap = LineCap.Round
633  ## Stroke Line Join
634  self.line_join = LineJoin.Round
635  ## Stroke Miter Limit. Only if Line Join is set to Miter.
636  self.miter_limit = 0
637  ## Stroke Opacity
638  self.opacity = Value(100)
639  ## Stroke Width
640  self.width = Value(width)
641  ## Dashes
642  self.dashes = None
643 
644 
645 ## @ingroup Lottie
647  """!
648  Solid stroke
649  """
650  _props = [
651  LottieProp("color", "c", MultiDimensional, False),
652  ]
653  ## %Shape type.
654  type = "st"
655 
656  def __init__(self, color=None, width=1):
657  ShapeElement.__init__(self)
658  BaseStroke.__init__(self, width)
659  ## Stroke Color
660  self.color = ColorValue(color or Color(0, 0, 0))
661 
662 
663 ## @ingroup Lottie
665  """!
666  Gradient stroke
667  """
668  ## %Shape type.
669  type = "gs"
670 
671  def __init__(self, stroke_width=1):
672  ShapeElement.__init__(self)
673  BaseStroke.__init__(self, stroke_width)
674  Gradient.__init__(self)
675 
676  def bounding_box(self, time=0):
677  return BoundingBox()
678 
679 
680 ## @ingroup Lottie
682  """!
683  Group transform
684  """
685  ## %Shape type.
686  type = "tr"
687 
688  def __init__(self):
689  ShapeElement.__init__(self)
690  Transform.__init__(self)
692 
693 
694 ## @ingroup Lottie
696  Above = 1
697  Below = 2
698 
699 
700 ## @ingroup Lottie
702  _props = [
703  LottieProp("start_opacity", "so", Value, False),
704  LottieProp("end_opacity", "eo", Value, False),
705  ]
706 
707  def __init__(self):
708  Transform.__init__(self)
709  self.start_opacity = Value(100)
710  self.end_opacity = Value(100)
711 
712 
713 ## @ingroup Lottie
715  pass
716 
717 
718 ## @ingroup Lottie
719 class TrimMultipleShapes(LottieEnum):
720  Simultaneously = 1
721  Individually = 2
722 
723 
724 ## @ingroup Lottie
725 ## @todo Implement SIF Export
726 class Trim(Modifier):
727  """
728  Trims shapes into a segment
729  """
730  _props = [
731  LottieProp("start", "s", Value, False),
732  LottieProp("end", "e", Value, False),
733  LottieProp("offset", "o", Value, False),
734  LottieProp("multiple", "m", TrimMultipleShapes, False),
735  ]
736  ## %Shape type.
737  type = "tm"
738 
739  def __init__(self):
740  ShapeElement.__init__(self)
741  ## Start of the segment, as a percentage
742  self.start = Value(0)
743  ## End of the segment, as a percentage
744  self.end = Value(100)
745  ## start/end offset, as an angle (0, 360)
746  self.offset = Value(0)
747  ## @todo?
748  self.multiple = None
749 
750 
751 ## @ingroup Lottie
753  """
754  Duplicates previous shapes in a group
755  """
756  _props = [
757  LottieProp("copies", "c", Value, False),
758  LottieProp("offset", "o", Value, False),
759  LottieProp("composite", "m", Composite, False),
760  LottieProp("transform", "tr", RepeaterTransform, False),
761  ]
762  ## %Shape type.
763  type = "rp"
764 
765  def __init__(self, copies=1):
766  Modifier.__init__(self)
767  ## Number of Copies
768  self.copies = Value(copies)
769  ## Offset of Copies
770  self.offset = Value()
771  ## Composite of copies
772  self.composite = Composite.Above
773  ## Transform values for each repeater copy
775 
776 
777 ## @ingroup Lottie
778 ## @todo Implement SIF Export
780  """
781  Rounds corners of other shapes
782  """
783  _props = [
784  LottieProp("radius", "r", Value, False),
785  ]
786  ## %Shape type.
787  type = "rd"
788 
789  def __init__(self):
790  Modifier.__init__(self)
791  ## Rounded Corner Radius
792  self.radius = Value()
793 
794 
795 ## @ingroup Lottie
796 ## @ingroup LottieCheck
797 ## @note marked as unsupported by lottie
799  _props = [
800  LottieProp("merge_mode", "mm", float, False),
801  ]
802  ## %Shape type.
803  type = "mm"
804 
805  def __init__(self):
806  ShapeElement.__init__(self)
807  ## Merge Mode
808  self.merge_mode = 1
809 
810 
811 ## @ingroup Lottie
812 ## @note marked as unsupported by lottie
814  _props = [
815  LottieProp("angle", "a", Value, False),
816  LottieProp("center", "c", MultiDimensional, False),
817  ]
818  ## %Shape type.
819  type = "tw"
820 
821  def __init__(self):
822  ShapeElement.__init__(self)
823  self.angle = Value(0)
lottie.objects.shapes.Group
ShapeElement that can contain other shapes.
Definition: shapes.py:428
lottie.objects.shapes.Twist.__init__
def __init__(self)
Definition: shapes.py:821
lottie.objects.shapes.Rect.bounding_box
def bounding_box(self, time=0)
Bounding box of the shape element at the given time.
Definition: shapes.py:168
lottie.utils.color.Color
Definition: color.py:368
lottie.objects.shapes.Repeater.offset
offset
Offset of Copies.
Definition: shapes.py:770
lottie.objects.shapes.Rect.to_bezier
def to_bezier(self)
Returns a Shape corresponding to this rect.
Definition: shapes.py:179
lottie.objects.shapes.Gradient.gradient_type
gradient_type
Gradient Type.
Definition: shapes.py:551
lottie.objects.shapes.BoundingBox.y1
y1
Definition: shapes.py:14
lottie.objects.shapes.Repeater.transform
transform
Transform values for each repeater copy.
Definition: shapes.py:774
lottie.objects.properties.Value
An animatable property that holds a float.
Definition: properties.py:608
lottie.objects.shapes.BaseStroke.__init__
def __init__(self, width=1)
Definition: shapes.py:630
lottie.objects.shapes.StarType
Definition: shapes.py:231
lottie.objects.shapes.Ellipse.to_bezier
def to_bezier(self)
Returns a Shape corresponding to this ellipse.
Definition: shapes.py:362
lottie.objects.shapes.GradientStroke.__init__
def __init__(self, stroke_width=1)
Definition: shapes.py:671
lottie.objects.shapes.ShapeElement.property_index
property_index
Property index.
Definition: shapes.py:95
lottie.objects.shapes.Repeater.composite
composite
Composite of copies.
Definition: shapes.py:772
lottie.objects.shapes.Star.position
position
Star's position.
Definition: shapes.py:257
lottie.objects.shapes.Group.insert_shape
def insert_shape(self, index, shape)
Definition: shapes.py:475
lottie.objects.shapes.Stroke
Solid stroke.
Definition: shapes.py:646
lottie.objects.shapes.Group.load
def load(cls, lottiedict)
Loads from a JSON object.
Definition: shapes.py:480
lottie.objects.shapes.RepeaterTransform.__init__
def __init__(self)
Definition: shapes.py:707
lottie.objects.shapes.Rect._bezier_t
def _bezier_t(self, time)
Definition: shapes.py:198
lottie.objects.shapes.ShapeElement.bm
bm
Definition: shapes.py:99
lottie.objects.shapes.LineCap
Definition: shapes.py:589
lottie.objects.shapes.Gradient.end_point
end_point
Gradient End Point.
Definition: shapes.py:549
lottie.objects.bezier.Bezier
Single bezier curve.
Definition: bezier.py:123
lottie.objects.shapes.Repeater.copies
copies
Number of Copies.
Definition: shapes.py:768
lottie.objects.shapes.ShapeElement.__init__
def __init__(self)
Definition: shapes.py:88
lottie.objects.shapes.StrokeDash.__str__
def __str__(self)
Definition: shapes.py:615
lottie.objects.shapes.BoundingBox.isnull
def isnull(self)
Whether the box is default-initialized.
Definition: shapes.py:46
lottie.objects.shapes.GradientType
Definition: shapes.py:527
lottie.objects.shapes.Path.index
index
Definition: shapes.py:412
lottie.objects.helpers.Transform.anchor_point
anchor_point
Transform Anchor Point.
Definition: helpers.py:26
lottie.objects.shapes.BoundingBox.__init__
def __init__(self, x1=None, y1=None, x2=None, y2=None)
Definition: shapes.py:12
lottie.objects.shapes.GradientStroke
Gradient stroke.
Definition: shapes.py:664
lottie.objects.shapes.Path.shape
shape
Shape's vertices.
Definition: shapes.py:410
lottie.objects.shapes.BoundingBox.x1
x1
Definition: shapes.py:13
lottie.objects.properties.ShapeProperty
An animatable property that holds a Bezier.
Definition: properties.py:672
lottie.objects.shapes.BaseStroke.miter_limit
miter_limit
Stroke Miter Limit.
Definition: shapes.py:636
lottie.objects.shapes.Fill.opacity
opacity
Fill Opacity.
Definition: shapes.py:519
lottie.objects.shapes.Ellipse.size
size
Ellipse's size.
Definition: shapes.py:349
lottie.objects.shapes.Shape.__init__
def __init__(self)
Definition: shapes.py:134
lottie.objects.base.LottieBase.clone
def clone(self)
Returns a copy of the object.
Definition: base.py:26
lottie.objects.shapes.BoundingBox.expand
def expand(self, other)
Expands the bounding box to include another bounding box.
Definition: shapes.py:33
lottie.objects.shapes.Group.transform
def transform(self)
Definition: shapes.py:448
lottie.objects.shapes.Path
Animatable Bezier curve.
Definition: shapes.py:396
lottie.objects.shapes.StrokeDash.length
length
Definition: shapes.py:613
lottie.objects.shapes.Star.star_type
star_type
Star's type.
Definition: shapes.py:271
lottie.objects.shapes.RepeaterTransform.start_opacity
start_opacity
Definition: shapes.py:709
lottie.objects.shapes.Star.points
points
Star's number of points.
Definition: shapes.py:269
lottie.objects.shapes.Trim
Definition: shapes.py:726
lottie.objects.shapes.Merge
Definition: shapes.py:798
lottie.objects.shapes.BaseStroke.opacity
opacity
Stroke Opacity.
Definition: shapes.py:638
lottie.objects.shapes.Repeater
Definition: shapes.py:752
lottie.objects.base.LottieObject
Base class for mapping Python classes into Lottie JSON objects.
Definition: base.py:224
lottie.objects.shapes.BoundingBox.x2
x2
Definition: shapes.py:15
lottie.objects.shapes.Modifier
Definition: shapes.py:714
lottie.objects.shapes.Gradient.opacity
opacity
Fill Opacity.
Definition: shapes.py:545
lottie.objects.shapes.ShapeElement.hidden
hidden
Hide element.
Definition: shapes.py:97
lottie.objects.shapes.Trim.multiple
multiple
Definition: shapes.py:748
lottie.objects.shapes.Gradient.highlight_angle
highlight_angle
Highlight Angle.
Definition: shapes.py:555
lottie.objects.shapes.Shape.to_bezier
def to_bezier(self)
Returns a Path corresponding to this Shape.
Definition: shapes.py:139
lottie.objects.shapes.StrokeDash.type
type
Definition: shapes.py:612
lottie.objects.shapes.Rect
A simple rectangle shape.
Definition: shapes.py:147
lottie.objects.shapes.Gradient.highlight_length
highlight_length
Gradient Highlight Length.
Definition: shapes.py:553
lottie.objects.shapes.TransformShape
Group transform.
Definition: shapes.py:681
lottie.objects.shapes.Fill
Solid fill color.
Definition: shapes.py:504
lottie.objects.shapes.StrokeDash.__init__
def __init__(self, length=0, type=StrokeDashType.Dash)
Definition: shapes.py:610
lottie.objects.shapes.Stroke.__init__
def __init__(self, color=None, width=1)
Definition: shapes.py:656
lottie.objects.shapes.Star.outer_roundness
outer_roundness
Star's outer roundness.
Definition: shapes.py:265
lottie.objects.base.LottieProp
Lottie <-> Python property mapper.
Definition: base.py:88
lottie.objects.shapes.Rect.rounded
rounded
Rect's rounded corners.
Definition: shapes.py:166
lottie.objects.shapes.BoundingBox.__repr__
def __repr__(self)
Definition: shapes.py:52
lottie.objects.shapes.StrokeDash
Definition: shapes.py:603
lottie.objects.shapes.Star.rotation
rotation
Star's rotation.
Definition: shapes.py:267
lottie.objects.shapes.GradientFill.fill_rule
fill_rule
Fill rule.
Definition: shapes.py:578
lottie.objects.shapes.ShapeElement.__str__
def __str__(self)
Definition: shapes.py:121
lottie.objects.shapes.Trim.offset
offset
start/end offset, as an angle (0, 360)
Definition: shapes.py:746
lottie.objects.shapes.Shape.direction
direction
After Effect's Direction.
Definition: shapes.py:137
lottie.objects.shapes.TransformShape.__init__
def __init__(self)
Definition: shapes.py:688
lottie.objects.shapes.Ellipse._bezier_t
def _bezier_t(self, time)
Definition: shapes.py:379
lottie.objects.shapes.GradientFill.__init__
def __init__(self, colors=[])
Definition: shapes.py:572
lottie.objects.shapes.Star.to_bezier
def to_bezier(self)
Returns a Shape corresponding to this star.
Definition: shapes.py:284
lottie.objects.shapes.Merge.__init__
def __init__(self)
Definition: shapes.py:805
lottie.objects.shapes.Star.__init__
def __init__(self)
Definition: shapes.py:254
lottie.objects.shapes.Group.number_of_properties
number_of_properties
Group number of properties.
Definition: shapes.py:443
lottie.objects.shapes.RepeaterTransform.end_opacity
end_opacity
Definition: shapes.py:710
lottie.objects.shapes.Twist.center
center
Definition: shapes.py:824
lottie.objects.shapes.Stroke.color
color
Stroke Color.
Definition: shapes.py:660
lottie.objects.base.LottieEnum
Base class for enum-like types in the Lottie JSON structure.
Definition: base.py:42
lottie.objects.shapes.GradientFill
Gradient fill.
Definition: shapes.py:561
lottie.objects.shapes.Star.inner_roundness
inner_roundness
Star's inner roundness.
Definition: shapes.py:261
lottie.objects.shapes.Trim.__init__
def __init__(self)
Definition: shapes.py:739
lottie.objects.shapes.BaseStroke.dashes
dashes
Dashes.
Definition: shapes.py:642
lottie.objects.shapes.BoundingBox.height
def height(self)
Definition: shapes.py:62
lottie.objects.shapes.RepeaterTransform
Definition: shapes.py:701
lottie.objects.shapes.Group.shapes
shapes
Group list of items.
Definition: shapes.py:445
lottie.objects.shapes.Trim.start
start
Start of the segment, as a percentage.
Definition: shapes.py:742
lottie.objects.shapes.Rect.size
size
Rect's size.
Definition: shapes.py:164
lottie.objects.shapes.Fill.color
color
Fill Color.
Definition: shapes.py:521
lottie.objects.shapes.Path.bounding_box
def bounding_box(self, time=0)
Bounding box of the shape element at the given time.
Definition: shapes.py:414
lottie.objects.shapes.BaseStroke.width
width
Stroke Width.
Definition: shapes.py:640
lottie.objects.shapes.BaseStroke.line_join
line_join
Stroke Line Join.
Definition: shapes.py:634
lottie.objects.shapes.FillRule
Definition: shapes.py:498
lottie.objects.shapes.Ellipse
Ellipse shape.
Definition: shapes.py:333
lottie.objects.shapes.Rect.__init__
def __init__(self, pos=None, size=None, rounded=0)
Definition: shapes.py:159
lottie.objects.shapes.BaseStroke.line_cap
line_cap
Stroke Line Cap.
Definition: shapes.py:632
lottie.objects.shapes.Gradient.__init__
def __init__(self, colors=[])
Definition: shapes.py:543
lottie.objects.shapes.Group.add_shape
def add_shape(self, shape)
Definition: shapes.py:471
lottie.objects.shapes.BoundingBox.y2
y2
Definition: shapes.py:16
lottie.objects.shapes.Group.__init__
def __init__(self)
Definition: shapes.py:440
lottie.objects.shapes.ShapeElement.name
name
After Effect's Name.
Definition: shapes.py:93
lottie.objects.shapes.Rect.position
position
Rect's position.
Definition: shapes.py:162
lottie.objects.shapes.RoundedCorners.radius
radius
Rounded Corner Radius.
Definition: shapes.py:792
lottie.objects.shapes.RoundedCorners
Definition: shapes.py:779
lottie.objects.shapes.Gradient.colors
colors
Gradient Colors.
Definition: shapes.py:557
lottie.objects.helpers.Transform
Layer transform.
Definition: helpers.py:7
lottie.objects.shapes.Gradient.start_point
start_point
Gradient Start Point.
Definition: shapes.py:547
lottie.objects.shapes.ShapeElement.bounding_box
def bounding_box(self, time=0)
Bounding box of the shape element at the given time.
Definition: shapes.py:101
lottie.objects.shapes.RoundedCorners.__init__
def __init__(self)
Definition: shapes.py:789
lottie.objects.shapes.Ellipse.__init__
def __init__(self, position=None, size=None)
Definition: shapes.py:344
lottie.objects.shapes.Trim.end
end
End of the segment, as a percentage.
Definition: shapes.py:744
lottie.objects.properties.GradientColors
Represents colors and offsets in a gradient.
Definition: properties.py:466
lottie.objects.shapes.Path.to_bezier
def to_bezier(self)
Returns a Path corresponding to this Shape.
Definition: shapes.py:423
lottie.objects.shapes.Gradient
Definition: shapes.py:533
lottie.objects.shapes.BoundingBox.center
def center(self)
Center point of the bounding box.
Definition: shapes.py:40
lottie.objects.shapes.Merge.merge_mode
merge_mode
Merge Mode.
Definition: shapes.py:808
lottie.objects.shapes.BoundingBox.width
def width(self)
Definition: shapes.py:56
lottie.objects.shapes.Star
Star shape.
Definition: shapes.py:237
lottie.objects.shapes.Fill.fill_rule
fill_rule
Fill rule.
Definition: shapes.py:523
lottie.objects.shapes.Twist.angle
angle
Definition: shapes.py:823
lottie.objects.shapes.Group.bounding_box
def bounding_box(self, time=0)
Bounding box of the shape element at the given time.
Definition: shapes.py:451
lottie.objects.properties.MultiDimensional
An animatable property that holds a NVector.
Definition: properties.py:385
lottie.objects.shapes.StrokeDashType
Definition: shapes.py:596
lottie.objects.shapes.LineJoin
Definition: shapes.py:582
lottie.objects.shapes.ShapeElement
Base class for all elements of ShapeLayer and Group.
Definition: shapes.py:72
lottie.objects.shapes.Composite
Definition: shapes.py:695
lottie.objects.shapes.Twist
Definition: shapes.py:813
lottie.objects.shapes.Ellipse.bounding_box
def bounding_box(self, time=0)
Bounding box of the shape element at the given time.
Definition: shapes.py:351
lottie.objects.shapes.Repeater.__init__
def __init__(self, copies=1)
Definition: shapes.py:765
lottie.objects.shapes.BoundingBox.size
def size(self)
Definition: shapes.py:67
lottie.objects.shapes.Fill.__init__
def __init__(self, color=None)
Definition: shapes.py:516
lottie.objects.shapes.Star.outer_radius
outer_radius
Star's outer radius.
Definition: shapes.py:263
lottie.objects.properties.ColorValue
An animatable property that holds a Color.
Definition: properties.py:452
lottie.objects.shapes.Path.__init__
def __init__(self, bezier=None)
Definition: shapes.py:407
lottie.objects.shapes.Star.inner_radius
inner_radius
Star's inner radius.
Definition: shapes.py:259
lottie.objects.shapes.BaseStroke
Definition: shapes.py:620
lottie.objects.shapes.Ellipse.position
position
Ellipse's position.
Definition: shapes.py:347
lottie.objects.shapes.Star._bezier_t
def _bezier_t(self, time)
Definition: shapes.py:308
lottie.objects.shapes.GradientStroke.bounding_box
def bounding_box(self, time=0)
Bounding box of the shape element at the given time.
Definition: shapes.py:676
lottie.objects.shapes.BoundingBox.include
def include(self, x, y)
Expands the box to include the point at x, y.
Definition: shapes.py:18
lottie.objects.shapes.Star.bounding_box
def bounding_box(self, time=0)
Bounding box of the shape element at the given time.
Definition: shapes.py:273
lottie.nvector.NVector
Definition: nvector.py:9
lottie.objects.shapes.BoundingBox
Shape bounding box.
Definition: shapes.py:8
lottie.objects.shapes.StrokeDash.name
name
Definition: shapes.py:611
lottie.objects.shapes.Shape
Drawable shape.
Definition: shapes.py:126