Skip to main content

DecorationImage

Struct DecorationImage 

Source
pub struct DecorationImage {
    pub image: Option<Arc<ImageData>>,
    pub color_filter: Option<ColorFilter>,
    pub fit: Option<BoxFit>,
    pub alignment: AlignmentGeometry,
    pub center_slice: Option<Rect>,
    pub repeat: ImageRepeat,
    pub match_text_direction: bool,
    pub scale: f32,
    pub opacity: f32,
    pub invert_colors: bool,
    /* private fields */
}
Expand description

A picture painted as a background, and the reference’s fitting. A picture painted as a box’s background — the reference’s DecorationImage.

The defaults are the reference’s: centred, not repeated, no slice, at its own scale and opacity, fitted by BoxFit::ScaleDown (or BoxFit::Fill with a centre slice) when no fit is named.

The picture is pixels already decoded. One that is still on its way — a network picture, say — is None for now, and paints nothing until it arrives, as the reference’s does.

Fields§

§image: Option<Arc<ImageData>>

The pixels; None paints nothing.

§color_filter: Option<ColorFilter>

A colour filter over the picture, applied before its opacity is.

§fit: Option<BoxFit>

How the picture is fitted into the box; None is the reference’s default.

§alignment: AlignmentGeometry

Where the picture sits in the spare room, and which part of it a crop keeps.

§center_slice: Option<Rect>

The centre slice, in the picture’s units (its pixels over scale): the part that stretches, while the four corners stay their size and the four edges stretch along their length. Fits that crop (BoxFit::None, BoxFit::Cover) have nothing to stretch and are not meant for it.

§repeat: ImageRepeat

Whether the picture repeats to fill the box.

§match_text_direction: bool

Whether the picture is mirrored when the box reads right to left.

§scale: f32

The picture’s pixels per logical pixel: 2.0 draws it at half its pixel size.

§opacity: f32

How opaque the picture is, 0..=1.

§invert_colors: bool

Whether the picture’s colours are inverted, after the colour filter.

Implementations§

Source§

impl DecorationImage

Source

pub fn new(image: impl Into<Option<Arc<ImageData>>>) -> DecorationImage

The picture image, centred, at its own size or smaller.

Source

pub fn color_filter(self, filter: ColorFilter) -> DecorationImage

Sets the colour filter.

Source

pub fn fit(self, fit: BoxFit) -> DecorationImage

Sets the fit.

Source

pub fn alignment( self, alignment: impl Into<AlignmentGeometry>, ) -> DecorationImage

Sets where the picture sits.

Source

pub fn center_slice(self, slice: Rect) -> DecorationImage

Sets the centre slice, the part that stretches.

Source

pub fn repeat(self, repeat: ImageRepeat) -> DecorationImage

Sets how the picture repeats.

Source

pub fn match_text_direction(self, matches: bool) -> DecorationImage

Mirrors the picture when the box reads right to left.

Source

pub fn scale(self, scale: f32) -> DecorationImage

Sets the picture’s pixels per logical pixel.

Source

pub fn opacity(self, opacity: f32) -> DecorationImage

Sets the opacity.

Source

pub fn invert_colors(self, invert: bool) -> DecorationImage

Inverts the picture’s colours.

Source

pub fn lerp( a: Option<&DecorationImage>, b: Option<&DecorationImage>, t: f32, ) -> Option<DecorationImage>

The picture t of the way from a to b — the reference’s DecorationImage.lerp. Two different pictures are not blended into a third: both are painted, the first at 1 - t and the second added to it at t. A picture on one side only fades in or out. At 0 and 1 the answer is the end itself.

Source

pub fn pieces( &self, size: Size, rect: Rect, direction: TextDirection, ) -> (Vec<ImagePiece>, bool)

Where each part of the picture lands when it is painted into rect, for a box reading in direction, given the picture’s pixel size — the reference’s paintImage, short of the drawing. Also says whether the parts repeat, which is when they are clipped to rect.

Empty when there is nothing to draw: an empty box, an empty picture, or a fit that leaves no room.

Source

pub fn paint( &self, scene: &mut Scene, rect: Rect, direction: TextDirection, blend: f32, )

Paints the picture into rect, for a box reading in direction, at blend of its opacity — the reference’s DecorationImagePainter.paint, short of the clip, which the decoration adds.

Trait Implementations§

Source§

impl Clone for DecorationImage

Source§

fn clone(&self) -> DecorationImage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DecorationImage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DecorationImage

Source§

fn eq(&self, other: &DecorationImage) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DecorationImage

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.