LottieFiles/dotlottie-rs
소개
Rust로 구현한 고성능 Lottie 및 dotLottie 플레이어입니다. Android, iOS, Web(WASM), C/C++ 바인딩을 제공합니다.
웹 및 앱 개발What you can do
- One Rust codebase builds for Android, iOS, the web, Flutter, React Native, and desktop.
- All players render with ThorVG, so an animation draws the same on every platform.
- Theming overrides slots at runtime. Supported slot types are color, scalar, vector, position, text, gradient, image, and bezier path.
- State machines add interactivity through states, transitions, guards, and actions.
측정된 스타 증가
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +3
- in 1 month
- +11
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginaldotLottie Rust
dotLottie Rust
[!TIP] Looking for animations to use with this player? Browse 100,000+ free Lottie animations and download any of them as
.lottieor.json, or create your own with Lottie Creator.
dotlottie-rs is the dotLottie runtime, written in Rust. Every official dotLottie player uses it, so theming, state machines, and multi-animation files behave the same way on every platform.
Native platforms call it through a C API generated with cbindgen. The web player calls it through wasm-bindgen bindings.
flowchart TD
A[dotLottie-web] --> WASM[WASM / wasm-bindgen]
B[dotLottie-ios] --> CAPI[C API]
C[dotLottie-android] --> CAPI
D[dotLottie-flutter] --> CAPI
E[dotLottie-react-native] --> CAPI
WASM --> dotlottiers[dotlottie-rs]
CAPI --> dotlottiers
dotlottiers --> Thorvg[ThorVG Lottie renderer]
What is dotLottie?
dotLottie is an open-source file format that packs one or more Lottie animations and their assets into a single file.
A .lottie file is a ZIP archive compressed with Deflate.
Features
- One Rust codebase builds for Android, iOS, the web, Flutter, React Native, and desktop.
- All players render with ThorVG, so an animation draws the same on every platform.
- Theming overrides slots at runtime. Supported slot types are color, scalar, vector, position, text, gradient, image, and bezier path.
- State machines add interactivity through states, transitions, guards, and actions.
- A single
.lottiefile can hold several animations, and the player can switch between them. - The
.lottiereader handles manifest v1 and v2 and embedded assets. - The
c_apifeature generates a C header with cbindgen for the Android NDK, iOS, and desktop. - The
wasm-bindgen-apifeature generates WebAssembly bindings for the browser.
Players
These official players use dotlottie-rs:
Contents
Installation
cargo add dotlottie-rs
dotlottie-rs requires Rust 1.89 or later. ThorVG ships inside the crate, and the build script compiles it from source. You need clang to compile ThorVG and libclang for bindgen.
The default features include the ThorVG software renderer with PNG, JPEG, WebP and TTF support, expressions and threads. To choose your own set:
[dependencies]
dotlottie-rs = { version = "0.1", default-features = false, features = [
"dotlottie", # .lottie files
"state-machines", # state machines
"theming", # themes and slots
"tvg-cpu", # software rendering backend
"tvg-png", # PNG image support
] }
Crates
- dotlottie-rs is the core library. It includes the C API (feature
c_api) and the wasm-bindgen bindings (featurewasm-bindgen-api).
Examples
The examples are in dotlottie-rs/examples. Run the Rust ones from the dotlottie-rs directory with cargo run --example <name>.
| Example | Shows |
|---|---|
player |
Loading .lottie and Lottie JSON files, playback controls, themes, background. Add --features audio for audio layers. |
slots |
Every slot type (color, scalar, vector, position, gradient, text, bezier path, image), with static and keyframed values. |
external_assets |
Supplying images that are not embedded in the animation through an asset resolver. |
state_machine |
A playground for state machines: inputs, pointer events and the event log. |
opengl |
Rendering with the OpenGL backend. Needs --features tvg-gl. |
| c_api | The C API, in an SDL2 window. |
| web | The WASM build in the browser, on the software, WebGL and WebGPU renderers. |
| node | The WASM build in Node, rendering one frame to an image. |
Development
For Rust development, use cargo as usual.
The Makefile is only for building release artifacts for Android, Apple, WASM, Linux, macOS, Windows, and native. BUILD_SYSTEM.md describes how it works.
Cross-platform release builds
You need GNU make.
Apple targets (macOS, iOS, tvOS, visionOS, watchOS, Mac Catalyst) also need a Mac with Xcode.
To install the tools for every platform, run this from the repo root:
make setup
To set up one platform:
make android-setupinstalls the Android Rust targets. You need the Android NDK.make apple-setupinstalls the Apple Rust targets. You need Xcode.make wasm-setupinstalls thewasm32-unknown-unknowntarget and wasm-bindgen-cli.make linux-setupinstalls the Linux Rust targets.make macos-setupinstalls the macOS Rust targets.make windows-setupinstalls the Windows Rust targets. You need the MSVC Build Tools.
Building
Each of these is a Makefile target:
android: all Android architectures (ARM64, x86_64, x86, ARMv7)apple: all Apple platforms (macOS, iOS, tvOS, visionOS, watchOS, Mac Catalyst)wasm: WebAssembly with the software rendererwasm-webgl: WebAssembly with the WebGL2 rendererwasm-webgpu: WebAssembly with the WebGPU rendererwasm-all: all three WebAssembly variantsnative: native library for the host platform, with the C APInative-opengl: native library with the OpenGL renderernative-webgpu: native library with the WebGPU rendererlinux: Linux x86_64 and ARM64macos: native macOS libraries for ARM64 and x86_64 (no Xcode frameworks)windows: Windows x86_64 and ARM64
android and apple build every supported architecture. Each wasm target builds one module.
For example, to build all Android architectures:
make android
To build one architecture:
make android-aarch64 # Android ARM64 only
make apple-macos-arm64 # macOS ARM64 only
Running make with no target prints the help menu.
Native C API
This command builds the C library and header into release/native/dotlottie-player/, with the header in include/ and the library in lib/:
make native
On Windows, use the Windows targets instead. They need the MSVC Build Tools.
make windows-setup
make windows-x86_64
dotlottie-rs/examples/c_api/demo-player.c is an example program that uses the C API.
Other targets
testruns all tests on a single thread.clippyruns clippy on all targets and fails onprint_stdout.cleanremoves native artifacts, the Cargotargetdirectory, and the generated bindings.list-platformslists the supported platforms.
Each platform also has its own clean target: android-clean, apple-clean, wasm-clean, linux-clean, macos-clean, windows-clean, and native-clean.
Run make help for the full list.
Release process
- A pull request that changes behaviour adds a changeset. Install knope and run
knope document-changeto create one. - Every push to
mainruns theCreate Release PRworkflow. It opens or updates the release PR with the new version and the changelog built from the pending changesets, then runs CI on it. - Review the release PR and merge it.
- The merge starts the
Releaseworkflow. It builds the Linux, macOS and Windows libraries, creates the tag and the GitHub release, and uploads the archives. It then publishes the crate to crates.io with Trusted Publishing.
The Release workflow publishes the version in dotlottie-rs/Cargo.toml when that version has no tag yet. If a release build fails, fix it on main and run the workflow by hand. If only the crates.io step fails, re-run that job.
Related tools
- dotlottie-js creates and edits
.lottiefiles. - relottie parses Lottie animations.
License
관련 프로젝트 살펴보기
불러오는 중…