question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] How is gradient fill stored in lottie format?

See original GitHub issue

After effects - [A] First color stop location - 10% [B] First color value - #FF0000 [C] Color mid point location - 47% [D] Second color stop location - 100% [E] Second color value - #00FF00 [F] First opacity location - 0% (value - 100%) [G] Opacity mid point location - 53% [H] Second opacity location - 100% (value - 100%)

Lottie file - "g":{"p":3,"k":{"a":0,"k":[0.1,1,0,0,0.523,0.5,0.5,0,1,0,1,0],"ix":9}}

Can anyone clarify how is "k" calculated here. ^__^ I tried searching the documentation, but could not find anything.

My guess: [{0.1 - A}, {1, 0, 0 - B}, {0.523 - somehow calculated from C}, {0.5, 0.5 - no idea}, {0, 1, 0 - E}, {1, 0 - no idea}]

This will be so much helpful in #1785 @bodymovin would you be able to help here?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

4reactions
bodymovincommented, Mar 18, 2020

Hi. “p” is the number of “Stops” the gradient has. In this case 3. Each point has 4 values (color stop location,red,green,blue) Since you have only 12 elements in the array, it means it has no opacity information, meaning it is all opaque. If you had opacity information, instead of 12 elements, you would see 18 (12 + 6). The last 6 relate to the opacity stops that just needs a pair per point (opacity stop location, alpha)

The k value, is the number of keyframes. In your case, the gradient is not animated. If you add keyframes to the property, you would see that “k” changes it’s shape. Let me know if you need more clarification.

2reactions
bodymovincommented, Mar 28, 2020

It seems you are using an old version of the format. the “e” property has been deprecated for a long time in favor of having a “s” value on every keyframe, including the last one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make a gradient in Lottie (EASY) | by Aydin Uzmez
Now double-click the Rectangle tool in the current project. Click “Rectangle 1”. Add menu “Gradient Fill”. You can see default gradient fill in...
Read more >
Gradient fill animation on Lottiefiles. Free Lottie Animation
Gradient fill animation · Bodymovin Version: 5.1.13 · Resolution: 76 x 20 · Filesize: 1.8 KB ( 1 layers ).
Read more >
Top Principles How to Design Lottie Animations for your ...
A Lottie is a JSON-based animation file format that you can use on any platform as easily as static assets. They are small...
Read more >
Lottie Docs
Lottie is a library for Android, iOS, Web, and Windows that parses Adobe After Effects animations exported as json with Bodymovin and renders...
Read more >
How to expand this lottie animation to fill the whole screen
I am currently working on having a gradient background animation in my app... I am doing so with the help of a lottie...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found