Skip to content

Commit

Permalink
fix: colors
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Jul 6, 2024
1 parent c93ba16 commit 7932c20
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ publish = false
bevy_vello = { path = "../../", features = ["experimental-dotLottie"] }
bevy = { workspace = true }
bevy_pancam = { version = "0.11", features = ["bevy_egui"] }
bevy_egui = "0.25"
bevy_egui = "0.28.0"
13 changes: 7 additions & 6 deletions examples/demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ fn main() {
.add_plugins(EguiPlugin)
.add_plugins(VelloPlugin)
.init_resource::<EmbeddedAssetRegistry>()
.add_plugins(bevy_pancam::PanCamPlugin)
//.add_plugins(bevy_pancam::PanCamPlugin)
.add_systems(Startup, setup_vector_graphics)
.add_systems(Update, (print_metadata, ui::controls_ui));
embedded_asset!(app, "assets/calendar.json");
app.run();
}

fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServer>) {
commands.spawn((Camera2dBundle::default(), bevy_pancam::PanCam::default()));
commands.spawn(Camera2dBundle::default());
//commands.spawn((Camera2dBundle::default(), bevy_pancam::PanCam::default()));
commands
.spawn(VelloAssetBundle {
vector: asset_server.load::<VelloAsset>("embedded://demo/assets/calendar.json"),
Expand All @@ -42,26 +43,26 @@ fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServe
autoplay: false,
..default()
})
.theme(Theme::new().add("calendar", css::BLUE.into()))
.theme(Theme::new().add("calendar", css::YELLOW.into()))
.transition(PlayerTransition::OnMouseEnter { state: "play" })
.reset_playhead_on_start()
})
.with_state(
PlayerState::new("play")
.playback_options(PlaybackOptions {
looping: PlaybackLoopBehavior::DoNotLoop,
speed: 0.25,
speed: 0.75,
..default()
})
.theme(Theme::new().add("calendar", css::GREEN.into()))
.theme(Theme::new().add("calendar", css::LIME.into()))
.transition(PlayerTransition::OnMouseLeave { state: "rev" }),
)
.with_state(
PlayerState::new("rev")
.playback_options(PlaybackOptions {
looping: PlaybackLoopBehavior::DoNotLoop,
direction: PlaybackDirection::Reverse,
speed: 0.25,
speed: 0.75,
..default()
})
.theme(Theme::new().add("calendar", css::RED.into()))
Expand Down
26 changes: 16 additions & 10 deletions examples/demo/src/ui.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::prelude::*;
use bevy_egui::{
egui::{self},
egui::{self, Color32},
EguiContexts,
};
use bevy_vello::{prelude::*, vello_svg::usvg::strict_num::Ulps};
Expand Down Expand Up @@ -48,6 +48,11 @@ pub fn controls_ui(
player.pause();
playhead.seek(frame);
};
if player.is_stopped() {
ui.colored_label(Color32::RED, "stopped");
} else if !player.is_playing() {
ui.colored_label(Color32::YELLOW, "paused");
}
});

ui.horizontal_wrapped(|ui| {
Expand Down Expand Up @@ -245,21 +250,22 @@ pub fn controls_ui(
ui.heading("Theme");
for layer in composition.as_ref().get_layers() {
let color = theme.get_mut(layer).cloned().unwrap_or_default();
let color = color.to_linear();
let mut color_edit = [color.red, color.green, color.blue, color.alpha];
let color = color.to_srgba().to_u8_array();
let mut color32 =
Color32::from_rgba_unmultiplied(color[0], color[1], color[2], color[3]);
ui.horizontal(|ui| {
if ui
.color_edit_button_rgba_unmultiplied(&mut color_edit)
.changed()
{
let [r, g, b, a] = color_edit;
if ui.color_edit_button_srgba(&mut color32).changed() {
let r = color32.r();
let g = color32.g();
let b = color32.b();
let a = color32.a();
player
.state_mut()
.theme
.as_mut()
.unwrap()
.edit(layer, Color::linear_rgba(r, g, b, a));
theme.edit(layer, Color::linear_rgba(r, g, b, a));
.edit(layer, Color::srgba_u8(r, g, b, a));
theme.edit(layer, Color::srgba_u8(r, g, b, a));
};
ui.label(layer);
});
Expand Down

0 comments on commit 7932c20

Please sign in to comment.