UNPKG

tav-media

Version:

Cross platform media editing framework

119 lines (118 loc) 4.99 kB
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; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { tav } from '../tav'; import { allowCallNativeAnytime } from '../types/tav-object'; import { Matrix } from '../types/types'; import { Effect } from './tav-effect'; /** * Effect to transform video frame with specified bezier curve. * @category Effects */ export class TransformEffect extends Effect { constructor() { super(...arguments); this.type = 'TransformEffect'; this._transform2D = {}; } static MakeTransformEffect() { const transformEffect = new TransformEffect(); return transformEffect; } clone() { const newColorTuningEffect = new TransformEffect(); const _a = this, { _nativeObject: _nativeClip, parent, id, nativeInvalidated } = _a, otherProperties = __rest(_a, ["_nativeObject", "parent", "id", "nativeInvalidated"]); return Object.assign(newColorTuningEffect, otherProperties); } /** * Get the real time matrix applied on the input. * @returns The current matrix applied on the input. */ getCurrentMatrix() { const matrix = new Matrix(); if (!this._nativeObject) { console.warn(`Transform effect ${this.id} has not built yet, please get its current matrix after built!`); return matrix; } const tavMatrix = this._nativeObject.getCurrentMatrix(); matrix.setNativeMatrix(tavMatrix); return matrix; } /** * Get the current opacity applied on the input. * @returns The current opacity applied on the input. */ getCurrentOpacity() { if (!this._nativeObject) { console.warn(`Transform effect ${this.id} has not built yet, please get its current opacity after built!`); return 1; } return this._nativeObject.getCurrentOpacity(); } createClip() { return __awaiter(this, void 0, void 0, function* () { const transformEffect = tav.TransformEffect.MakeTransformEffect(this.transform2D); return transformEffect; }); } updateClip(effect) { const _super = Object.create(null, { updateClip: { get: () => super.updateClip } }); return __awaiter(this, void 0, void 0, function* () { yield _super.updateClip.call(this, effect); }); } updateTransform() { if (this.nativeClip) { if (tav.webAssemblyQueue.exec) { tav.webAssemblyQueue.exec(tav.TransformEffect.updateTransform, tav.TransformEffect, this.nativeClip, this.transform2D); } else { tav.TransformEffect.updateTransform(this.nativeClip, this.transform2D); } } } /** * Get or set the transform data with a Transform2D object. */ get transform2D() { return this._transform2D; } set transform2D(transform2D) { this._transform2D = transform2D; this.updateTransform(); } } __decorate([ allowCallNativeAnytime ], TransformEffect.prototype, "getCurrentMatrix", null); __decorate([ allowCallNativeAnytime ], TransformEffect.prototype, "getCurrentOpacity", null); __decorate([ allowCallNativeAnytime ], TransformEffect.prototype, "transform2D", null);