pub struct Mask {
data: Vec<u8>,
size: IntSize,
}
Expand description
A mask.
During drawing over Pixmap
, mask’s black (0) “pixels” would block rendering
and white (255) will allow it.
Anything in between is used for gradual masking and anti-aliasing.
Unlike Skia, we’re using just a simple 8bit alpha mask. It’s way slower, but easier to implement.
Fields§
§data: Vec<u8>
§size: IntSize
Implementations§
source§impl Mask
impl Mask
sourcepub fn new(width: u32, height: u32) -> Option<Self>
pub fn new(width: u32, height: u32) -> Option<Self>
Creates a new mask by taking ownership over a mask buffer.
The size needs to match the data provided.
sourcepub fn from_pixmap(pixmap: PixmapRef<'_>, mask_type: MaskType) -> Self
pub fn from_pixmap(pixmap: PixmapRef<'_>, mask_type: MaskType) -> Self
Creates a new mask from a PixmapRef
.
sourcepub fn from_vec(data: Vec<u8>, size: IntSize) -> Option<Self>
pub fn from_vec(data: Vec<u8>, size: IntSize) -> Option<Self>
Creates a new mask by taking ownership over a mask buffer.
The size needs to match the data provided.
pub(crate) fn as_submask(&self) -> SubMaskRef<'_>
pub(crate) fn submask(&self, rect: IntRect) -> Option<SubMaskRef<'_>>
pub(crate) fn as_subpixmap(&mut self) -> SubPixmapMut<'_>
pub(crate) fn subpixmap(&mut self, rect: IntRect) -> Option<SubPixmapMut<'_>>
sourcepub fn fill_path(
&mut self,
path: &Path,
fill_rule: FillRule,
anti_alias: bool,
transform: Transform,
)
pub fn fill_path( &mut self, path: &Path, fill_rule: FillRule, anti_alias: bool, transform: Transform, )
Draws a filled path onto the mask.
In terms of RGB (no alpha) image, draws a white path on top of black mask.
Doesn’t reset the existing mask content and draws the path on top of existing data.
If the above behavior is undesired, Mask::clear()
should be called first.
This method is intended to be used for simple cases. For more complex masks
prefer Mask::from_pixmap()
.
Trait Implementations§
impl StructuralPartialEq for Mask
Auto Trait Implementations§
impl Freeze for Mask
impl RefUnwindSafe for Mask
impl Send for Mask
impl Sync for Mask
impl Unpin for Mask
impl UnwindSafe for Mask
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)