tav-media
Version:
Cross platform media editing framework
365 lines (364 loc) • 8.78 kB
TypeScript
import { tav } from '../tav';
import { Matrix } from './matrix';
export { Matrix } from './matrix';
/**
* Defines how to calculate the value between two keyframes.
* @category Animation
*/
export declare const enum KeyframeInterpolationType {
/**
* Linear interpolation.
*/
Linear = 1,
/**
* Bezier curve interpolation.
*/
Bezier = 2,
/**
* Use the value of the previous keyframe.
*/
Hold = 3
}
/**
* Defines the type of the Property.
* @category Animation
*/
export declare const enum PropertyType {
Property = 0,
Animatable = 1
}
/**
* Defines the type of the VolumeEffect.
* @category Effects
*/
export declare const enum VolumeEffectType {
FIFOEffect = 0,
VolumeEffect = 1
}
/**
* Defines a keyframe.
* @category Animation
*/
export interface Keyframe {
/**
* The start time of the keyframe.
*/
startTime: number;
/**
* The initial value of the keyframe.
*/
startValue: number;
/**
* The end time of the keyframe.
*/
endTime: number;
/**
* The final value of the keyframe.
*/
endValue: number;
/**
* The 'in' params of the bezier curve.
* Used only when interpolationType is Bezier.
*/
bezierIn?: [number, number];
/**
* The 'out' params of the bezier curve.
* Used only when interpolationType is Bezier.
*/
bezierOut?: [number, number];
/**
* The interpolation type of the keyframe.
*/
interpolationType: KeyframeInterpolationType;
}
export declare type NoBlankArray<T> = [T, ...T[]];
/**
* Defines a fade-in and fade-out effect.
* @category Effects
*/
export interface FIFOEffect {
effectType: VolumeEffectType.FIFOEffect;
maxVolume: number;
fadeInDuration: number;
fadeOutDuration: number;
}
/**
* Defines keyframe-based volume effect.
* @category Effects
*/
export interface VolumeEffect {
effectType: VolumeEffectType.VolumeEffect;
volumeRampList: NoBlankArray<Keyframe>;
}
/**
* Defines how to update the matrix or the opacity of a clip.
* @category Effects
*/
export interface Transform2D {
/**
* Defines how to update the anchorPointX.
*/
anchorPointX?: Property;
/**
* Defines how to update the anchorPointY.
*/
anchorPointY?: Property;
/**
* Defines how to update the position in X axis.
*/
translationX?: Property;
/**
* Defines how to update the position in Y axis.
*/
translationY?: Property;
/**
* Defines how to update the scale in X axis.
*/
scaleX?: Property;
/**
* Defines how to update the scale in Y axis.
*/
scaleY?: Property;
/**
* Defines how to update the rotation in Degrees.
*/
rotation?: Property;
/**
* Defines how to update the opacity. The value should be between 0 and 1.
*/
opacity?: Property;
}
/**
* Defines a color with RGBA.
* @category Basic
*/
export interface Color {
/**
* The red value of the color. The value should be between 0 and 255.
*/
red: number;
/**
* The green value of the color. The value should be between 0 and 255.
*/
green: number;
/**
* The blue value of the color. The value should be between 0 and 255.
*/
blue: number;
/**
* The alpha value of the color. The value should be between 0 and 255.
*/
alpha: number;
}
/**
* Describe chroma matting configuration.
* @category Effects
*/
export interface ChromaMattingConfig {
/**
* Expand the color range.
* * The value should be between 0 and 1.
*/
intensity: number;
/**
* Add shadow to the edge.
* * The value should be between 0 and 1.
*/
shadow: number;
/**
* The color to be removed.
*/
selectedColor: Color;
}
/**
* Describe how to update the color of a clip.
* * Use a Property to set one option to a fixed value.
* * Use a AnimatableProperty to set one option to a keyframe-based animation.
* @category Effects
*/
export interface ColorTuning {
/**
* Color temperature (色温 in chinese). The value should be between -50 and 50.
*/
kelvin?: Property;
/**
* Hue (色调 in chinese). The value should be between -50 and 50.
*/
hue?: Property;
/**
* Saturation (饱和度 in chinese). The value should be between -50 and 50.
*/
saturation?: Property;
/**
* Brightness (亮度 in chinese). The value should be between -50 and 50.
*/
brightness?: Property;
/**
* Contrast (对比度 in chinese). The value should be between -50 and 50.
*/
contrast?: Property;
/**
* Exposure (曝光 in chinese). The value should be between -50 and 50.
*/
exposure?: Property;
/**
* Gamma (褪色 in chinese). The value should be between -50 and 50.
*/
gamma?: Property;
}
/**
* Defines a property. The value of the property may change over time.
* @category Animation
*/
export interface Property {
/**
* The type of the property.
*/
type: PropertyType;
/**
* The initial value of the property.
*/
value?: number;
}
/**
* Defines a keyframe based animatable property.
* @category Animation
*/
export interface AnimatableProperty extends Property {
/**
* Keyframes of the property.
* * The keyframes should have at least one frame.
*/
keyframes?: NoBlankArray<Keyframe>;
}
/**
* Describes how to scale the content to fit the specified area.
* @category Engine
*/
export declare const enum ScaleMode {
/**
* The content is not scaled.
*/
None = 0,
/**
* The content is stretched to fit.
*/
Stretch = 1,
/**
* The content is scaled with respect to the original unscaled image's aspect ratio.
* This is the default value.
*/
LetterBox = 2,
/**
* The content is scaled to fit with respect to the original unscaled image's aspect ratio.
* This results in cropping on one axis.
*/
Zoom = 3
}
/**
* Describes how to interpret the alpha component of a pixel.
* @category Engine
*/
export declare const enum AlphaType {
/**
* uninitialized.
*/
Unknown = 0,
/**
* pixel is opaque.
*/
Opaque = 1,
/**
* pixel components are premultiplied by alpha.
*/
Premultiplied = 2,
/**
* pixel components are independent of alpha.
*/
Unpremultiplied = 3
}
/**
* Describes how pixel bits encode color. These values match up with the enum in Bitmap.Config on
* Android platform.
* @category Engine
*/
export declare const enum ColorType {
/**
* uninitialized.
*/
Unknown = 0,
/**
* Each pixel is stored as a single translucency (alpha) channel. This is very useful to
* efficiently store masks for instance. No color information is stored. With this configuration,
* each pixel requires 1 byte of memory.
*/
ALPHA_8 = 1,
/**
* Each pixel is stored on 4 bytes. Each channel (RGB and alpha for translucency) is stored with 8
* bits of precision (256 possible values). The channel order is: red, green, blue, alpha.
*/
RGBA_8888 = 2,
/**
* Each pixel is stored on 4 bytes. Each channel (RGB and alpha for translucency) is stored with 8
* bits of precision (256 possible values). The channel order is: blue, green, red, alpha.
*/
BGRA_8888 = 3
}
export interface Point {
x: number;
y: number;
}
/**
* Replace a image layer at editableIndex with another image.
* @category Effects
* @category Clips
*/
export interface PAGImageReplacement {
/**
* The index of the editable image data in the PAG file.
*/
editableIndex: number;
/**
* The path of the image file.
*/
imagePath: string;
/**
* The scale mode used to scale the image to fit the layer.
*/
scaleMode: ScaleMode;
}
/**
* Replace the color of the specified layer index.
* @category Effects
* @category Clips
*/
export interface PAGColorReplacement {
/**
* The index of the layer in the PAG file.
*/
layerIndex: number;
/**
* The color to replace the editable color.
*/
backgroundColor: Color;
}
/**
* Replace a image layer at editableIndex with clip at the inputIndex.
* @category Effects
* @category Clips
*/
export interface ClipReplacement {
editableIndex: number;
inputIndex: number;
scaleMode: ScaleMode;
matrix?: Matrix;
}
/**
* Replace the text of the specified layer index.
* @category Effects
* @category Clips
*/
export interface PAGTextReplacement {
editableIndex: number;
content: string | tav.TAVTextAttribute;
}