@tsparticles/plugin-polygon-mask
Version:
tsParticles polygon mask plugin
66 lines (65 loc) • 2.71 kB
JavaScript
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "@tsparticles/engine", "./PolygonMaskDraw.js", "./PolygonMaskInline.js", "./PolygonMaskLocalSvg.js", "./PolygonMaskMove.js", "../../Enums/PolygonMaskType.js"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PolygonMask = void 0;
const engine_1 = require("@tsparticles/engine");
const PolygonMaskDraw_js_1 = require("./PolygonMaskDraw.js");
const PolygonMaskInline_js_1 = require("./PolygonMaskInline.js");
const PolygonMaskLocalSvg_js_1 = require("./PolygonMaskLocalSvg.js");
const PolygonMaskMove_js_1 = require("./PolygonMaskMove.js");
const PolygonMaskType_js_1 = require("../../Enums/PolygonMaskType.js");
class PolygonMask {
constructor(engine) {
this.draw = new PolygonMaskDraw_js_1.PolygonMaskDraw(engine);
this.enable = false;
this.inline = new PolygonMaskInline_js_1.PolygonMaskInline();
this.move = new PolygonMaskMove_js_1.PolygonMaskMove();
this.scale = 1;
this.type = PolygonMaskType_js_1.PolygonMaskType.none;
}
load(data) {
if ((0, engine_1.isNull)(data)) {
return;
}
this.draw.load(data.draw);
this.inline.load(data.inline);
this.move.load(data.move);
if (data.scale !== undefined) {
this.scale = data.scale;
}
if (data.type !== undefined) {
this.type = data.type;
}
if (data.enable !== undefined) {
this.enable = data.enable;
}
else {
this.enable = this.type !== PolygonMaskType_js_1.PolygonMaskType.none;
}
if (data.url !== undefined) {
this.url = data.url;
}
if (data.data !== undefined) {
if ((0, engine_1.isString)(data.data)) {
this.data = data.data;
}
else {
this.data = new PolygonMaskLocalSvg_js_1.PolygonMaskLocalSvg();
this.data.load(data.data);
}
}
if (data.position !== undefined) {
this.position = (0, engine_1.deepExtend)({}, data.position);
}
}
}
exports.PolygonMask = PolygonMask;
});