added icon
This commit is contained in:
parent
f300a9d3be
commit
bccfbc7a3f
|
@ -7,3 +7,4 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
eframe = "0.26.2"
|
||||
image = "0.24.9"
|
||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -1,15 +1,23 @@
|
|||
use eframe::egui;
|
||||
use std::{thread, time};
|
||||
use image::GenericImageView;
|
||||
use std::{
|
||||
thread,
|
||||
time,
|
||||
sync::Arc,
|
||||
error::Error,
|
||||
};
|
||||
|
||||
|
||||
const MAX_FPS : f32 = 30.0;
|
||||
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
let icon_data = load_icon().unwrap_or_default();
|
||||
|
||||
let options = eframe::NativeOptions {
|
||||
viewport: egui::ViewportBuilder::default()
|
||||
.with_inner_size([1200.0, 800.0]),
|
||||
.with_inner_size([1200.0, 800.0])
|
||||
.with_icon(Arc::new(icon_data)),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
@ -55,3 +63,19 @@ impl Jiji {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_icon() -> Result<egui::IconData, Box<dyn Error>> {
|
||||
let (icon_rgba, icon_width, icon_height) = {
|
||||
let icon = include_bytes!("../assets/icon.png");
|
||||
let image = image::load_from_memory(icon)?;
|
||||
let rgba = image.clone().into_rgba8().to_vec();
|
||||
let (width, height) = image.dimensions();
|
||||
(rgba, width, height)
|
||||
};
|
||||
|
||||
Ok(egui::IconData {
|
||||
rgba: icon_rgba,
|
||||
width: icon_width,
|
||||
height: icon_height,
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue