Skip to content

About

Lottie-Windows is a library (and related tools) for rendering Lottie animations on Windows 10 and Windows 11.

Topics

Resources

Stars

724 stars

Watchers

28 watching

Forks

Latest commit

 

History

480 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lottie-Windows

Lottie-Windows is a library for rendering Adobe After Effects animations natively in your application. This project adds Windows to the Lottie family of tools also targeting Android, iOS, and Web.

Lottie simplifies the design-to-code workflow for bringing engaging, interactive vector animations to your Windows applications, with significant improvements in terms of performance, quality, and engineering efficiency over traditional approaches such as gifs, manually coded animations, etc. Lottie-Windows uses the Windows.UI.Composition APIs to provide smooth 60fps animations and resolution-independent vector graphics.

Lottie-Windows Gif

Lottie-Windows consists of 3 related products:

  • Lottie-Windows library for parsing and translating Bodymovin JSON files
  • LottieGen command-line tool for generating C# or C++ code to be used instead of JSON
  • Lottie Viewer application for previewing JSON and also generating code

This repo also contains source code for samples.

It also contains LottieRuntime, native C++/WinRT source that builds the composition tree at runtime from a serialized animation produced by LottieGen -Language flatbuffer. It keeps the animation as data, like the JSON path does, but without shipping a JSON parser or the translator. See the format for how the two relate.

Quick start

There are two options to integrate Lottie animations into your WinUI 3 or UWP project.

Option #1, using dynamic loader

  1. Install CommunityToolkit.WinUI.Lottie nuget package for WinUI project (or CommunityToolkit.Uwp.Lottie for UWP project).
    • WinUI 3 apps must target .NET 10 (net10.0-windows10.0.18362.0 or later) and Windows App SDK 1.6.241114003 or later.
    • .NET UWP apps (<UseUwp>true</UseUwp>) must target net10.0-windows10.0.26100.0 or later. Classic UWP apps (uap10.0.16299 or later, .NET Native) are still supported.
  2. Dependencies (Microsoft.Graphics.Win2D for WinUI, Win2D.uwp and Microsoft.UI.Xaml for UWP) flow transitively, so you don't need to add them yourself.
    • WinUI 3: the package copies Win2D's native Microsoft.Graphics.Canvas.dll into your app output. Build for a specific platform or runtime identifier (x86, x64 or arm64, for example -r win-x64); an AnyCPU build without a runtime identifier gets no native Win2D DLL. A direct Microsoft.Graphics.Win2D reference is optional (1.0.5.1 and 1.3.x have been tested). To supply the DLL yourself, set <CommunityToolkitWinUILottieCopyWin2DNative>false</CommunityToolkitWinUILottieCopyWin2DNative>.
  3. In your .xaml markup file add:
        ...
        xmlns:lottie="using:CommunityToolkit.WinUI.Lottie"
        ...
        <AnimatedVisualPlayer>
            <lottie:LottieVisualSource UriSource="ms-appx:///Assets/Spinner.lcomp" />
        </AnimatedVisualPlayer>
    or for UWP project:
        ...
        xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
        xmlns:lottie="using:CommunityToolkit.WinUI.Lottie"
        ...
        <muxc:AnimatedVisualPlayer>
            <lottie:LottieVisualSource UriSource="ms-appx:///Assets/Spinner.lcomp" />
        </muxc:AnimatedVisualPlayer>
    Use the same UriSource for a .json asset. To precompile it, run LottieGen -InputFile Spinner.json -Language flatbuffer -WinUIVersion 3.0 (use 2.8 for WinUI 2/UWP) and include the resulting .lcomp as app Content. The managed player reads the compiled composition without translating JSON at runtime; no generated C# or native reader package is needed. If LottieGen produces several UAP variants, point the player at the file compatible with your target. It does not search for fallback files. The ms-appx examples use package assets. In an unpackaged WinUI 3 app, load a local file with await source.SetSourceAsync(storageFile) or pass an input stream.

Option #2, using codegen (recommended)

  1. Install codegen tool using dotnet tool install lottiegen in powershell
  2. Run codegen tool lottiegen -InputFile MyAnimation.json -Language cs -WinUIVersion 3.0
    • For UWP projects use -WinUIVersion 2.X depending on the version of Microsoft.UI.Xaml
    • Other language options: cppwinrt and cppcx
  3. Add generated source files to the project
  4. Generated code doesn't need the Lottie package, but it may need its dependencies. Install them directly if needed: Microsoft.Graphics.Win2D and Microsoft.WindowsAppSDK for WinUI 3, or Win2D.uwp and Microsoft.UI.Xaml for UWP.
  5. In your .xaml markup file add:
        ...
        xmlns:animatedvisuals="using:AnimatedVisuals"
        ...
        <AnimatedVisualPlayer>
            <animatedvisuals:MyAnimation/>
        </AnimatedVisualPlayer>
    or for UWP project:
        ...
        xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
        xmlns:animatedvisuals="using:AnimatedVisuals"
        ...
        <muxc:AnimatedVisualPlayer>
            <animatedvisuals:MyAnimation/>
        </muxc:AnimatedVisualPlayer>

Supported SDKs

  • May 2019 Update (18362) and later

Documentation

Build Status

Package Branch Status Latest nuget version
CommunityToolkit.WinUI.Lottie main Build Status NuGet
CommunityToolkit.Uwp.Lottie main Build Status NuGet
LottieGen main Build Status NuGet

Feedback and Requests

Please use GitHub Issues for bug reports and feature requests.

Principles

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.

About

Lottie-Windows is a library (and related tools) for rendering Lottie animations on Windows 10 and Windows 11.

Topics

Resources

Stars

724 stars

Watchers

28 watching

Forks

Releases

Used by

Contributors

Languages