UNPKG

@tsparticles/plugin-canvas-mask

Version:

tsParticles canvas mask plugin

34 lines (33 loc) 998 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CanvasMaskPixels = void 0; const engine_1 = require("@tsparticles/engine"); const minAlpha = 0; class CanvasMaskPixels { constructor() { this.filter = (pixel) => pixel.a > minAlpha; this.offset = 4; } load(data) { if ((0, engine_1.isNull)(data)) { return; } if (data.filter !== undefined) { if ((0, engine_1.isString)(data.filter)) { if (Object.hasOwn(window, data.filter)) { const filter = window[data.filter]; if ((0, engine_1.isFunction)(filter)) { this.filter = filter; } } } else { this.filter = data.filter; } } if (data.offset !== undefined) { this.offset = data.offset; } } } exports.CanvasMaskPixels = CanvasMaskPixels;