Struct Paste

Source
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>

Source

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).

Source

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.

Source

pub fn with_mask(self, mask: &'mask Image<BitPixel>) -> Self

Sets the mask image to use. Currently this is only limited to BitPixel images.

This must have the same dimensions as the base foreground image! You will receive a panic if this is not the case.

§Panics
  • The mask image has different dimensions than the foreground image.
Source

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.

Source

pub const fn with_overlay_mode(self, mode: OverlayMode) -> Self

Sets the overlay mode of the image.

Trait Implementations§

Source§

impl<'img, 'mask, P: Clone + Pixel> Clone for Paste<'img, 'mask, P>

Source§

fn clone(&self) -> Paste<'img, 'mask, P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'img, 'mask, P: Pixel> Draw<P> for Paste<'img, 'mask, P>

Source§

fn draw<I: DerefMut<Target = Image<P>>>(&self, image: I)

Draws the object to the given image.

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>
where P: Sync, <P as Pixel>::Color: Sync,

§

impl<'img, 'mask, P> Sync for Paste<'img, 'mask, P>
where P: Sync, <P as Pixel>::Color: Sync,

§

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> 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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.