Module freya_elements::elements::image
source · Expand description
image
element let’s you show an image.
For dynamic Images you may use dynamic_bytes
.
§Example
ⓘ
static RUST_LOGO: &[u8] = include_bytes!("./rust_logo.png");
fn app() -> Element {
let image_data = static_bytes(RUST_LOGO);
rsx!(
image {
image_data,
width: "100%", // You must specify size otherwhise it will default to 0
height: "100%",
}
)
}
Constants§
aspect_ratio
controls how animage
element is rendered when facing unexpected dimensions.cache_key
lets you specify an unique identifier for the given image. This will help Freya cache the image decoding, if the cache_key changes the old cache will be pruned and the image (changed or not) will be decoded again.cache_key
is optinal but its recommended to be used, specialy for high quality images. You can pass any value that can be transformed into a string. Like a URL.cover
controls how animage
element position is rendered inside the given dimensions.- Specify the width for the given element.
- Specify the margin of an element. You can do so by four different ways, just like in CSS.
- Specify a maximum height for the given element.
- Specify a maximum width for the given element.
- This can be useful if you use it alongside a percentage for the target size.
- Specify a minimum height for the given element. This can be useful if you use it alongside a percentage for the target size.
- Specify how you want the element to be positioned inside it’s parent area.
sampling
controls how animage
element is resized when scaling from its original size to smaller or larger sizes.- Specify the height for the given element.