/** * Mask Renderer * * Paints CSS mask-image layers into a mask surface (alpha mask) which the * caller composites onto the element surface via `destination-in`. * * Value grammars are shared with background-image (position/size/repeat), so * the layer maths mirrors the background renderer but works in the local * coordinate space of the mask positioning area (default: border box) and * always fills the whole area — a mask surface is about alpha coverage, not * about what is visible underneath. * * Gradient layers share the rasterisation primitives of the background * renderer (gradient-rasterizer.ts): repeating gradients stack their stop * cycles, and the area beyond a radial gradient's ending shape keeps the * last stop's colour. Limitations (v1): mask-mode is alpha-only; layers * composite with source-over (≈ the spec-default `add`). */ import { ICSSImage } from '../../css/types/image'; import { LengthPercentage } from '../../css/types/length-percentage'; import { BACKGROUND_REPEAT } from '../../css/property-descriptors/background-repeat'; import { BackgroundSizeInfo } from '../../css/property-descriptors/background-size'; export interface MaskLayerStyles { maskPosition: LengthPercentage[][]; maskRepeat: BACKGROUND_REPEAT[]; maskSize: BackgroundSizeInfo[][]; } export interface MaskArea { left: number; top: number; width: number; height: number; } export type MaskImageSource = HTMLImageElement | HTMLCanvasElement; /** * Paint every mask layer into `ctx` (expected to already be scaled to device * pixels and translated so the page origin maps correctly). */ export declare const paintMaskLayers: (ctx: CanvasRenderingContext2D, layers: ICSSImage[], styles: MaskLayerStyles, area: MaskArea, matchImage: (url: string) => Promise) => Promise;