python-lottie  0.6.8+dev6bb61be
A framework to work with lottie files and telegram animated stickers (tgs)
lottie.objects.properties.GradientColors Class Reference

Represents colors and offsets in a gradient. More...

Inheritance diagram for lottie.objects.properties.GradientColors:
[legend]
Collaboration diagram for lottie.objects.properties.GradientColors:
[legend]

Public Member Functions

def __init__ (self, stops=[])
 
def set_stops (self, stops, keyframe=None)
 
def add_color (self, offset, color, keyframe=None)
 
def add_keyframe (self, time, stops, ease=easing.Linear())
 
def get_stops (self, keyframe=None)
 
def stops_at (self, time)
 
- Public Member Functions inherited from lottie.objects.base.LottieObject
def to_dict (self)
 Serializes into a JSON object fit for the Lottie format. More...
 
def load (cls, lottiedict)
 Loads from a JSON object. More...
 
def find (self, search, propname="name")
 Recursively searches for child objects with a matching property. More...
 
def find_all (self, type, predicate=None, include_self=True)
 Find all child objects that match a predicate. More...
 
def clone (self)
 Returns a copy of the object. More...
 
def __str__ (self)
 
- Public Member Functions inherited from lottie.objects.base.LottieObjectMeta
def __new__ (cls, name, bases, attr)
 

Static Public Member Functions

def color_to_stops (self, colors)
 

Public Attributes

 colors
 Animatable colors, as a vector containing [offset, r, g, b] values as a flat array. More...
 
 count
 Number of colors. More...
 

Detailed Description

Represents colors and offsets in a gradient.

Colors are represented as a flat list interleaving offsets and color components in weird ways There are two possible layouts:

Without alpha, the colors are a sequence of offset, r, g, b

With alpha, same as above but at the end of the list there is a sequence of offset, alpha

Examples:

For the gradient [0, red], [0.5, yellow], [1, green] The list would be [0, 1, 0, 0, 0.5, 1, 1, 0, 1, 0, 1, 0]

For the gradient [0, red at 80% opacity], [0.5, yellow at 70% opacity], [1, green at 60% opacity] The list would be [0, 1, 0, 0, 0.5, 1, 1, 0, 1, 0, 1, 0, 0, 0.8, 0.5, 0.7, 1, 0.6]

Lottie JSON
Lottie name Type Description Attribute
k MultiDimensional Animatable colors, as a vector containing [offset, r, g, b] values as a flat array.   colors
p int Number of colors.   count

Definition at line 466 of file properties.py.

Constructor & Destructor Documentation

◆ __init__()

def lottie.objects.properties.GradientColors.__init__ (   self,
  stops = [] 
)

Definition at line 490 of file properties.py.

Member Function Documentation

◆ add_color()

def lottie.objects.properties.GradientColors.add_color (   self,
  offset,
  color,
  keyframe = None 
)

Definition at line 561 of file properties.py.

◆ add_keyframe()

def lottie.objects.properties.GradientColors.add_keyframe (   self,
  time,
  stops,
  ease = easing.Linear() 
)
Parameters
timeFrame time
stopsIterable of (offset, Color) tuples
easeEasing function

Definition at line 577 of file properties.py.

◆ color_to_stops()

def lottie.objects.properties.GradientColors.color_to_stops (   self,
  colors 
)
static
Converts a list of colors (Color) to tuples (offset, color)

Definition at line 499 of file properties.py.

◆ get_stops()

def lottie.objects.properties.GradientColors.get_stops (   self,
  keyframe = None 
)

Definition at line 585 of file properties.py.

◆ set_stops()

def lottie.objects.properties.GradientColors.set_stops (   self,
  stops,
  keyframe = None 
)
Parameters
stopsiterable of (offset, Color) tuples
keyframekeyframe index (or None if not animated)

Definition at line 508 of file properties.py.

◆ stops_at()

def lottie.objects.properties.GradientColors.stops_at (   self,
  time 
)

Definition at line 603 of file properties.py.

Member Data Documentation

◆ colors

lottie.objects.properties.GradientColors.colors

Animatable colors, as a vector containing [offset, r, g, b] values as a flat array.

Definition at line 492 of file properties.py.

◆ count

lottie.objects.properties.GradientColors.count

Number of colors.

Definition at line 494 of file properties.py.


The documentation for this class was generated from the following file: