import * as PIXI from "pixi.js"; import { z } from "zod"; /** * Strategies for fitting a clip against the display bounds. */ export declare enum FitToScreenEnum { INSIDE = "inside", OUTSIDE = "outside", STRETCH = "stretch" } /** * Serializable style state applied to a clip sprite. * * This object captures the baseline transform and crop state of a clip. Runtime animation offsets * are tracked separately and are not expected to be persisted here. */ export interface ClipStyleOptions { clipId: string; mediaDataId?: string; alpha?: number; rotation?: number; position?: [number, number]; scale?: [number, number]; crop?: [number, number, number, number]; cropOffset?: [number, number]; zoom?: [number, number]; zIndex?: number; width?: number; height?: number; cornerRadius?: [number, number, number, number]; relativeCornerRadius?: boolean; } /** * Zod schema describing the serialized clip style payload stored in project data. */ export declare const ClipStyleSchema: z.ZodObject<{ clipId: z.ZodString; mediaDataId: z.ZodOptional; alpha: z.ZodNumber; rotation: z.ZodNumber; position: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>; scale: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>; crop: z.ZodDefault>>; cropOffset: z.ZodDefault>>; zoom: z.ZodDefault>>; zIndex: z.ZodNumber; width: z.ZodOptional; height: z.ZodOptional; cornerRadius: z.ZodOptional>; relativeCornerRadius: z.ZodDefault>; }, "strip", z.ZodTypeAny, { scale: [number, number]; alpha: number; rotation: number; clipId: string; position: [number, number]; crop: [number, number, number, number]; cropOffset: [number, number]; zoom: [number, number]; zIndex: number; relativeCornerRadius: boolean; mediaDataId?: string | undefined; width?: number | undefined; height?: number | undefined; cornerRadius?: [number, number, number, number] | undefined; }, { scale: [number, number]; alpha: number; rotation: number; clipId: string; position: [number, number]; zIndex: number; mediaDataId?: string | undefined; crop?: [number, number, number, number] | undefined; cropOffset?: [number, number] | undefined; zoom?: [number, number] | undefined; width?: number | undefined; height?: number | undefined; cornerRadius?: [number, number, number, number] | undefined; relativeCornerRadius?: boolean | undefined; }>; /** * Stores transform, crop, sizing, and masking state for a clip sprite. */ export declare class ClipStyle { protected alpha: number; protected rotation: number; protected position: [number, number]; protected zIndex: number; protected width: number; protected height: number; protected scale: [number, number]; protected crop: [number, number, number, number]; protected cropOffset: [number, number]; protected zoom: [number, number]; protected cornerRadius: number[]; protected relativeCornerRadius: boolean; protected sprite: T | null; protected clipId: string; protected mediaDataId: string | undefined; protected mask: PIXI.Graphics | null; protected animationPositionOffset: [number, number]; protected animationScaleMultiplier: [number, number]; protected animationRotationOffset: number; protected animationAlphaMultiplier: number; protected animationCrop: [number, number, number, number]; protected animationCropOffset: [number, number]; protected animationZoom: [number, number]; private lastCornerRadius; private lastCornerSize; private lastCornerScale; private lastRelativeCornerRadius; private lastCrop; private lastCropOffset; private lastZoom; /** * Creates a style object for a clip sprite. * * @param options Initial style configuration. */ constructor(options: ClipStyleOptions); /** * Scales the clip to fit or cover the display area. * * @param fitStyle Strategy used to size the clip against the display. * @param center When `true`, centers the clip before fitting; otherwise fits relative to its current position. * @param margin Extra margin, in pixels, to include in the fit calculation. * @returns Nothing. */ fitToScreen(fitStyle: FitToScreenEnum, center?: boolean, margin?: number): void; /** * Moves the clip to the center of the display. * * @returns Nothing. */ positionToCenter(): void; /** * Scales the clip down uniformly so it fits inside the display while preserving aspect ratio. * * @returns Nothing. */ scaleDownToFit(): void; /** * Rebinds the style to a different media asset ID. * * @param mediaDataId Media asset ID associated with the clip. * @returns Nothing. */ replaceMediaDataId(mediaDataId: string): void; /** * Sets corner radii used to mask the clip into a rounded rectangle. * * @param radii Uniform radius or individual radii for each corner. * @param relative When `true`, corner radii are interpreted relative to the unclipped sprite size. * @returns Nothing. */ setCornerRadius(radii: number | [number, number, number, number], relative?: boolean): void; /** * Returns the configured corner radii. * * @returns The corner radii in top-left, top-right, bottom-right, bottom-left order. */ getCornerRadius(): number[]; /** * Indicates whether corner radii are stored in relative mode. * * @returns `true` if relative corner radii are enabled; otherwise `false`. */ getCornerRadiusRelative(): boolean; /** * Updates the owning clip ID tracked by the style. * * @param clipId Owning clip ID. * @returns Nothing. */ setClipId(clipId: string): void; /** * Returns the owning clip ID. * * @returns The owning clip ID. */ getClipId(): string; /** * Sets the clip scale multipliers. * * @param scaleX Horizontal scale multiplier. * @param scaleY Vertical scale multiplier. * @returns Nothing. */ setScale(scaleX: number, scaleY: number): void; /** * Returns the base clip scale multipliers. * * @returns The `[x, y]` scale pair. */ getScale(): [number, number]; /** * Sets runtime-only scale multipliers applied by clip animation. * * @param multiplierX Animated horizontal scale multiplier. * @param multiplierY Animated vertical scale multiplier. * @returns Nothing. */ setAnimationScaleMultiplier(multiplierX: number, multiplierY: number): void; /** * Returns the runtime animation scale multipliers. * * @returns The `[x, y]` animation scale multiplier pair. */ getAnimationScaleMultiplier(): [number, number]; setWidth(width: number): void; setHeight(height: number): void; setSize(width: number, height: number): void; getWidth(): number; getHeight(): number; getSize(): [number, number]; getRawWidth(): number; getRawHeight(): number; getRawSize(): [number, number]; setAlpha(alpha: number): void; getAlpha(): number; setAnimationAlphaMultiplier(alpha: number): void; getAnimationAlphaMultiplier(): number; /** * Sets runtime-only crop values applied by animation. * * @param left Animated crop from the left edge. * @param top Animated crop from the top edge. * @param right Animated crop from the right edge. * @param bottom Animated crop from the bottom edge. * @returns Nothing. */ setAnimationCrop(left: number, top: number, right: number, bottom: number): void; /** * Returns runtime-only crop values applied by animation. * * @returns The animated crop values in `[left, top, right, bottom]` order. */ getAnimationCrop(): [number, number, number, number]; /** * Sets runtime-only crop offset values applied by animation. * * @param x Horizontal crop offset in pixels. * @param y Vertical crop offset in pixels. * @returns Nothing. */ setAnimationCropOffset(x: number, y: number): void; getAnimationCropOffset(): [number, number]; /** * Sets runtime-only zoom multipliers applied by animation. * * @param x Horizontal zoom multiplier. * @param y Vertical zoom multiplier. * @returns Nothing. */ setAnimationZoom(x: number, y: number): void; getAnimationZoom(): [number, number]; setRotation(rotation: number): void; getRotation(): number; setAnimationRotationOffset(rotation: number): void; getAnimationRotationOffset(): number; setPosition(x: number, y: number): void; getPosition(): [number, number]; setAnimationPositionOffset(x: number, y: number): void; getAnimationPositionOffset(): [number, number]; setZIndex(zIndex: number): void; getZIndex(): number; private getSafeCropValues; /** * Sets the crop values for the clip's sprite. This will clip the original texture to the given coordinates. * If the sprite is not a video, gif or image, it will not be updated. * If the sprite has no texture, or the texture is not valid, it will not be updated. * If `updatePosition` is true, it will also update the position of the sprite, so that the cropped area will maintain it's visual position. * @param left The left coordinate of the crop area * @param top The top coordinate of the crop area * @param right The right coordinate of the crop area * @param bottom The bottom coordinate of the crop area * @param updatePosition If true, it will also update the position of the sprite, so that the middle of the cropped area is at the same position as the middle of the original texture. Default is true. */ setCrop(left: number, top: number, right: number, bottom: number, updatePosition?: boolean): void; /** * Returns the current crop values of the clip. * The returned array contains four numbers: [left, top, right, bottom] * @returns {number[]} The current crop values of the clip. */ getCrop(): number[]; /** * Sets the base zoom multipliers used when computing crop bounds. * * @param zoomX Horizontal zoom multiplier. * @param zoomY Vertical zoom multiplier. * @returns Nothing. */ setZoom(zoomX: number, zoomY: number): void; getZoom(): [number, number]; /** * Sets the base crop offset used when computing crop bounds. * * @param x Horizontal crop offset in pixels. * @param y Vertical crop offset in pixels. * @returns Nothing. */ setCropOffset(x: number, y: number): void; getCropOffset(): [number, number]; /** * Attaches a sprite instance to the style and applies the current style state to it. * * @param sprite Sprite to control. * @returns Nothing. */ load(sprite: T): void; /** * Clears cached derived values so the next update fully recomputes style-dependent sprite state. * * @returns Nothing. */ invalidateCache(): void; /** * Compute final crop pixel bounds given crop/zoom/offset values. * Returns [left, top, width, height] in original texture pixels. */ private computeCropBounds; /** * Applies the current style state to a sprite, including transforms, crop, and mask updates. * * @param sprite Sprite to update. * @returns Nothing. */ update(sprite: T): void; protected setCornerRadiusOnSprite(sprite: T): void; protected updateMask(sprite: T): void; protected emitUpdateEvent(property: string, value: unknown): boolean; /** * Releases any style-owned runtime mask resources. * * @returns Nothing. */ destroy(): void; /** * Serializes the clip style into a project-safe payload. * * @returns The serialized style payload. */ serialize(): { scale: [number, number]; alpha: number; rotation: number; clipId: string; position: [number, number]; crop: [number, number, number, number]; cropOffset: [number, number]; zoom: [number, number]; zIndex: number; relativeCornerRadius: boolean; mediaDataId?: string | undefined; width?: number | undefined; height?: number | undefined; cornerRadius?: [number, number, number, number] | undefined; }; /** * Creates a clip style instance from serialized data. * * @param payload Serialized style payload. * @returns The deserialized clip style. */ static deserialize(payload: object): ClipStyle; }