pub struct Paste<'img, 'mask, P: Pixel> {
pub position: (u32, u32),
pub image: &'img Image<P>,
pub mask: Option<&'mask Image<BitPixel>>,
pub overlay: Option<OverlayMode>,
}
Expand description
Pastes or overlays an image on top of another image.
Fields§
§position: (u32, u32)
The position of the image to paste.
image: &'img Image<P>
A reference to the image to paste, or the foreground image.
mask: Option<&'mask Image<BitPixel>>
A refrence to an image that masks or filters out pixels based on the values of its own corresponding pixels.
Currently this ony supports images with the BitPixel
type. If you want to mask alpha
values, see Image::mask_alpha
.
If this is None, all pixels will be overlaid on top of the image.
overlay: Option<OverlayMode>
The overlay mode of the image, or None to inherit from the background image.
Implementations§
Source§impl<'img, 'mask, P: Pixel> Paste<'img, 'mask, P>
impl<'img, 'mask, P: Pixel> Paste<'img, 'mask, P>
Sourcepub const fn new(image: &'img Image<P>) -> Self
pub const fn new(image: &'img Image<P>) -> Self
Creates a new image paste with from the given image with the position default to (0, 0)
.
Sourcepub const fn with_position(self, x: u32, y: u32) -> Self
pub const fn with_position(self, x: u32, y: u32) -> Self
Sets the position of where to paste the image at. The position is where the top-left corner of the image will be pasted.
Sourcepub unsafe fn with_mask_unchecked(self, mask: &'mask Image<BitPixel>) -> Self
pub unsafe fn with_mask_unchecked(self, mask: &'mask Image<BitPixel>) -> Self
Sets the mask image to use. Currently this is only limited to BitPixel
images.
§Safety
This should have the same dimensions as the base foreground image! This method does not
check for that though, however if this is not the case, you may get undescriptive panics
later. Use Paste::with_mask
instead if you are not 100% sure that the mask dimensions
are valid.
Sourcepub const fn with_overlay_mode(self, mode: OverlayMode) -> Self
pub const fn with_overlay_mode(self, mode: OverlayMode) -> Self
Sets the overlay mode of the image.
Trait Implementations§
Auto Trait Implementations§
impl<'img, 'mask, P> Freeze for Paste<'img, 'mask, P>
impl<'img, 'mask, P> RefUnwindSafe for Paste<'img, 'mask, P>
impl<'img, 'mask, P> Send for Paste<'img, 'mask, P>
impl<'img, 'mask, P> Sync for Paste<'img, 'mask, P>
impl<'img, 'mask, P> Unpin for Paste<'img, 'mask, P>
impl<'img, 'mask, P> UnwindSafe for Paste<'img, 'mask, P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more