pub struct MaskFixed<const W: usize, const H: usize, const MASK_N: usize> {
pub bits: [u8; MASK_N],
}Expand description
A packed binary visibility mask with one bit per image pixel.
Set bits are drawn and clear bits are transparent. Create a mask from an
Image888Fixed with Image888Fixed::to_mask_magenta, then pass it to
MaskedDrawable::draw_masked.
§Example
use device_envoy_core::{
UnwrapInfallible,
cyd::{
Cyd, CydDisplay,
display::{
CydFrame, Image565Fixed, Image888Fixed, MaskFixed, MaskedDrawable,
mask_byte_count, tga,
},
},
};
use embedded_graphics::{Drawable, prelude::Point};
const SOURCE: Image888Fixed<45, 73, { 45 * 73 }> = tga!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/docs/assets/cyd_fill_contiguous.tga"
));
const IMAGE: Image565Fixed<45, 73, { 45 * 73 }> = SOURCE.to_565();
const MASK: MaskFixed<45, 73, { mask_byte_count(45, 73) }> =
SOURCE.to_mask_magenta();
async fn draw<C: Cyd>(cyd: &mut C) -> Result<(), C::Error> {
let display = cyd.display();
let mut frame = display.full_frame_mut();
IMAGE
.at(Point::new(80, 84))
.draw(&mut frame)
.unwrap_infallible();
IMAGE
.at(Point::new(200, 84))
.draw_masked(&MASK, &mut frame)
.unwrap_infallible();
frame.flush().await
}
assert!(!MASK.is_set(0));The opaque RGB565 image is on the left. The masked drawing on the right skips the magenta background:
Fields§
§bits: [u8; MASK_N]Row-major visibility bits, least-significant bit first within each byte.
Implementations§
Auto Trait Implementations§
impl<const W: usize, const H: usize, const MASK_N: usize> Freeze for MaskFixed<W, H, MASK_N>
impl<const W: usize, const H: usize, const MASK_N: usize> RefUnwindSafe for MaskFixed<W, H, MASK_N>
impl<const W: usize, const H: usize, const MASK_N: usize> Send for MaskFixed<W, H, MASK_N>
impl<const W: usize, const H: usize, const MASK_N: usize> Sync for MaskFixed<W, H, MASK_N>
impl<const W: usize, const H: usize, const MASK_N: usize> Unpin for MaskFixed<W, H, MASK_N>
impl<const W: usize, const H: usize, const MASK_N: usize> UnsafeUnpin for MaskFixed<W, H, MASK_N>
impl<const W: usize, const H: usize, const MASK_N: usize> UnwindSafe for MaskFixed<W, H, MASK_N>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Casts the value.
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<S, T> Upcast<T> for S
impl<S, T> Upcast<T> for S
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.