Add example for the Image widget itself

This commit is contained in:
Daniel Bulant 2024-10-08 11:00:58 +02:00
parent 1429051cbb
commit bea18f97ae
No known key found for this signature in database

View file

@ -20,6 +20,7 @@ Use a [`Dynamic`][Dynamic]`(`[`AnyTexture`][AnyTexture]`)`.
You can default to a empty texture like so: You can default to a empty texture like so:
```rs ```rs
let dynamic_texture = Dynamic::new(
AnyTexture::Lazy( AnyTexture::Lazy(
LazyTexture::from_image( LazyTexture::from_image(
image::DynamicImage::ImageRgba8( image::DynamicImage::ImageRgba8(
@ -28,6 +29,8 @@ AnyTexture::Lazy(
cushy::kludgine::wgpu::FilterMode::Linear cushy::kludgine::wgpu::FilterMode::Linear
) )
) )
);
let widget = Image::new(dynamic_texture); // Creates image widget with an empty texture, that can later be changed
``` ```
To load an image from bytes, use the [`image`][image-crate] crate and then pass it to LazyTexture: To load an image from bytes, use the [`image`][image-crate] crate and then pass it to LazyTexture: