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: AlignmentGeometryWhere 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: ImageRepeatWhether the picture repeats to fill the box.
match_text_direction: boolWhether the picture is mirrored when the box reads right to left.
scale: f32The picture’s pixels per logical pixel: 2.0 draws it at half its pixel size.
opacity: f32How opaque the picture is, 0..=1.
invert_colors: boolWhether the picture’s colours are inverted, after the colour filter.
Implementations§
Source§impl DecorationImage
impl DecorationImage
Sourcepub fn new(image: impl Into<Option<Arc<ImageData>>>) -> DecorationImage
pub fn new(image: impl Into<Option<Arc<ImageData>>>) -> DecorationImage
The picture image, centred, at its own size or smaller.
Sourcepub fn color_filter(self, filter: ColorFilter) -> DecorationImage
pub fn color_filter(self, filter: ColorFilter) -> DecorationImage
Sets the colour filter.
Sourcepub fn fit(self, fit: BoxFit) -> DecorationImage
pub fn fit(self, fit: BoxFit) -> DecorationImage
Sets the fit.
Sourcepub fn alignment(
self,
alignment: impl Into<AlignmentGeometry>,
) -> DecorationImage
pub fn alignment( self, alignment: impl Into<AlignmentGeometry>, ) -> DecorationImage
Sets where the picture sits.
Sourcepub fn center_slice(self, slice: Rect) -> DecorationImage
pub fn center_slice(self, slice: Rect) -> DecorationImage
Sets the centre slice, the part that stretches.
Sourcepub fn repeat(self, repeat: ImageRepeat) -> DecorationImage
pub fn repeat(self, repeat: ImageRepeat) -> DecorationImage
Sets how the picture repeats.
Sourcepub fn match_text_direction(self, matches: bool) -> DecorationImage
pub fn match_text_direction(self, matches: bool) -> DecorationImage
Mirrors the picture when the box reads right to left.
Sourcepub fn scale(self, scale: f32) -> DecorationImage
pub fn scale(self, scale: f32) -> DecorationImage
Sets the picture’s pixels per logical pixel.
Sourcepub fn opacity(self, opacity: f32) -> DecorationImage
pub fn opacity(self, opacity: f32) -> DecorationImage
Sets the opacity.
Sourcepub fn invert_colors(self, invert: bool) -> DecorationImage
pub fn invert_colors(self, invert: bool) -> DecorationImage
Inverts the picture’s colours.
Sourcepub fn lerp(
a: Option<&DecorationImage>,
b: Option<&DecorationImage>,
t: f32,
) -> Option<DecorationImage>
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.
Sourcepub fn pieces(
&self,
size: Size,
rect: Rect,
direction: TextDirection,
) -> (Vec<ImagePiece>, bool)
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.
Trait Implementations§
Source§impl Clone for DecorationImage
impl Clone for DecorationImage
Source§fn clone(&self) -> DecorationImage
fn clone(&self) -> DecorationImage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more