Find a file
Leon Styhre 79ff784721 Squashed 'external/rlottie/' changes from bf3d272df..875626965
875626965 Check border of color table while generating gradient
d1636c7b4 Ignore animations with objects of unspecified type
f3eed9a33 add formal parameter void to lottie_init() and lottie_shutdown()
519bd08b0 Add lottie_init() and lottie_shutdown() c api.
447cb7dd1 replace unsigned int with uint32_t in Int()
d7cf0a5ab replace uint ushort and uchar typedefs with uint32 uint16 and uint8 -- added format script to run clang format on latest commit.
16beec845 lottiemodel: Improve opacity calculation for gradient stop
327fb7dba Reject reversed frames
625bc4c48 Finite loop in VBezier::tAtLength()
ddbc9dce7 rlottie/capi: Add missing multiply for Path
c0e16e571 Check Layer.mExtra and Transform.mExtra before dereferencing
9f78532c8 Avoid access to last element of empty mChildren vector
4e08acd8c remove RAPIDJSON_ASSERT() by placing the parser in error state
7affa78fe Fix dereferencing of null pointer in model::Layer::solidColor() getter
9d17ff8e6 Skip dash array of size one or zero
f379dfe15 add the /inc folder as an include path at build time
194b31736 Improve matte rendering performance for simple layer
7c5b40cbb CMake: fix MSVC warnings
fa44b753e fix compileing error
41f906480 On windows, stbi__fopen opens a path containing non-English characters or symbols will fail due to encoding problems, so the filename parameter is assumed to be utf-8 and converted to utf-16, and then call _wfopen_s or _wfopen
29b391b95 add lottie_configure_model_cache_size() c api
3cd00151c Fix comparison
bd4c4e1f8 MT and MTd
c593b57eb Remove link warnings on MSVC
132ca0a00 #include "fix" for rust-bindgen
c9780b46d Fix CMake build in subdirectory
1cb2021d6 Fix crash when path animation  data is empty
ad9beaec6 Added support for RoundedCornor objects.
a41bd7383 rlottie: draw line if width or height is 0
ed94baf14 resource: polish player png image.
9b4c4d2af resource: add rlottie_player image.
2d7b1fa2b Fixed build with GCC 11.
9cd9a6e95 vs2019: Add release build option
d733e953b updated AUTHORS
fc760ef92 updated AUTHORS
d92d4aaf6 wasm: Add extra functions for lottie animation to use them in rlottie viewer
09662b89d updated AUTHORS
71fbff5d5 example/win32Player: removed unnecessary files.
d25911e6c add app executables
538dfd9aa rename directory rlottiePlayer to win32Player
6fbb67d49 fix openJSONFileDialog
85856dff3 fix animation replace error
f86e97d65 fix animation bitmap size to be set dynamically
55815b2cb move function prototype to animation.h To prevent function prototype duplicate code in source.cpp.
9a71eeca9 add an example of win32 app that play rlottie animation by vs2019
619320cbb add rlottiePlayer Project
4884e0e9b Modify: Update .gitignore
3ebf0c7e3 Docs: Fix README typo
502cc3638 updated license in spec file.
e812ba9e9 Docs: Fix README typo
c98ec565d Update README.md
33295c22f Fixed README typo
073224e69 fixed readme typo
ff8ddfc49 ci: upgrade windows build chain to VS2017
10c1055a3 fixed sign extension warning
98ed2620a build: use shared_module instead of shared_library

git-subtree-dir: external/rlottie
git-subtree-split: 875626965959d8e269ca22175c8e1ad190696c43
2022-01-07 18:43:06 +01:00
.Gifs Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
cmake Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
example Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
inc Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
licenses Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
packaging Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
src Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
test Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
vs2019 Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
.appveyor.yml Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
.clang-format Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
.gitignore Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
.travis.yml Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
arm_build.sh Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
arm_cross.txt Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
AUTHORS Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
CMakeLists.txt Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
COPYING Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
format Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
meson.build Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
meson_options.txt Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
README.md Squashed 'external/rlottie/' changes from bf3d272df..875626965 2022-01-07 18:43:06 +01:00
rlottie.expmap Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
rlottie.pc.in Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
wasm_build.sh Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00
wasm_cross.txt Squashed 'external/rlottie/' content from commit bf3d272df 2022-01-06 22:59:15 +01:00

rlottie

Build Status Build status Gitter

rlottie is a platform independent standalone c++ library for rendering vector based animations and art in realtime.

Lottie loads and renders animations and vectors exported in the bodymovin JSON format. Bodymovin JSON can be created and exported from After Effects with bodymovin, Sketch with Lottie Sketch Export, and from Haiku.

For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand. Since the animation is backed by JSON they are extremely small in size but can be large in complexity!

Here are small samples of the power of Lottie.

Contents

Building Lottie

rlottie supports meson and cmake build system. rlottie is written in C++14. and has a public header dependency of C++11

Meson Build

install meson and ninja if not already installed.

Run meson to configure rlottie

meson build

Run ninja to build rlottie

ninja -C build

Cmake Build

Install cmake if not already installed

Create a build directory for out of source build

mkdir build

Run cmake command inside build directory to configure rlottie.

cd build
cmake ..

# install in a different path. eg ~/test/usr/lib
cmake -DCMAKE_INSTALL_PREFIX=~/test ..

# static build
cmake -DBUILD_SHARED_LIBS=OFF ..

Run make to build rlottie

make -j 2

To install rlottie library

make install

Test

Configure to build test

meson configure -Dtest=true

Build test suit

ninja

Run test suit

ninja test

Back to contents

Demo

If you want to see rlottie library in action without building it please visit rlottie online viewer

While building rlottie library it generates a simple lottie to GIF converter which can be used to convert lottie json file to GIF file.

Run Demo

lottie2gif [lottie file name]

Previewing Lottie JSON Files

Please visit rlottie online viewer

rlottie online viewer uses rlottie wasm library to render the resource locally in your browser. To test your JSON resource drag and drop it to the browser window.

Quick Start

Lottie loads and renders animations and vectors exported in the bodymovin JSON format. Bodymovin JSON can be created and exported from After Effects with bodymovin, Sketch with Lottie Sketch Export, and from Haiku.

You can quickly load a Lottie animation with:

auto animation = rlottie::Animation::loadFromFile("absolute_path/test.json");

You can load a lottie animation from raw data with:

auto animation = rlottie::Animation::loadFromData(std::string(rawData), std::string(cacheKey));

Properties like frameRate , totalFrame , duration can be queried with:

# get the frame rate of the resource.
double frameRate = animation->frameRate();

#get total frame that exists in the resource
size_t totalFrame = animation->totalFrame();

#get total animation duration in sec for the resource
double duration = animation->duration();

Render a particular frame in a surface buffer immediately with:

rlottie::Surface surface(buffer, width , height , stride);
animation->renderSync(frameNo, surface);

Render a particular frame in a surface buffer asyncronousely with:

rlottie::Surface surface(buffer, width , height , stride);
# give a render request
std::future<rlottie::Surface> handle = animation->render(frameNo, surface);
...
#when the render data is needed
rlottie::Surface surface = handle.get();

Back to contents

Dynamic Property

You can update properties dynamically at runtime. This can be used for a variety of purposes such as:

  • Theming (day and night or arbitrary themes).
  • Responding to events such as an error or a success.
  • Animating a single part of an animation in response to an event.
  • Responding to view sizes or other values not known at design time.

Understanding After Effects

To understand how to change animation properties in Lottie, you should first understand how animation properties are stored in Lottie. Animation properties are stored in a data tree that mimics the information hierarchy of After Effects. In After Effects a Composition is a collection of Layers that each have their own timelines. Layer objects have string names, and their contents can be an image, shape layers, fills, strokes, or just about anything that is drawable. Each object in After Effects has a name. Lottie can find these objects and properties by their name using a KeyPath.

Usage

To update a property at runtime, you need 3 things:

  1. KeyPath
  2. rLottie::Property
  3. setValue()

KeyPath

A KeyPath is used to target a specific content or a set of contents that will be updated. A KeyPath is specified by a list of strings that correspond to the hierarchy of After Effects contents in the original animation. KeyPaths can include the specific name of the contents or wildcards:

  • Wildcard *
    • Wildcards match any single content name in its position in the keypath.
  • Globstar **
    • Globstars match zero or more layers.

Properties

rLottie::Property is an enumeration of properties that can be set. They correspond to the animatable value in After Effects and the available properties are listed below.

enum class Property {
    FillColor,     /*!< Color property of Fill object , value type is rlottie::Color */
    FillOpacity,   /*!< Opacity property of Fill object , value type is float [ 0 .. 100] */
    StrokeColor,   /*!< Color property of Stroke object , value type is rlottie::Color */
    StrokeOpacity, /*!< Opacity property of Stroke object , value type is float [ 0 .. 100] */
    StrokeWidth,   /*!< stroke with property of Stroke object , value type is float */
    ...
};

setValue()

setValue() requires a keypath of string and value. The value can be Color, Size and Point structure or a function that returns them. Color, Size, and Point vary depending on the type of rLottie::Property. This value or function(callback) is called and applied to every frame. This value can be set differently for each frame by using the FrameInfo argument passed to the function.

Usage

animation->setValue<rlottie::Property::FillColor>("**",rlottie::Color(0, 1, 0));
animation->setValue<rlottie::Property::FillColor>("Layer1.Box 1.Fill1",
    [](const rlottie::FrameInfo& info) {
         if (info.curFrame() < 15 )
             return rlottie::Color(0, 1, 0);
         else {
             return rlottie::Color(1, 0, 0);
         }
     });

Back to contents

Supported After Effects Features

Shapes Supported
Shape 👍
Ellipse 👍
Rectangle 👍
Rounded Rectangle 👍
Polystar 👍
Group 👍
Trim Path (individually) 👍
Trim Path (simultaneously) 👍
Renderable Supported
Fill 👍
Stroke 👍
Radial Gradient 👍
Linear Gradient 👍
Gradient Stroke 👍
Transforms Supported
Position 👍
Position (separated X/Y) 👍
Scale 👍
Skew
Rotation 👍
Anchor Point 👍
Opacity 👍
Parenting 👍
Auto Orient 👍
Interpolation Supported
Linear Interpolation 👍
Bezier Interpolation 👍
Hold Interpolation 👍
Spatial Bezier Interpolation 👍
Rove Across Time 👍
Masks Supported
Mask Path 👍
Mask Opacity 👍
Add 👍
Subtract 👍
Intersect 👍
Lighten
Darken
Difference
Expansion
Feather
Mattes Supported
Alpha Matte 👍
Alpha Inverted Matte 👍
Luma Matte 👍
Luma Inverted Matte 👍
Merge Paths Supported
Merge
Add
Subtract
Intersect
Exclude Intersection
Layer Effects Supported
Fill
Stroke
Tint
Tritone
Levels Individual Controls
Text Supported
Glyphs
Fonts
Transform
Fill
Stroke
Tracking
Anchor point grouping
Text Path
Per-character 3D
Range selector (Units)
Range selector (Based on)
Range selector (Amount)
Range selector (Shape)
Range selector (Ease High)
Range selector (Ease Low)
Range selector (Randomize order)
expression selector
Other Supported
Expressions
Images 👍
Precomps 👍
Time Stretch 👍
Time remap 👍
Markers 👍

Back to contents

Issues or Feature Requests?

File github issues for anything that is broken. Be sure to check the list of supported features before submitting. If an animation is not working, please attach the After Effects file to your issue. Debugging without the original can be very difficult. For immidiate assistant or support please reach us in Gitter