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