//! An example demonstrating how to translate, rotate and scale UI elements. use bevy::color::palettes::css::DARK_GRAY; use bevy::color::palettes::css::RED; use bevy::color::palettes::css::YELLOW; use bevy::prelude::*; use core::f32::consts::FRAC_PI_8; fn main() { App::new() .add_plugins(DefaultPlugins) .add_systems(Startup, setup) .add_systems(Update, button_system) .add_systems(Update, translation_system) .run(); } const NORMAL_BUTTON: Color = Color::WHITE; const HOVERED_BUTTON: Color = Color::Srgba(YELLOW); const PRESSED_BUTTON: Color = Color::Srgba(RED); /// A button that rotates the target node #[derive(Component)] pub struct RotateButton(pub Rot2); /// A button that scales the target node #[derive(Component)] pub struct ScaleButton(pub f32); /// Marker component so the systems know which entities to translate, rotate and scale #[derive(Component)] pub struct TargetNode; /// Handles button interactions fn button_system( mut interaction_query: Query< ( &Interaction, &mut BackgroundColor, Option<&RotateButton>, Option<&ScaleButton>, ), (Changed, With