mirror of
https://github.com/griffi-gh/hUI.git
synced 2025-04-07 08:26:27 -05:00
use image crate in example 7
This commit is contained in:
parent
433d25618b
commit
803240a83e
hui-examples
|
@ -9,6 +9,7 @@ publish = false
|
|||
hui = { path = "../hui" }
|
||||
hui-painter = { path = "../hui-painter" }
|
||||
hui-glium = { path = "../hui-glium" }
|
||||
hui-euc = { path = "../hui-euc" }
|
||||
hui-winit = { path = "../hui-winit" }
|
||||
kubi-logging = { git = "https://github.com/griffi-gh/kubi", rev = "1e051c47b64c967305e4bbbd464ef5da2cc56bbb" }
|
||||
glium = "0.36"
|
||||
|
|
|
@ -14,6 +14,7 @@ use hui::{
|
|||
signal::Signal,
|
||||
size,
|
||||
};
|
||||
use hui_painter::texture::SourceTextureFormat;
|
||||
|
||||
#[path = "../boilerplate.rs"]
|
||||
#[macro_use]
|
||||
|
@ -24,11 +25,17 @@ struct SetValue(f32);
|
|||
|
||||
ui_main!(
|
||||
"hUI: 9-Patch demo",
|
||||
init: |_ui| {
|
||||
init: |ui| {
|
||||
(
|
||||
NinePatchAsset {
|
||||
// FIXME add image loader here
|
||||
image: todo!("FIXME add image loader here"), //ui.add_image_file_path("./hui-examples/assets/ninepatch_button.png").unwrap(),
|
||||
image: {
|
||||
let data = std::fs::read("./hui-examples/assets/ninepatch_button.png").unwrap();
|
||||
let image = image::load_from_memory(&data[..]).unwrap();
|
||||
let width = image.width() as usize;
|
||||
let data = image.as_rgba8().unwrap().as_raw();
|
||||
ui.textures_mut().add_with_data(SourceTextureFormat::RGBA8, data, width)
|
||||
},
|
||||
size: (190, 49),
|
||||
scalable_region: Rect {
|
||||
position: vec2(8. / 190., 8. / 49.),
|
||||
|
|
Loading…
Reference in a new issue