From 0e20708ebe07b2a28de3feeb4a04f482763a00eb Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Mon, 27 Nov 2023 10:45:07 +0000 Subject: [PATCH] feat: intialise fonts Former-commit-id: d9ee695b4336ee17a83c33ca88f3b67d5bec6023 --- Cargo.lock | 1 + Cargo.toml | 1 + .../iosevka-comfy-bold.ttf.REMOVED.git-id | 1 + ...osevka-comfy-bolditalic.ttf.REMOVED.git-id | 1 + ...iosevka-comfy-extrabold.ttf.REMOVED.git-id | 1 + ...a-comfy-extrabolditalic.ttf.REMOVED.git-id | 1 + .../iosevka-comfy-italic.ttf.REMOVED.git-id | 1 + .../iosevka-comfy-light.ttf.REMOVED.git-id | 1 + ...sevka-comfy-lightitalic.ttf.REMOVED.git-id | 1 + .../iosevka-comfy-medium.ttf.REMOVED.git-id | 1 + ...evka-comfy-mediumitalic.ttf.REMOVED.git-id | 1 + .../iosevka-comfy-regular.ttf.REMOVED.git-id | 1 + .../iosevka-comfy-semibold.ttf.REMOVED.git-id | 1 + ...ka-comfy-semibolditalic.ttf.REMOVED.git-id | 1 + ...iosevka-comfy-semilight.ttf.REMOVED.git-id | 1 + ...a-comfy-semilightitalic.ttf.REMOVED.git-id | 1 + src/main.rs | 225 +++--------------- 17 files changed, 52 insertions(+), 189 deletions(-) create mode 100644 assets/fonts/iosevka-comfy-bold.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-bolditalic.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-extrabold.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-extrabolditalic.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-italic.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-light.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-lightitalic.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-medium.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-mediumitalic.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-regular.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-semibold.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-semibolditalic.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-semilight.ttf.REMOVED.git-id create mode 100644 assets/fonts/iosevka-comfy-semilightitalic.ttf.REMOVED.git-id diff --git a/Cargo.lock b/Cargo.lock index 3044050..c27fb86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,6 +210,7 @@ name = "aspiration" version = "0.1.0" dependencies = [ "bevy", + "lazy_static", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3269df8..e64c739 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,3 +20,4 @@ rustflags = ["-C", "link-arg=-fuse-ld=mold"] [dependencies] bevy = { version = "0.12.0", features = [ "wayland", "dynamic_linking" ] } +lazy_static = "1.4.0" diff --git a/assets/fonts/iosevka-comfy-bold.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-bold.ttf.REMOVED.git-id new file mode 100644 index 0000000..36dcc57 --- /dev/null +++ b/assets/fonts/iosevka-comfy-bold.ttf.REMOVED.git-id @@ -0,0 +1 @@ +43a6ab5c4dfb60b08c412649395ce5c25e188a8c \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-bolditalic.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-bolditalic.ttf.REMOVED.git-id new file mode 100644 index 0000000..4b5e6f9 --- /dev/null +++ b/assets/fonts/iosevka-comfy-bolditalic.ttf.REMOVED.git-id @@ -0,0 +1 @@ +d9d289c17441292d43c9000d3fe2d06bcd73b214 \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-extrabold.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-extrabold.ttf.REMOVED.git-id new file mode 100644 index 0000000..4c6bdf5 --- /dev/null +++ b/assets/fonts/iosevka-comfy-extrabold.ttf.REMOVED.git-id @@ -0,0 +1 @@ +e1c86f5e1b7c808380038ac6d2c5ae06ad0d67fb \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-extrabolditalic.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-extrabolditalic.ttf.REMOVED.git-id new file mode 100644 index 0000000..03c432b --- /dev/null +++ b/assets/fonts/iosevka-comfy-extrabolditalic.ttf.REMOVED.git-id @@ -0,0 +1 @@ +c76f5b2976714df5af0fd4f27ba57bd3392c8d41 \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-italic.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-italic.ttf.REMOVED.git-id new file mode 100644 index 0000000..347866f --- /dev/null +++ b/assets/fonts/iosevka-comfy-italic.ttf.REMOVED.git-id @@ -0,0 +1 @@ +3ff6b0a802dda30a115759e831f7592e8749a399 \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-light.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-light.ttf.REMOVED.git-id new file mode 100644 index 0000000..099edd4 --- /dev/null +++ b/assets/fonts/iosevka-comfy-light.ttf.REMOVED.git-id @@ -0,0 +1 @@ +9447cdf13ebcfa1bf2702c0b3307fba5fc37566a \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-lightitalic.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-lightitalic.ttf.REMOVED.git-id new file mode 100644 index 0000000..58158d0 --- /dev/null +++ b/assets/fonts/iosevka-comfy-lightitalic.ttf.REMOVED.git-id @@ -0,0 +1 @@ +1ce2c88bbb22be0fe92ffa0d8033c3342c01d4a5 \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-medium.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-medium.ttf.REMOVED.git-id new file mode 100644 index 0000000..72d00bd --- /dev/null +++ b/assets/fonts/iosevka-comfy-medium.ttf.REMOVED.git-id @@ -0,0 +1 @@ +14a2fcfc9303b8ee2da12bd7fb7f7e8c93273dae \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-mediumitalic.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-mediumitalic.ttf.REMOVED.git-id new file mode 100644 index 0000000..8de9339 --- /dev/null +++ b/assets/fonts/iosevka-comfy-mediumitalic.ttf.REMOVED.git-id @@ -0,0 +1 @@ +2fedc5759bd029781ab5a905b6feac0581269623 \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-regular.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-regular.ttf.REMOVED.git-id new file mode 100644 index 0000000..d9ea4fa --- /dev/null +++ b/assets/fonts/iosevka-comfy-regular.ttf.REMOVED.git-id @@ -0,0 +1 @@ +ccc5a6f8221d5251ef60bf750fd69949924a9051 \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-semibold.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-semibold.ttf.REMOVED.git-id new file mode 100644 index 0000000..9d85da7 --- /dev/null +++ b/assets/fonts/iosevka-comfy-semibold.ttf.REMOVED.git-id @@ -0,0 +1 @@ +2c175f57fcff6bca4b3b47b55f3f731ebe4d2765 \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-semibolditalic.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-semibolditalic.ttf.REMOVED.git-id new file mode 100644 index 0000000..94255c7 --- /dev/null +++ b/assets/fonts/iosevka-comfy-semibolditalic.ttf.REMOVED.git-id @@ -0,0 +1 @@ +5f32aaed882da219dc6cebbb318889094fab909a \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-semilight.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-semilight.ttf.REMOVED.git-id new file mode 100644 index 0000000..06db190 --- /dev/null +++ b/assets/fonts/iosevka-comfy-semilight.ttf.REMOVED.git-id @@ -0,0 +1 @@ +f473198ba766139e4dad21984370852602abe882 \ No newline at end of file diff --git a/assets/fonts/iosevka-comfy-semilightitalic.ttf.REMOVED.git-id b/assets/fonts/iosevka-comfy-semilightitalic.ttf.REMOVED.git-id new file mode 100644 index 0000000..bd4bae3 --- /dev/null +++ b/assets/fonts/iosevka-comfy-semilightitalic.ttf.REMOVED.git-id @@ -0,0 +1 @@ +b1639fea30723b077f0c69149e5950b1a15af699 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index a8037a5..fcd3527 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,209 +1,56 @@ -//! Illustrates bloom post-processing in 2d. +use bevy::prelude::*; +use std::collections::HashMap; +use lazy_static::lazy_static; -use bevy::{ - core_pipeline::{ - bloom::{BloomCompositeMode, BloomSettings}, - tonemapping::Tonemapping, - }, - prelude::*, - sprite::MaterialMesh2dBundle, -}; +// Create a map of the Hypernova colorscheme +lazy_static!{ + static ref HYPERNOVA: HashMap<&'static str, Color> = vec![ + ("BLACK", Color::hex("0d0d0f").unwrap()), + ("DARK_GRAY", Color::hex("151517").unwrap()), + ("GRAY", Color::hex("27272b").unwrap()), + ("LIGHT_GRAY", Color::hex("454449").unwrap()), + ("SUBTEXT", Color::hex("d9d0d7").unwrap()), + ("WHITE", Color::hex("fefefa").unwrap()), + ("RED", Color::hex("f06969").unwrap()), + ("MAGENTA", Color::hex("e887bb").unwrap()), + ("PURPLE", Color::hex("a292e8").unwrap()), + ("BLUE", Color::hex("78b9c4").unwrap()), + ("CYAN", Color::hex("7ee6ae").unwrap()), + ("GREEN", Color::hex("91d65c").unwrap()), + ("YELLOW", Color::hex("d9d564").unwrap()), + ].iter().copied().collect(); +} fn main() { App::new() + .insert_resource(ClearColor(HYPERNOVA.get("DARK_GRAY").copied().unwrap())) .add_plugins(DefaultPlugins) .add_systems(Startup, setup) - .add_systems(Update, update_bloom_settings) + .add_systems(Update, render_ui) .run(); } -fn setup( - mut commands: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, - asset_server: Res, -) { - commands.spawn(( +fn setup(mut commands: Commands) { + commands.spawn( Camera2dBundle { camera: Camera { - hdr: true, // 1. HDR is required for bloom + hdr: true, ..default() }, - tonemapping: Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended ..default() - }, - BloomSettings::default(), // 3. Enable bloom for the camera - )); - - // Sprite - commands.spawn(SpriteBundle { - texture: asset_server.load("branding/bevy_bird_dark.png"), - sprite: Sprite { - color: Color::rgb(5.0, 5.0, 5.0), // 4. Put something bright in a dark environment to see the effect - custom_size: Some(Vec2::splat(160.0)), - ..default() - }, - ..default() - }); - - // Circle mesh - commands.spawn(MaterialMesh2dBundle { - mesh: meshes.add(shape::Circle::new(100.).into()).into(), - // 4. Put something bright in a dark environment to see the effect - material: materials.add(ColorMaterial::from(Color::rgb(7.5, 0.0, 7.5))), - transform: Transform::from_translation(Vec3::new(-200., 0., 0.)), - ..default() - }); - - // Hexagon mesh - commands.spawn(MaterialMesh2dBundle { - mesh: meshes - .add(shape::RegularPolygon::new(100., 6).into()) - .into(), - // 4. Put something bright in a dark environment to see the effect - material: materials.add(ColorMaterial::from(Color::rgb(6.25, 9.4, 9.1))), - transform: Transform::from_translation(Vec3::new(200., 0., 0.)), - ..default() - }); - - // UI - commands.spawn( - TextBundle::from_section( - "", - TextStyle { - font_size: 18.0, - color: Color::WHITE, - ..default() - }, - ) - .with_style(Style { - position_type: PositionType::Absolute, - bottom: Val::Px(10.0), - left: Val::Px(10.0), - ..default() - }), + } ); } -// ------------------------------------------------------------------------------------------------ - -fn update_bloom_settings( - mut camera: Query<(Entity, Option<&mut BloomSettings>), With>, - mut text: Query<&mut Text>, - mut commands: Commands, - keycode: Res>, - time: Res