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