Impeller
Impeller is a 2D vector graphics renderer used in Flutter. Impeller can also be used standalone (without flutter) with its C API (only openGL is exposed at the moment). This crate provides a safe rust wrapper around the C API (and also the raw bindings).
What can it do?
- draw 2D shapes like paths (lines/curvies), rectangles, circles, etc.
- draw AND layout text.
- draw effects like blurs, shadows, color blending etc.
- clipping using any shape.
Where do I want to use it?
- UI libraries are the best use-case.
- 2D games? easy to embed Impeller into any opengl app.
Why Impeller?
- Blazingly? Fast - It is used in Flutter, so, you know it will be maintained and improved continuously. The focus is also on consistency to keep everything running smooth.
- Great text rendering AND layout - The rust ecosystem is severely lacking when it comes to text. Impeller is basically production grade when it comes to text.
- The object model is very simple and takes like 15 minutes to learn.
- Easy to Embed - Any opengl-based app/game can embed Impeller in less than 10 lines.
- Fast compilation - The only bottleneck is network speed to download the prebuilt libs.
And even that can be avoided with the
cache_binariesfeature.
Why not Impeller?
- This is not a pure rust library. Impeller is written in C++. The rust wrapper only supports mainstream platforms like macos/linux/windows/android by using pre-built libraries.
- cannot build from source. We use pre-built static/shared libraries. Impeller lives in flutter's monorepo, so building it requires like 15+ GB of space, which seems like way too much resource usage. idk. you are always welcome to contribute to support source builds.
- We only support opengl (no vulkan/metal/d3d and no fallback software renderer).
- Impeller supports a limited subset of skia's features. If you need more power, use Skia-rs.
- Impeller is not thread-safe (It could be, but I have yet to figure out the soundness of different operations in a multithreaded context).
How to use the crate
For libraries who are just "using" the API (eg: building structs/calling fns), all you need to do is just use the crate with no features. By default, we don't do anything (no download or linking at all).
The final bin/executable user can enable the download_binaries feature to download the prebuilt artefacts (static or dynamic libraries) from github releases.
NOTE: We use curl to download and tar to extract the archives. linux, mac and windows (10+) will have these by default, but if you don't, please install curl + tar.
Features
download_binaries- Downloads the prebuilt libraries from github releases and links them to your project.static_link- If disabled, we will use dynamic linking. If enabled, we will link static libraries.debug_binaries- If disabled, we will use the release (debug info stripped) libs. If enabled, we will use the debug libs (useful for debugging).cache_binaries- If you enable this feature, we will cache the binaries in.impeller_cacheof your project dir (parent oftargetdir). Add it to .gitignore to avoid committing the cache. caching is good, as it avoids redownloading aftercargo cleanand this also makes the builds faster. You also get to inspect the downloaded archives in the cache to debug any errors.codegen- This is an internal feature and only used to generate bindings before publishing.