pub struct Mask { /* private fields */ }
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.
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.
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()
.