This commit is contained in:
Philip Kristoffersen
2022-04-09 21:49:11 +02:00
committed by GitHub
parent 2a1523470f
commit a0c6fe0c8f
22 changed files with 2349 additions and 572 deletions
+48
View File
@@ -0,0 +1,48 @@
pub mod ui_colors {
use egui::Color32;
pub const TEXT_COLOR: Color32 = Color32::from_rgb(255, 212, 163);
pub const BACKGROUND_COLOR: Color32 = Color32::from_rgb(13, 43, 69);
pub const BG_STROKE_COLOR: Color32 = Color32::from_rgb(32, 60, 86);
// pub const WHITE:Color32 = Color32::from_rgb(255, 236, 214);
pub const LIGHT_ORANGE: Color32 = Color32::from_rgb(255, 212, 163);
pub const ORANGE: Color32 = Color32::from_rgb(255, 170, 94);
pub const PURLPLE: Color32 = Color32::from_rgb(84, 78, 104);
}
pub mod ui_images {
use eframe::epi::IconData;
use egui::{ColorImage, ImageData};
pub const IMPORT_GAMES_IMAGE: &[u8] = include_bytes!("../../resources/import_games_button.png");
pub const LOGO_32: &[u8] = include_bytes!("../../resources/logo32.png");
pub const LOGO_ICON: &[u8] = include_bytes!("../../resources/logo_small.png");
pub fn get_import_image() -> ImageData {
ImageData::Color(load_image_from_memory(IMPORT_GAMES_IMAGE).unwrap())
}
pub fn get_logo() -> ImageData {
ImageData::Color(load_image_from_memory(LOGO_32).unwrap())
}
pub fn get_logo_icon() -> IconData {
let image = image::load_from_memory(LOGO_ICON).unwrap();
let image_buffer = image.to_rgba8();
let pixels = image_buffer.as_flat_samples();
IconData {
height: image.height() as u32,
width: image.width() as u32,
rgba: pixels.as_slice().to_vec(),
}
}
fn load_image_from_memory(image_data: &[u8]) -> Result<ColorImage, image::ImageError> {
let image = image::load_from_memory(image_data)?;
let size = [image.width() as _, image.height() as _];
let image_buffer = image.to_rgba8();
let pixels = image_buffer.as_flat_samples();
Ok(ColorImage::from_rgba_unmultiplied(size, pixels.as_slice()))
}
}