pub struct Image { /* private fields */ }Expand description
A picture from a PNG, JPEG, GIF, WebP or SVG file, drawn at a fixed size.
A GIF of more than one frame plays while it is drawn, at its own delays, looping as the file says. The filters run once on the picture at the size drawn, and the result is cached, so a filtered image costs what a plain one does to draw.
Implementations§
Source§impl Image
impl Image
Sourcepub const DEFAULT_SIZE: u32 = 64
pub const DEFAULT_SIZE: u32 = 64
The default width and height in logical pixels.
Sourcepub fn new(source: impl IntoProp<PathBuf>) -> Image
pub fn new(source: impl IntoProp<PathBuf>) -> Image
An image of the file at source: a path (&str, String, &Path
or PathBuf) or a closure that returns one.
Sourcepub fn fit(self, fit: impl IntoProp<Fit>) -> Image
pub fn fit(self, fit: impl IntoProp<Fit>) -> Image
Sets how the picture fills the image’s box when their shapes differ.
Sourcepub fn tint(self, tint: impl IntoProp<Option<Color>>) -> Image
pub fn tint(self, tint: impl IntoProp<Option<Color>>) -> Image
Paints the picture’s pixels in tint, keeping their alpha, as
Icon::tint does. None, the default, draws it as it is.
Sourcepub fn brightness(self, brightness: impl IntoProp<f32>) -> Image
pub fn brightness(self, brightness: impl IntoProp<f32>) -> Image
Scales the colors, as CSS’s brightness(): 1, the default, leaves
them, 0 is black and 2 twice as bright. A number that isn’t finite
counts as 1, and one below 0 as 0.
Sourcepub fn contrast(self, contrast: impl IntoProp<f32>) -> Image
pub fn contrast(self, contrast: impl IntoProp<f32>) -> Image
Sets the contrast, as CSS’s contrast(): 1, the default, leaves the
colors, 0 is middle gray and more than 1 is stronger. A number that
isn’t finite counts as 1, and one below 0 as 0.
Sourcepub fn saturation(self, saturation: impl IntoProp<f32>) -> Image
pub fn saturation(self, saturation: impl IntoProp<f32>) -> Image
Sets the saturation, as CSS’s saturate(): 1, the default, leaves
the colors, 0 is gray and more than 1 is more vivid. A number that
isn’t finite counts as 1, and one below 0 as 0.
Sourcepub fn blur(self, blur: impl IntoProp<f32>) -> Image
pub fn blur(self, blur: impl IntoProp<f32>) -> Image
Blurs the picture, as CSS’s blur(): the Gaussian’s standard
deviation in logical pixels, 0 by default. Pixels past the picture’s
edge count as its edge pixels, so a blurred picture keeps its edges
opaque. A number that isn’t finite or is below 0 counts as 0. The
blur is for still pictures, such as album art and wallpapers: a
blurred GIF shows its first frame, still.
Sourcepub fn playing(self, playing: impl IntoProp<bool>) -> Image
pub fn playing(self, playing: impl IntoProp<bool>) -> Image
Whether an animated GIF plays, true by default. False pauses it on the frame it shows.
Sourcepub fn transition(self, transition: impl IntoProp<ImageTransition>) -> Image
pub fn transition(self, transition: impl IntoProp<ImageTransition>) -> Image
How a new source comes in: ImageTransition::None, the default,
shows it at once; the others bring it in over the old picture on the
animation clock, repainting only the image’s box. A new source
mid-transition starts again from the picture most of the box shows:
the one leaving before halfway, the one coming in from halfway on.
A new source that can’t be loaded keeps the old picture; the clock
still runs and repaints the box for the transition’s length, since
only the renderer learns the file is bad.
Sourcepub fn visible(self, visible: impl IntoProp<bool>) -> Self
pub fn visible(self, visible: impl IntoProp<bool>) -> Self
Shows or hides the widget. Hidden, it is taken out of the layout, so its space goes to the others, and it isn’t drawn, hit or reached by Tab; it drops the keyboard focus and the pointer. Its bindings and state stay, so it shows again as it was. Shown by default.
Sourcepub fn geometry(self, geometry: Signal<Rect>) -> Self
pub fn geometry(self, geometry: Signal<Rect>) -> Self
Shares where the widget is: after each layout that moves or
resizes it, its laid-out rectangle in the window’s logical
pixels, scrolled with any scroll view around it but not moved by
a style’s translate, scale or rotate, is written to geometry. A
hidden widget writes nothing. An effect that reads it may change
the layout: the window is laid out again at once, until nothing
moves.