feat(colors): add all Rosé Pine variants

This commit is contained in:
Kristofers Solo 2025-01-05 00:33:27 +02:00
parent f2f333b8cf
commit 4145abda19
10 changed files with 222 additions and 55 deletions

View File

@ -8,7 +8,7 @@ native-dev:
# Run native release # Run native release
native-release: native-release:
cargo run --release --no-default-features RUSTC_WRAPPER=sccache cargo run --release --no-default-features
# Run web dev # Run web dev
web-dev: web-dev:
@ -16,7 +16,7 @@ web-dev:
# Run web release # Run web release
web-release: web-release:
trunk serve --release --no-default-features RUSTC_WRAPPER=sccache trunk serve --release --no-default-features
# Run tests # Run tests
test: test:

View File

@ -1,4 +1,4 @@
pub const MOVEMENT_THRESHOLD: f32 = 0.01; pub const MOVEMENT_THRESHOLD: f32 = 0.01;
pub const WALL_OVERLAP_MODIFIER: f32 = 1.25; pub const WALL_OVERLAP_MODIFIER: f32 = 1.25;
pub const FLOOR_Y_OFFSET: u8 = 100; pub const FLOOR_Y_OFFSET: u8 = 200;
pub const MOVEMENT_COOLDOWN: f32 = 1.0; // one second cooldown pub const MOVEMENT_COOLDOWN: f32 = 1.0; // one second cooldown

18
src/floor/systems/fog.rs Normal file
View File

@ -0,0 +1,18 @@
use bevy::prelude::*;
use crate::theme::{palette::rose_pine::RosePineDawn, prelude::ColorScheme};
pub fn setup_camera_fog(mut commands: Commands) {
commands.spawn((
Name::new("Fog"),
DistanceFog {
color: RosePineDawn::Overlay.to_color(),
directional_light_color: RosePineDawn::Overlay.to_color(),
falloff: FogFalloff::Linear {
start: 1.,
end: 20.,
},
..default()
},
));
}

View File

@ -1,14 +1,17 @@
mod despawn; mod despawn;
mod fog;
mod movement; mod movement;
mod spawn; mod spawn;
use crate::maze::MazePluginLoaded; use crate::maze::MazePluginLoaded;
use bevy::prelude::*; use bevy::prelude::*;
use despawn::despawn_floor; use despawn::despawn_floor;
use fog::setup_camera_fog;
use movement::{handle_floor_transition_events, move_floors}; use movement::{handle_floor_transition_events, move_floors};
use spawn::spawn_floor; use spawn::spawn_floor;
pub(super) fn plugin(app: &mut App) { pub(super) fn plugin(app: &mut App) {
app.add_systems(Startup, setup_camera_fog);
app.add_systems( app.add_systems(
Update, Update,
( (

View File

@ -48,7 +48,6 @@ pub fn handle_floor_transition_events(
} }
for event in event_reader.read() { for event in event_reader.read() {
dbg!(&event);
let Some((current_entity, current_floor)) = current_query.get_single().ok() else { let Some((current_entity, current_floor)) = current_query.get_single().ok() else {
continue; continue;
}; };
@ -68,7 +67,6 @@ pub fn handle_floor_transition_events(
for (entity, transforms, _, movement_state) in maze_query.iter_mut() { for (entity, transforms, _, movement_state) in maze_query.iter_mut() {
let target_y = (FLOOR_Y_OFFSET as f32).mul_add(direction, transforms.translation.y); let target_y = (FLOOR_Y_OFFSET as f32).mul_add(direction, transforms.translation.y);
dbg!(movement_state, target_y);
if movement_state.is_none() { if movement_state.is_none() {
commands.entity(entity).insert(FloorYTarget(target_y)); commands.entity(entity).insert(FloorYTarget(target_y));
} }
@ -77,7 +75,6 @@ pub fn handle_floor_transition_events(
update_current_next_floor(&mut commands, current_entity, target_entity); update_current_next_floor(&mut commands, current_entity, target_entity);
break; break;
} }
event_reader.clear();
} }
fn update_current_next_floor(commands: &mut Commands, current: Entity, target: Entity) { fn update_current_next_floor(commands: &mut Commands, current: Entity, target: Entity) {

View File

@ -14,6 +14,7 @@ use bevy::{
audio::{AudioPlugin, Volume}, audio::{AudioPlugin, Volume},
prelude::*, prelude::*,
}; };
use theme::{palette::rose_pine, prelude::ColorScheme};
pub struct AppPlugin; pub struct AppPlugin;
@ -26,7 +27,7 @@ impl Plugin for AppPlugin {
); );
// Spawn the main camera. // Spawn the main camera.
app.add_systems(Startup, spawn_camera); app.add_systems(Startup, (spawn_camera, load_background));
// Add Bevy plugins. // Add Bevy plugins.
app.add_plugins( app.add_plugins(
@ -100,3 +101,11 @@ fn spawn_camera(mut commands: Commands) {
IsDefaultUiCamera, IsDefaultUiCamera,
)); ));
} }
fn load_background(mut commands: Commands) {
#[cfg(feature = "dev")]
let colorcheme = rose_pine::RosePine::Base;
#[cfg(not(feature = "dev"))]
let colorcheme = rose_pine::RosePineDawn::Base;
commands.insert_resource(ClearColor(colorcheme.to_color()));
}

View File

@ -1,7 +1,7 @@
use super::resources::GlobalMazeConfig; use super::resources::GlobalMazeConfig;
use crate::{ use crate::{
constants::WALL_OVERLAP_MODIFIER, constants::WALL_OVERLAP_MODIFIER,
theme::{palette::rose_pine::RosePine, prelude::ColorScheme}, theme::{palette::rose_pine::RosePineDawn, prelude::ColorScheme},
}; };
use bevy::{prelude::*, utils::HashMap}; use bevy::{prelude::*, utils::HashMap};
use std::f32::consts::FRAC_PI_2; use std::f32::consts::FRAC_PI_2;
@ -15,7 +15,7 @@ pub struct MazeAssets {
pub wall_mesh: Handle<Mesh>, pub wall_mesh: Handle<Mesh>,
pub hex_material: Handle<StandardMaterial>, pub hex_material: Handle<StandardMaterial>,
pub wall_material: Handle<StandardMaterial>, pub wall_material: Handle<StandardMaterial>,
pub custom_materials: HashMap<RosePine, Handle<StandardMaterial>>, pub custom_materials: HashMap<RosePineDawn, Handle<StandardMaterial>>,
} }
impl MazeAssets { impl MazeAssets {
@ -24,7 +24,7 @@ impl MazeAssets {
materials: &mut ResMut<Assets<StandardMaterial>>, materials: &mut ResMut<Assets<StandardMaterial>>,
global_config: &GlobalMazeConfig, global_config: &GlobalMazeConfig,
) -> Self { ) -> Self {
let custom_materials = RosePine::iter() let custom_materials = RosePineDawn::iter()
.map(|color| (color, materials.add(color.to_standart_material()))) .map(|color| (color, materials.add(color.to_standart_material())))
.collect(); .collect();
Self { Self {

View File

@ -8,8 +8,9 @@ use crate::{
events::SpawnMaze, events::SpawnMaze,
resources::GlobalMazeConfig, resources::GlobalMazeConfig,
}, },
theme::palette::rose_pine::RosePine, theme::palette::rose_pine::RosePineDawn,
}; };
use bevy::prelude::*; use bevy::prelude::*;
use hexlab::prelude::{Tile as HexTile, *}; use hexlab::prelude::{Tile as HexTile, *};
use hexx::HexOrientation; use hexx::HexOrientation;
@ -100,12 +101,12 @@ pub(super) fn spawn_single_hex_tile(
let material = match tile.pos() { let material = match tile.pos() {
pos if pos == maze_config.start_pos => assets pos if pos == maze_config.start_pos => assets
.custom_materials .custom_materials
.get(&RosePine::Pine) .get(&RosePineDawn::Pine)
.cloned() .cloned()
.unwrap_or_default(), .unwrap_or_default(),
pos if pos == maze_config.end_pos => assets pos if pos == maze_config.end_pos => assets
.custom_materials .custom_materials
.get(&RosePine::Love) .get(&RosePineDawn::Love)
.cloned() .cloned()
.unwrap_or_default(), .unwrap_or_default(),
_ => assets.hex_material.clone(), _ => assets.hex_material.clone(),

View File

@ -1,6 +1,6 @@
use bevy::prelude::*; use bevy::prelude::*;
use crate::theme::{palette::rose_pine::RosePine, prelude::ColorScheme}; use crate::theme::{palette::rose_pine::RosePineDawn, prelude::ColorScheme};
pub(super) fn generate_pill_mesh(radius: f32, half_length: f32) -> Mesh { pub(super) fn generate_pill_mesh(radius: f32, half_length: f32) -> Mesh {
Mesh::from(Capsule3d { Mesh::from(Capsule3d {
@ -10,7 +10,7 @@ pub(super) fn generate_pill_mesh(radius: f32, half_length: f32) -> Mesh {
} }
pub(super) fn blue_material() -> StandardMaterial { pub(super) fn blue_material() -> StandardMaterial {
let color = RosePine::Pine; let color = RosePineDawn::Pine;
StandardMaterial { StandardMaterial {
base_color: color.to_color(), base_color: color.to_color(),
emissive: color.to_linear_rgba() * 3., emissive: color.to_linear_rgba() * 3.,

View File

@ -1,45 +1,184 @@
use super::rgb_u8; use crate::{
use crate::theme::prelude::ColorScheme; create_color_scheme,
theme::{colorscheme::ColorScheme, palette::rgb_u8},
};
use bevy::prelude::*; use bevy::prelude::*;
use strum::EnumIter; use strum::EnumIter;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter)] create_color_scheme!(
pub enum RosePine { pub RosePine, {
Base, Base: "#191724",
Surface, Surface: "#1f1d2e",
Overlay, Overlay: "#26233a",
Muted, Muted: "#6e6a86",
Subtle, Subtle: "#908caa",
Text, Text: "#e0def4",
Love, Love: "#eb6f92",
Gold, Gold: "#f6c177",
Rose, Rose: "#ebbcba",
Pine, Pine: "#31748f",
Foam, Foam: "#9ccfd8",
Iris, Iris: "#c4a7e7",
HighlightLow, HighlightLow: "#21202e",
HighlightMed, HighlightMed: "#403d52",
HighlightHigh, HighlightHigh: "#524f67"
}
impl ColorScheme for RosePine {
fn to_color(&self) -> Color {
match self {
Self::Base => rgb_u8(25, 23, 36),
Self::Surface => rgb_u8(31, 29, 46),
Self::Overlay => rgb_u8(38, 35, 58),
Self::Muted => rgb_u8(110, 106, 134),
Self::Subtle => rgb_u8(144, 140, 170),
Self::Text => rgb_u8(224, 222, 244),
Self::Love => rgb_u8(235, 111, 146),
Self::Gold => rgb_u8(246, 193, 119),
Self::Rose => rgb_u8(235, 188, 186),
Self::Pine => rgb_u8(49, 116, 143),
Self::Foam => rgb_u8(156, 207, 216),
Self::Iris => rgb_u8(196, 167, 231),
Self::HighlightLow => rgb_u8(33, 32, 46),
Self::HighlightMed => rgb_u8(64, 61, 82),
Self::HighlightHigh => rgb_u8(82, 79, 103),
}
} }
);
create_color_scheme!(
pub RosePineMoon, {
Base: "#232136",
Surface: "#2a273f",
Overlay: "#393552",
Muted: "#6e6a86",
Subtle: "#908caa",
Text: "#e0def4",
Love: "#eb6f92",
Gold: "#f6c177",
Rose: "#ea9a97",
Pine: "#3e8fb0",
Foam: "#9ccfd8",
Iris: "#c4a7e7",
HighlightLow: "#2a283e",
HighlightMed: "#44415a",
HighlightHigh: "#56526e"
}
);
create_color_scheme!(
pub RosePineDawn, {
Base: "#faf4ed",
Surface: "#fffaf3",
Overlay: "#f2e9e1",
Muted: "#9893a5",
Subtle: "#797593",
Text: "#575279",
Love: "#b4637a",
Gold: "#ea9d34",
Rose: "#d7827e",
Pine: "#286983",
Foam: "#56949f",
Iris: "#907aa9",
HighlightLow: "#f4ede8",
HighlightMed: "#dfdad9",
HighlightHigh: "#cecacd"
}
);
#[macro_export]
macro_rules! create_color_scheme {
($(#[$meta:meta])* $vis:vis $name:ident, {
Base: $base:expr,
Surface: $surface:expr,
Overlay: $overlay:expr,
Muted: $muted:expr,
Subtle: $subtle:expr,
Text: $text:expr,
Love: $love:expr,
Gold: $gold:expr,
Rose: $rose:expr,
Pine: $pine:expr,
Foam: $foam:expr,
Iris: $iris:expr,
HighlightLow: $hl_low:expr,
HighlightMed: $hl_med:expr,
HighlightHigh: $hl_high:expr
}) => {
$(#[$meta])*
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter)]
$vis enum $name {
Base,
Surface,
Overlay,
Muted,
Subtle,
Text,
Love,
Gold,
Rose,
Pine,
Foam,
Iris,
HighlightLow,
HighlightMed,
HighlightHigh,
}
impl $name {
fn hex_to_rgb(hex: &str) -> (u8, u8, u8) {
let hex = if hex.starts_with('#') { &hex[1..] } else { hex };
let r = u8::from_str_radix(&hex[0..2], 16).unwrap_or(0);
let g = u8::from_str_radix(&hex[2..4], 16).unwrap_or(0);
let b = u8::from_str_radix(&hex[4..6], 16).unwrap_or(0);
(r, g, b)
}
}
impl ColorScheme for $name {
fn to_color(&self) -> Color {
match self {
Self::Base => {
let (r, g, b) = Self::hex_to_rgb($base);
rgb_u8(r, g, b)
},
Self::Surface => {
let (r, g, b) = Self::hex_to_rgb($surface);
rgb_u8(r, g, b)
},
Self::Overlay => {
let (r, g, b) = Self::hex_to_rgb($overlay);
rgb_u8(r, g, b)
},
Self::Muted => {
let (r, g, b) = Self::hex_to_rgb($muted);
rgb_u8(r, g, b)
},
Self::Subtle => {
let (r, g, b) = Self::hex_to_rgb($subtle);
rgb_u8(r, g, b)
},
Self::Text => {
let (r, g, b) = Self::hex_to_rgb($text);
rgb_u8(r, g, b)
},
Self::Love => {
let (r, g, b) = Self::hex_to_rgb($love);
rgb_u8(r, g, b)
},
Self::Gold => {
let (r, g, b) = Self::hex_to_rgb($gold);
rgb_u8(r, g, b)
},
Self::Rose => {
let (r, g, b) = Self::hex_to_rgb($rose);
rgb_u8(r, g, b)
},
Self::Pine => {
let (r, g, b) = Self::hex_to_rgb($pine);
rgb_u8(r, g, b)
},
Self::Foam => {
let (r, g, b) = Self::hex_to_rgb($foam);
rgb_u8(r, g, b)
},
Self::Iris => {
let (r, g, b) = Self::hex_to_rgb($iris);
rgb_u8(r, g, b)
},
Self::HighlightLow => {
let (r, g, b) = Self::hex_to_rgb($hl_low);
rgb_u8(r, g, b)
},
Self::HighlightMed => {
let (r, g, b) = Self::hex_to_rgb($hl_med);
rgb_u8(r, g, b)
},
Self::HighlightHigh => {
let (r, g, b) = Self::hex_to_rgb($hl_high);
rgb_u8(r, g, b)
},
}
}
}
};
} }