Skip to main content

Image

Struct Image 

Source
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

Source

pub const DEFAULT_SIZE: u32 = 64

The default width and height in logical pixels.

Source

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.

Source

pub fn width(self, width: impl IntoProp<u32>) -> Image

Sets the width in logical pixels.

Source

pub fn height(self, height: impl IntoProp<u32>) -> Image

Sets the height in logical pixels.

Source

pub fn fit(self, fit: impl IntoProp<Fit>) -> Image

Sets how the picture fills the image’s box when their shapes differ.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn style(self, style: impl IntoProp<Style>) -> Self

Sets the widget’s Style.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Widget for Image

Source§

fn into_element(self: Box<Self>) -> Element

Turns the description, and everything inside it, into the element the window builds nodes from. It runs when the window is created or a list item first appears, before the window’s tree is touched and without recording what it reads, so it only describes.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Image

§

impl !Send for Image

§

impl !Sync for Image

§

impl !UnwindSafe for Image

§

impl Forget for Image

§

impl Freeze for Image

§

impl Move for Image

§

impl Unpin for Image

§

impl UnsafeUnpin for Image

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more