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!
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:
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:
KeyPath
rLottie::Property
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.
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
rlottie
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 ofC++11Meson Build
install meson and ninja if not already installed.
Run meson to configure rlottie
Run ninja to build rlottie
Cmake Build
Install cmake if not already installed
Create a build directory for out of source
buildRun cmake command inside
builddirectory to configure rlottie.Run make to build rlottie
To install rlottie library
Test
Configure to build test
Build test suit
Run test suit
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
#
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:
You can load a lottie animation from raw data with:
Properties like
frameRate,totalFrame,durationcan be queried with:Render a particular frame in a surface buffer
immediatelywith:Render a particular frame in a surface buffer
asyncronouselywith:Back to contents
Dynamic Property
You can update properties dynamically at runtime. This can be used for a variety of purposes such as:
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:
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:
Properties
rLottie::Propertyis an enumeration of properties that can be set. They correspond to the animatable value in After Effects and the available properties are listed below.setValue()
setValue()requires a keypath of string and value. The value can beColor,SizeandPointstructure or a function that returns them.Color,Size, andPointvary depending on the type ofrLottie::Property. This value or function(callback) is called and applied to every frame. This value can be set differently for each frame by using theFrameInfoargument passed to the function.Usage
Back to contents
# #
Supported After Effects Features
# 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