tsparticles
Version:
Easily create highly customizable particle animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.
61 lines (60 loc) • 1.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Plugins = void 0;
const plugins = [];
const presets = new Map();
const drawers = new Map();
const pathGenerators = new Map();
class Plugins {
static getPlugin(plugin) {
return plugins.find((t) => t.id === plugin);
}
static addPlugin(plugin) {
if (!Plugins.getPlugin(plugin.id)) {
plugins.push(plugin);
}
}
static getAvailablePlugins(container) {
const res = new Map();
for (const plugin of plugins) {
if (!plugin.needsPlugin(container.actualOptions)) {
continue;
}
res.set(plugin.id, plugin.getPlugin(container));
}
return res;
}
static loadOptions(options, sourceOptions) {
for (const plugin of plugins) {
plugin.loadOptions(options, sourceOptions);
}
}
static getPreset(preset) {
return presets.get(preset);
}
static addPreset(presetKey, options) {
if (!Plugins.getPreset(presetKey)) {
presets.set(presetKey, options);
}
}
static addShapeDrawer(type, drawer) {
if (!Plugins.getShapeDrawer(type)) {
drawers.set(type, drawer);
}
}
static getShapeDrawer(type) {
return drawers.get(type);
}
static getSupportedShapes() {
return drawers.keys();
}
static getPathGenerator(type) {
return pathGenerators.get(type);
}
static addPathGenerator(type, pathGenerator) {
if (!Plugins.getPathGenerator(type)) {
pathGenerators.set(type, pathGenerator);
}
}
}
exports.Plugins = Plugins;