@diffusionstudio/core-v4
Version:
2D motion graphics and video rendering engine
192 lines (191 loc) • 6.46 kB
TypeScript
import { Serializer } from '../../services';
import { Constructor, Percent, Size } from '../../types';
import { BlendMode, Point, RelativePoint } from '../../renderer';
import { Mask } from '../../masks';
import { Timestamp } from '../../models';
import { ClipAnimationOptions } from '../clip';
import { Constraints } from './interfaces';
interface VisualBase extends Serializer {
animations: ClipAnimationOptions;
start: Timestamp;
stop: Timestamp;
}
export declare function VisualMixin<T extends Constructor<VisualBase>>(Base: T): {
new (...args: any[]): {
source?: {
height: number;
width: number;
aspectRatio: number;
};
_position: {
x: number;
y: number;
};
_layoutCache: Size;
/**
* Defines the height adjusted by the constraints
*/
_height?: number;
/**
* Defines the width adjusted by the constraints
*/
_width?: number;
_aspectRatio?: number;
_keepAspectRatio: boolean;
_mask?: Mask;
/**
* The resizing behavior of a clip when its parent container is resized.
* @default { horizontal: 'MIN', vertical: 'MIN' }
*/
constraints: Constraints;
/**
* The anchor x position, proxy for the anchor.x property
* @default 0
*/
anchorX: number;
/**
* The anchor y position, proxy for the anchor.y property
* @default 0
*/
anchorY: number;
/**
* The scale x factor
* @default 1
*/
scaleX: number;
/**
* The scale y factor
* @default 1
*/
scaleY: number;
/**
* The translate x factor
* @default 0
*/
translateX: number;
/**
* The translate y factor
* @default 0
*/
translateY: number;
/**
* Defines the rotation of the clip in degrees
* @default 0
* @example 90
*/
rotation: number;
/**
* Defines the opacity of the clip as a number
* between 0 and 1
* @default 100
*/
opacity: number;
/**
* Defines the filter property of the Canvas 2D API. It provides
* filter effects such as blurring and grayscaling.
* It is similar to the CSS filter property and accepts the same values.
* https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter
*/
filter?: string;
/**
* Sets the type of compositing operation to apply when drawing new shapes.
* https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
* @default 'source-over'
*/
blendMode?: BlendMode;
/**
* The position of the clip on the x axis.
* @default 0
*/
get x(): number;
set x(value: number | Percent);
/**
* The position of the clip on the y axis.
* @default 0
*/
get y(): number;
set y(value: number | Percent);
/**
* 2D position offset of the clip.
* @default { x: 0, y: 0 }
*/
get translate(): Point;
set translate(value: Point | number);
/**
* The anchor sets the origin point of the clip. Setting the anchor to (0.5,0.5)
* means the clips' origin is centered. Setting the anchor to (1,1) would mean
* the clips' origin point will be the bottom right corner. If you pass only
* single parameter, it will set both x and y to the same value.
*/
get anchor(): Point;
set anchor(value: Point | number);
/**
* The scale factors of this object along the local coordinate axes.
* Will be added to the scale applied by setting height and/or width
* @default { x: 1, y: 1 }
*/
get scale(): Point;
set scale(value: Point | number);
/**
* Defines a region of the clip to be masked.
*/
mask: Mask | undefined;
/**
* If true, the clip will keep the aspect ratio.
* Will be set to false if both height and width are set.
* @default true
*/
keepAspectRatio: boolean;
/**
* Gets the effective aspect ratio, using custom ratio if set, otherwise falling back to source
*/
get aspectRatio(): number;
/**
* Sets a custom aspect ratio that overrides the source aspect ratio when free transform is enabled
*/
set aspectRatio(value: number | undefined);
/**
* Gets the current height of the clip
*/
get height(): number;
set height(value: Percent | number | undefined);
/**
* Gets the current width of the clip
*/
get width(): number;
set width(value: Percent | number | undefined);
/**
* The coordinate of the object relative to the local coordinates of the parent.
* @default { x: 0, y: 0 }
*/
get position(): Point;
set position(value: RelativePoint | "center");
animate(time: Timestamp): /*elided*/ any;
layout(next: Size): void;
/**
* Gets the size of the clip in absolute units
*/
readonly size: Size;
/**
* Calculates the absolute coordinates of the shape's corners, taking into account
* position, anchor point, translation, scale, and rotation and scale.
* @returns Object containing the coordinates of all four corners
*/
readonly bounds: [Point, Point, Point, Point];
animations: ClipAnimationOptions;
start: Timestamp;
stop: Timestamp;
toJSON(exclude?: string[]): unknown;
fromJSON<K = {}>(obj: K extends string ? never : K): /*elided*/ any;
};
readonly VISUAL_MIXIN: symbol;
} & T;
/**
* Check if an object's class has been wrapped with VisualMixin
*/
export declare function hasVisualMixin(obj: any): boolean;
/**
* Type guard to check if an object has VisualMixin capabilities
*/
export declare function isVisualMixinInstance(obj: any): obj is InstanceType<ReturnType<typeof VisualMixin>>;
export {};