tav-media
Version:
Cross platform media editing framework
244 lines (243 loc) • 7.41 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { PAGComposition } from './pag-composition';
import { destroyVerify, wasmAwaitRewind } from './utils/decorators';
import { Matrix } from './core/matrix';
import { layer2typeLayer, proxyVector } from './utils/type-utils';
let PAGLayer = class PAGLayer {
constructor(wasmIns) {
this.wasmIns = wasmIns;
}
/**
* Returns a globally unique id for this object.
*/
uniqueID() {
return this.wasmIns._uniqueID();
}
/**
* Returns the type of layer.
*/
layerType() {
return this.wasmIns._layerType();
}
/**
* Returns the name of the layer.
*/
layerName() {
return this.wasmIns._layerName();
}
/**
* A matrix object containing values that alter the scaling, rotation, and translation of the
* layer. Altering it does not change the animation matrix, and it will be concatenated to current
* animation matrix for displaying.
*/
matrix() {
const wasmIns = this.wasmIns._matrix();
if (!wasmIns)
throw new Error('Get matrix fail!');
return new Matrix(wasmIns);
}
setMatrix(matrix) {
this.wasmIns._setMatrix(matrix.wasmIns);
}
/**
* Resets the matrix to its default value.
*/
resetMatrix() {
this.wasmIns._resetMatrix();
}
/**
* The final matrix for displaying, it is the combination of the matrix property and current
* matrix from animation.
*/
getTotalMatrix() {
const wasmIns = this.wasmIns._getTotalMatrix();
if (!wasmIns)
throw new Error('Get total matrix fail!');
return new Matrix(this.wasmIns._getTotalMatrix());
}
/**
* Returns the current alpha of the layer if previously set.
*/
alpha() {
return this.wasmIns._alpha();
}
/**
* Set the alpha of the layer, which will be concatenated to the current animation opacity for
* displaying.
*/
setAlpha(opacity) {
this.wasmIns._setAlpha(opacity);
}
/**
* Whether or not the layer is visible.
*/
visible() {
return this.wasmIns._visible();
}
/**
* Set the visible of the layer.
*/
setVisible(visible) {
this.wasmIns._setVisible(visible);
}
/**
* Ranges from 0 to PAGFile.numTexts - 1 if the layer type is text, or from 0 to PAGFile.numImages
* -1 if the layer type is image, otherwise returns -1.
*/
editableIndex() {
return this.wasmIns._editableIndex();
}
/**
* Returns the parent PAGComposition of current PAGLayer.
*/
parent() {
const wasmIns = this.wasmIns._parent();
if (!wasmIns)
throw new Error('Get total matrix fail!');
return new PAGComposition(wasmIns);
}
/**
* Returns the markers of this layer.
*/
markers() {
const wasmIns = this.wasmIns._markers();
if (!wasmIns)
throw new Error('Get markers fail!');
return proxyVector(wasmIns, (wasmIns) => wasmIns);
}
/**
* Converts the time from the PAGLayer's (local) timeline to the PAGSurface (global) timeline. The
* time is in microseconds.
*/
localTimeToGlobal(localTime) {
return this.wasmIns._localTimeToGlobal(localTime);
}
/**
* Converts the time from the PAGSurface (global) to the PAGLayer's (local) timeline timeline. The
* time is in microseconds.
*/
globalToLocalTime(globalTime) {
return this.wasmIns._globalToLocalTime(globalTime);
}
/**
* The duration of the layer in microseconds, indicates the length of the visible range.
*/
duration() {
return this.wasmIns._duration();
}
/**
* Returns the frame rate of this layer.
*/
frameRate() {
return this.wasmIns._frameRate();
}
/**
* The start time of the layer in microseconds, indicates the start position of the visible range
* in parent composition. It could be negative value.
*/
startTime() {
return this.wasmIns._startTime();
}
/**
* Set the start time of the layer, in microseconds.
*/
setStartTime(time) {
this.wasmIns._setStartTime(time);
}
/**
* The current time of the layer in microseconds, the layer is invisible if currentTime is not in
* the visible range (startTime <= currentTime < startTime + duration).
*/
currentTime() {
return this.wasmIns._currentTime();
}
/**
* Set the current time of the layer, in microseconds.
*/
setCurrentTime(time) {
this.wasmIns._setCurrentTime(time);
}
/**
* Returns the current progress of play position, the value ranges from 0.0 to 1.0.
*/
getProgress() {
return this.wasmIns._getProgress();
}
/**
* Set the progress of play position, the value ranges from 0.0 to 1.0. A value of 0.0 represents
* the frame at startTime. A value of 1.0 represents the frame at the end of duration.
*/
setProgress(percent) {
this.wasmIns._setProgress(percent);
}
/**
* Set the progress of play position to the previous frame.
*/
preFrame() {
this.wasmIns._preFrame();
}
/**
* Set the progress of play position to the next frame.
*/
nextFrame() {
this.wasmIns._nextFrame();
}
/**
* Returns a rectangle that defines the original area of the layer, which is not transformed by
* the matrix.
*/
getBounds() {
return this.wasmIns._getBounds();
}
/**
* Returns trackMatte layer of this layer.
*/
trackMatteLayer() {
const wasmIns = this.wasmIns._trackMatteLayer();
if (!wasmIns)
throw new Error('Get track matte layer fail!');
return layer2typeLayer(wasmIns);
}
/**
* Indicate whether this layer is excluded from parent's timeline. If set to true, this layer's
* current time will not change when parent's current time changes.
*/
excludedFromTimeline() {
return this.wasmIns._excludedFromTimeline();
}
/**
* Set the excludedFromTimeline flag of this layer.
*/
setExcludedFromTimeline(value) {
this.wasmIns._setExcludedFromTimeline(value);
}
/**
* Returns true if this layer is a PAGFile.
*/
isPAGFile() {
return this.wasmIns._isPAGFile();
}
/**
* Returns this layer as a type layer.
*/
asTypeLayer() {
return layer2typeLayer(this);
}
isDelete() {
return this.wasmIns.isDelete();
}
destroy() {
this.wasmIns.delete();
this.isDestroyed = true;
}
};
PAGLayer = __decorate([
destroyVerify,
wasmAwaitRewind
], PAGLayer);
export { PAGLayer };