import { Ellipse } from "../../geometries/ellipse.ts"; import { Polygon } from "../../geometries/polygon.ts"; import type { Color } from "../../math/color.ts"; import type Tween from "../../tweens/tween.ts"; import type Renderer from "../../video/renderer.js"; import type Camera2d from "../camera2d.ts"; import CameraEffect from "./camera_effect.ts"; type MaskShape = Ellipse | Polygon; /** * A camera effect that performs a mask-based scene transition. * A shape (ellipse, polygon) is scaled from full-screen to zero (hide) * or from zero to full-screen (reveal), with the area outside the shape * filled with a solid color. * @category Camera * @example * // iris transition (circle shrinks to hide the scene) * camera.addCameraEffect(new MaskEffect(camera, { * shape: new Ellipse(0, 0, 1, 1), * color: "#000", * duration: 500, * direction: "hide", * })); * @example * // diamond reveal transition * camera.addCameraEffect(new MaskEffect(camera, { * shape: new Polygon(0, 0, [ * { x: 0, y: -1 }, { x: 1, y: 0 }, * { x: 0, y: 1 }, { x: -1, y: 0 }, * ]), * color: "#000", * duration: 500, * direction: "reveal", * })); */ export default class MaskEffect extends CameraEffect { /** * the transition fill color */ color: Color; /** * the mask shape template (unit-sized, centered at origin) */ shape: MaskShape; /** * current progress value (0 = fully covered, 1 = fully visible) */ progress: { value: number; }; /** * the tween controlling progress */ tween: Tween; /** * transition direction */ direction: "hide" | "reveal"; /** * optional callback when transition completes */ onComplete: (() => void) | undefined; /** * pooled shape used for rendering (avoids per-frame allocation) * @ignore */ _maskShape: MaskShape; /** * @param camera - the camera to apply the transition to * @param options - transition parameters * @param options.shape - an Ellipse or Polygon (unit-sized, centered at origin) defining the mask shape * @param options.color - CSS color value or Color instance for the transition fill * @param [options.duration=500] - transition duration in milliseconds * @param [options.direction="hide"] - "hide" shrinks the visible area, "reveal" grows it * @param [options.onComplete] - callback when the transition finishes */ constructor(camera: Camera2d, options: { shape: MaskShape; color: Color | string; duration?: number | undefined; direction?: "hide" | "reveal" | undefined; onComplete?: (() => void) | undefined; }); update(): void; draw(renderer: Renderer, width: number, height: number): void; destroy(): void; } export {}; //# sourceMappingURL=mask_effect.d.ts.map