mirror of
https://github.com/danbulant/cushy
synced 2026-07-06 11:40:37 +00:00
Add example for the Image widget itself
This commit is contained in:
parent
1429051cbb
commit
bea18f97ae
1 changed files with 10 additions and 7 deletions
|
|
@ -20,14 +20,17 @@ 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
|
||||||
AnyTexture::Lazy(
|
let dynamic_texture = Dynamic::new(
|
||||||
LazyTexture::from_image(
|
AnyTexture::Lazy(
|
||||||
image::DynamicImage::ImageRgba8(
|
LazyTexture::from_image(
|
||||||
image::ImageBuffer::new(1, 1)
|
image::DynamicImage::ImageRgba8(
|
||||||
),
|
image::ImageBuffer::new(1, 1)
|
||||||
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:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue