Skip to main content

MaskedDrawable

Trait MaskedDrawable 

Source
pub trait MaskedDrawable<const W: usize, const H: usize>: Drawable<Output = ()> {
    // Required method
    fn draw_masked<const MASK_N: usize, D>(
        &self,
        mask: &MaskFixed<W, H, MASK_N>,
        target: &mut D,
    ) -> Result<(), D::Error>
       where D: DrawTarget<Color = Self::Color>;
}
Expand description

Draws a fixed RGB565 image through a matching binary mask.

This image-specific counterpart to Drawable is implemented for both an Image565Fixed and the positioned value returned by Image565Fixed::at. The W and H const arguments require the image and MaskFixed dimensions to match at compile time. It is intentionally not implemented for arbitrary Drawable types, whose pixels might not correspond to a fixed, row-major mask.

Import this trait to make draw_masked available. See the visual MaskFixed example, which draws an opaque image beside its positioned, masked result.

Required Methods§

Source

fn draw_masked<const MASK_N: usize, D>( &self, mask: &MaskFixed<W, H, MASK_N>, target: &mut D, ) -> Result<(), D::Error>
where D: DrawTarget<Color = Self::Color>,

Draws the image, skipping pixels whose corresponding mask bits are clear.

An Image565Fixed draws at (0, 0). The value returned by Image565Fixed::at draws at the supplied position. See the visual MaskFixed example for the masked output.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<const W: usize, const H: usize, const N: usize> MaskedDrawable<W, H> for Image565Fixed<W, H, N>