4 releases
0.1.3 | Oct 21, 2024 |
---|---|
0.1.2 | Sep 27, 2024 |
0.1.1 | Sep 24, 2024 |
0.1.0 | Sep 21, 2024 |
#302 in GUI
32 downloads per month
Used in talon-gui
20KB
260 lines
egui-theme-lerp
A simple library for egui to smoothly animate theme transitions by interpolating between any two visuals/themes. It works with any set of visuals, allowing transitions between light/dark modes or custom themes.
Installation
Add the following to your Cargo.toml
:
[dependencies]
egui-theme-lerp = "0.1.0"
Usage
use egui_theme_lerp::ThemeAnimator;
use egui::Visuals;
pub struct MainWindow {
theme_animator: ThemeAnimator,
}
impl MainWindow {
pub fn new() -> Self {
Self {
theme_animator: ThemeAnimator::new(Visuals::light(), Visuals::dark()),
}
}
}
impl eframe::App for MainWindow {
fn update(&mut self, ctx: &eframe::egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
if self.theme_animator.anim_id.is_none() {
self.theme_animator.create_id(ui);
} else {
self.theme_animator.animate(ctx);
}
ui.vertical_centered(|ui| {
if ui.button("Switch Theme".to_string()).clicked() {
self.theme_animator.start();
}
});
});
}
}
Run Demo
The demo is accessible online via this link
-
Clone the repository
git clone https://github.com/TheRustyPickle/egui-theme-lerp
-
Move into the demo folder
cd egui-theme-lerp/demo
- To run natively
cargo run --release
or
- To run in wasm locally install the required target with
rustup target add wasm32-unknown-unknown
- Install Trunk with
cargo install --locked trunk
trunk serve
to run and visithttp://127.0.0.1:8080/
- To run natively
Contributing
Contributions, issues, and feature requests are welcome! If you'd like to contribute, please open a pull request.
License
This project is licensed under the MIT License.
Dependencies
~4–9MB
~84K SLoC