Skip to content
apply_mask

apply_mask

Mojo function 🡭

apply_mask

fn def apply_mask(canvas: Canvas, mask: Mask) -> Canvas

A copy of canvas with every pixel’s alpha scaled by the mask’s coverage at the same position; pixels the mask does not reach become transparent. Color channels are untouched.

Args:

  • canvas (Canvas): Canvas to copy. Unchanged.
  • mask (Mask): Coverage aligned with the canvas’s top-left corner.

Returns:

Canvas: The masked copy, the same size as canvas.