Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tsparticles/updater-roll

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsparticles/updater-roll - npm Package Compare versions

Comparing version 3.0.0-alpha.1 to 3.0.0-beta.0

browser/Types.js

4

browser/index.js
import { RollUpdater } from "./RollUpdater";
export async function loadRollUpdater(engine) {
await engine.addParticleUpdater("roll", () => new RollUpdater());
export async function loadRollUpdater(engine, refresh = true) {
await engine.addParticleUpdater("roll", () => new RollUpdater(), refresh);
}

@@ -1,2 +0,2 @@

import { OptionsColor, setRangeValue } from "@tsparticles/engine";
import { OptionsColor, setRangeValue, } from "@tsparticles/engine";
import { RollLight } from "./RollLight";

@@ -3,0 +3,0 @@ export class Roll {

@@ -1,18 +0,6 @@

import { getRandom, getRangeValue, rangeColorToHsl } from "@tsparticles/engine";
import { initParticle, updateRoll } from "./Utils";
import { Roll } from "./Options/Classes/Roll";
function updateRoll(particle, delta) {
const roll = particle.options.roll;
if (!particle.roll || !(roll === null || roll === void 0 ? void 0 : roll.enable)) {
return;
}
const speed = particle.roll.speed * delta.factor, max = 2 * Math.PI;
particle.roll.angle += speed;
if (particle.roll.angle > max) {
particle.roll.angle -= max;
}
}
export class RollUpdater {
getTransformValues(particle) {
var _a;
const roll = ((_a = particle.roll) === null || _a === void 0 ? void 0 : _a.enable) && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
const roll = particle.roll?.enable && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
return {

@@ -24,47 +12,7 @@ a: rollHorizontal ? Math.cos(roll.angle) : undefined,

init(particle) {
const rollOpt = particle.options.roll;
if (rollOpt === null || rollOpt === void 0 ? void 0 : rollOpt.enable) {
particle.roll = {
enable: rollOpt.enable,
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
angle: getRandom() * Math.PI * 2,
speed: getRangeValue(rollOpt.speed) / 360,
};
if (rollOpt.backColor) {
particle.backColor = rangeColorToHsl(rollOpt.backColor);
}
else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
const alterType = getRandom() >= 0.5 ? "darken" : "enlighten";
particle.roll.alter = {
type: alterType,
value: getRangeValue(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value),
};
}
else if (rollOpt.darken.enable) {
particle.roll.alter = {
type: "darken",
value: getRangeValue(rollOpt.darken.value),
};
}
else if (rollOpt.enlighten.enable) {
particle.roll.alter = {
type: "enlighten",
value: getRangeValue(rollOpt.enlighten.value),
};
}
}
else {
particle.roll = {
enable: false,
horizontal: false,
vertical: false,
angle: 0,
speed: 0,
};
}
initParticle(particle);
}
isEnabled(particle) {
const roll = particle.options.roll;
return !particle.destroyed && !particle.spawning && !!(roll === null || roll === void 0 ? void 0 : roll.enable);
return !particle.destroyed && !particle.spawning && !!roll?.enable;
}

@@ -76,3 +24,3 @@ loadOptions(options, ...sources) {

for (const source of sources) {
options.roll.load(source === null || source === void 0 ? void 0 : source.roll);
options.roll.load(source?.roll);
}

@@ -79,0 +27,0 @@ }

"use strict";
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadRollUpdater = void 0;
const RollUpdater_1 = require("./RollUpdater");
function loadRollUpdater(engine) {
return __awaiter(this, void 0, void 0, function* () {
yield engine.addParticleUpdater("roll", () => new RollUpdater_1.RollUpdater());
});
async function loadRollUpdater(engine, refresh = true) {
await engine.addParticleUpdater("roll", () => new RollUpdater_1.RollUpdater(), refresh);
}
exports.loadRollUpdater = loadRollUpdater;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RollUpdater = void 0;
const engine_1 = require("@tsparticles/engine");
const Utils_1 = require("./Utils");
const Roll_1 = require("./Options/Classes/Roll");
function updateRoll(particle, delta) {
const roll = particle.options.roll;
if (!particle.roll || !(roll === null || roll === void 0 ? void 0 : roll.enable)) {
return;
}
const speed = particle.roll.speed * delta.factor, max = 2 * Math.PI;
particle.roll.angle += speed;
if (particle.roll.angle > max) {
particle.roll.angle -= max;
}
}
class RollUpdater {
getTransformValues(particle) {
var _a;
const roll = ((_a = particle.roll) === null || _a === void 0 ? void 0 : _a.enable) && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
const roll = particle.roll?.enable && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
return {

@@ -27,47 +15,7 @@ a: rollHorizontal ? Math.cos(roll.angle) : undefined,

init(particle) {
const rollOpt = particle.options.roll;
if (rollOpt === null || rollOpt === void 0 ? void 0 : rollOpt.enable) {
particle.roll = {
enable: rollOpt.enable,
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
angle: (0, engine_1.getRandom)() * Math.PI * 2,
speed: (0, engine_1.getRangeValue)(rollOpt.speed) / 360,
};
if (rollOpt.backColor) {
particle.backColor = (0, engine_1.rangeColorToHsl)(rollOpt.backColor);
}
else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
const alterType = (0, engine_1.getRandom)() >= 0.5 ? "darken" : "enlighten";
particle.roll.alter = {
type: alterType,
value: (0, engine_1.getRangeValue)(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value),
};
}
else if (rollOpt.darken.enable) {
particle.roll.alter = {
type: "darken",
value: (0, engine_1.getRangeValue)(rollOpt.darken.value),
};
}
else if (rollOpt.enlighten.enable) {
particle.roll.alter = {
type: "enlighten",
value: (0, engine_1.getRangeValue)(rollOpt.enlighten.value),
};
}
}
else {
particle.roll = {
enable: false,
horizontal: false,
vertical: false,
angle: 0,
speed: 0,
};
}
(0, Utils_1.initParticle)(particle);
}
isEnabled(particle) {
const roll = particle.options.roll;
return !particle.destroyed && !particle.spawning && !!(roll === null || roll === void 0 ? void 0 : roll.enable);
return !particle.destroyed && !particle.spawning && !!roll?.enable;
}

@@ -79,3 +27,3 @@ loadOptions(options, ...sources) {

for (const source of sources) {
options.roll.load(source === null || source === void 0 ? void 0 : source.roll);
options.roll.load(source?.roll);
}

@@ -87,5 +35,5 @@ }

}
updateRoll(particle, delta);
(0, Utils_1.updateRoll)(particle, delta);
}
}
exports.RollUpdater = RollUpdater;
import { RollUpdater } from "./RollUpdater";
export async function loadRollUpdater(engine) {
await engine.addParticleUpdater("roll", () => new RollUpdater());
export async function loadRollUpdater(engine, refresh = true) {
await engine.addParticleUpdater("roll", () => new RollUpdater(), refresh);
}

@@ -1,2 +0,2 @@

import { OptionsColor, setRangeValue } from "@tsparticles/engine";
import { OptionsColor, setRangeValue, } from "@tsparticles/engine";
import { RollLight } from "./RollLight";

@@ -3,0 +3,0 @@ export class Roll {

@@ -1,18 +0,6 @@

import { getRandom, getRangeValue, rangeColorToHsl } from "@tsparticles/engine";
import { initParticle, updateRoll } from "./Utils";
import { Roll } from "./Options/Classes/Roll";
function updateRoll(particle, delta) {
const roll = particle.options.roll;
if (!particle.roll || !(roll === null || roll === void 0 ? void 0 : roll.enable)) {
return;
}
const speed = particle.roll.speed * delta.factor, max = 2 * Math.PI;
particle.roll.angle += speed;
if (particle.roll.angle > max) {
particle.roll.angle -= max;
}
}
export class RollUpdater {
getTransformValues(particle) {
var _a;
const roll = ((_a = particle.roll) === null || _a === void 0 ? void 0 : _a.enable) && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
const roll = particle.roll?.enable && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
return {

@@ -24,47 +12,7 @@ a: rollHorizontal ? Math.cos(roll.angle) : undefined,

init(particle) {
const rollOpt = particle.options.roll;
if (rollOpt === null || rollOpt === void 0 ? void 0 : rollOpt.enable) {
particle.roll = {
enable: rollOpt.enable,
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
angle: getRandom() * Math.PI * 2,
speed: getRangeValue(rollOpt.speed) / 360,
};
if (rollOpt.backColor) {
particle.backColor = rangeColorToHsl(rollOpt.backColor);
}
else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
const alterType = getRandom() >= 0.5 ? "darken" : "enlighten";
particle.roll.alter = {
type: alterType,
value: getRangeValue(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value),
};
}
else if (rollOpt.darken.enable) {
particle.roll.alter = {
type: "darken",
value: getRangeValue(rollOpt.darken.value),
};
}
else if (rollOpt.enlighten.enable) {
particle.roll.alter = {
type: "enlighten",
value: getRangeValue(rollOpt.enlighten.value),
};
}
}
else {
particle.roll = {
enable: false,
horizontal: false,
vertical: false,
angle: 0,
speed: 0,
};
}
initParticle(particle);
}
isEnabled(particle) {
const roll = particle.options.roll;
return !particle.destroyed && !particle.spawning && !!(roll === null || roll === void 0 ? void 0 : roll.enable);
return !particle.destroyed && !particle.spawning && !!roll?.enable;
}

@@ -76,3 +24,3 @@ loadOptions(options, ...sources) {

for (const source of sources) {
options.roll.load(source === null || source === void 0 ? void 0 : source.roll);
options.roll.load(source?.roll);
}

@@ -79,0 +27,0 @@ }

{
"name": "@tsparticles/updater-roll",
"version": "3.0.0-alpha.1",
"version": "3.0.0-beta.0",
"description": "tsParticles particles roll updater",

@@ -76,8 +76,9 @@ "homepage": "https://particles.js.org",

"types": "types/index.d.ts",
"sideEffects": false,
"dependencies": {
"@tsparticles/engine": "^3.0.0-beta.0"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@tsparticles/engine": "^3.0.0-alpha.1"
}
}
}

@@ -5,5 +5,5 @@ [![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)

[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-updater-roll/badge)](https://www.jsdelivr.com/package/npm/tsparticles-updater-roll)
[![npmjs](https://badge.fury.io/js/tsparticles-updater-roll.svg)](https://www.npmjs.com/package/tsparticles-updater-roll)
[![npmjs](https://img.shields.io/npm/dt/tsparticles-updater-roll)](https://www.npmjs.com/package/tsparticles-updater-roll) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/updater-roll/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/updater-roll)
[![npmjs](https://badge.fury.io/js/@tsparticles/updater-roll.svg)](https://www.npmjs.com/package/@tsparticles/updater-roll)
[![npmjs](https://img.shields.io/npm/dt/@tsparticles/updater-roll)](https://www.npmjs.com/package/@tsparticles/updater-roll) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)

@@ -30,3 +30,3 @@ [tsParticles](https://github.com/matteobruni/tsparticles) updater plugin for roll animations.

(async () => {
await loadRollUpdater();
await loadRollUpdater(tsParticles);

@@ -47,3 +47,3 @@ await tsParticles.load({

```shell
$ npm install tsparticles-updater-roll
$ npm install @tsparticles/updater-roll
```

@@ -54,3 +54,3 @@

```shell
$ yarn add tsparticles-updater-roll
$ yarn add @tsparticles/updater-roll
```

@@ -61,6 +61,8 @@

```javascript
const { tsParticles } = require("tsparticles-engine");
const { loadRollUpdater } = require("tsparticles-updater-roll");
const { tsParticles } = require("@tsparticles/engine");
const { loadRollUpdater } = require("@tsparticles/updater-roll");
loadRollUpdater(tsParticles);
(async () => {
await loadRollUpdater(tsParticles);
})();
```

@@ -71,6 +73,8 @@

```javascript
import { tsParticles } from "tsparticles-engine";
import { loadRollUpdater } from "tsparticles-updater-roll";
import { tsParticles } from "@tsparticles/engine";
import { loadRollUpdater } from "@tsparticles/updater-roll";
loadRollUpdater(tsParticles);
(async () => {
await loadRollUpdater(tsParticles);
})();
```

@@ -7,3 +7,3 @@ /*!

* How to use? : Check the GitHub README
* v3.0.0-alpha.1
* v3.0.0-beta.0
*/

@@ -95,3 +95,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

__webpack_require__.d(__webpack_exports__, {
"loadRollUpdater": () => (/* binding */ loadRollUpdater)
loadRollUpdater: () => (/* binding */ loadRollUpdater)
});

@@ -101,2 +101,56 @@

var engine_root_window_ = __webpack_require__(533);
;// CONCATENATED MODULE: ./dist/browser/Utils.js
function initParticle(particle) {
const rollOpt = particle.options.roll;
if (!rollOpt?.enable) {
particle.roll = {
enable: false,
horizontal: false,
vertical: false,
angle: 0,
speed: 0
};
return;
}
particle.roll = {
enable: rollOpt.enable,
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
angle: (0,engine_root_window_.getRandom)() * Math.PI * 2,
speed: (0,engine_root_window_.getRangeValue)(rollOpt.speed) / 360
};
if (rollOpt.backColor) {
particle.backColor = (0,engine_root_window_.rangeColorToHsl)(rollOpt.backColor);
} else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
const alterType = (0,engine_root_window_.getRandom)() >= 0.5 ? "darken" : "enlighten";
particle.roll.alter = {
type: alterType,
value: (0,engine_root_window_.getRangeValue)(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value)
};
} else if (rollOpt.darken.enable) {
particle.roll.alter = {
type: "darken",
value: (0,engine_root_window_.getRangeValue)(rollOpt.darken.value)
};
} else if (rollOpt.enlighten.enable) {
particle.roll.alter = {
type: "enlighten",
value: (0,engine_root_window_.getRangeValue)(rollOpt.enlighten.value)
};
}
}
function updateRoll(particle, delta) {
const roll = particle.options.roll,
data = particle.roll;
if (!data || !roll?.enable) {
return;
}
const speed = data.speed * delta.factor,
max = 2 * Math.PI;
data.angle += speed;
if (data.angle > max) {
data.angle -= max;
}
}
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/RollLight.js

@@ -155,18 +209,5 @@

function updateRoll(particle, delta) {
const roll = particle.options.roll;
if (!particle.roll || !(roll === null || roll === void 0 ? void 0 : roll.enable)) {
return;
}
const speed = particle.roll.speed * delta.factor,
max = 2 * Math.PI;
particle.roll.angle += speed;
if (particle.roll.angle > max) {
particle.roll.angle -= max;
}
}
class RollUpdater {
getTransformValues(particle) {
var _a;
const roll = ((_a = particle.roll) === null || _a === void 0 ? void 0 : _a.enable) && particle.roll,
const roll = particle.roll?.enable && particle.roll,
rollHorizontal = roll && roll.horizontal,

@@ -180,43 +221,7 @@ rollVertical = roll && roll.vertical;

init(particle) {
const rollOpt = particle.options.roll;
if (rollOpt === null || rollOpt === void 0 ? void 0 : rollOpt.enable) {
particle.roll = {
enable: rollOpt.enable,
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
angle: (0,engine_root_window_.getRandom)() * Math.PI * 2,
speed: (0,engine_root_window_.getRangeValue)(rollOpt.speed) / 360
};
if (rollOpt.backColor) {
particle.backColor = (0,engine_root_window_.rangeColorToHsl)(rollOpt.backColor);
} else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
const alterType = (0,engine_root_window_.getRandom)() >= 0.5 ? "darken" : "enlighten";
particle.roll.alter = {
type: alterType,
value: (0,engine_root_window_.getRangeValue)(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value)
};
} else if (rollOpt.darken.enable) {
particle.roll.alter = {
type: "darken",
value: (0,engine_root_window_.getRangeValue)(rollOpt.darken.value)
};
} else if (rollOpt.enlighten.enable) {
particle.roll.alter = {
type: "enlighten",
value: (0,engine_root_window_.getRangeValue)(rollOpt.enlighten.value)
};
}
} else {
particle.roll = {
enable: false,
horizontal: false,
vertical: false,
angle: 0,
speed: 0
};
}
initParticle(particle);
}
isEnabled(particle) {
const roll = particle.options.roll;
return !particle.destroyed && !particle.spawning && !!(roll === null || roll === void 0 ? void 0 : roll.enable);
return !particle.destroyed && !particle.spawning && !!roll?.enable;
}

@@ -228,3 +233,3 @@ loadOptions(options, ...sources) {

for (const source of sources) {
options.roll.load(source === null || source === void 0 ? void 0 : source.roll);
options.roll.load(source?.roll);
}

@@ -241,4 +246,4 @@ }

async function loadRollUpdater(engine) {
await engine.addParticleUpdater("roll", () => new RollUpdater());
async function loadRollUpdater(engine, refresh = true) {
await engine.addParticleUpdater("roll", () => new RollUpdater(), refresh);
}

@@ -245,0 +250,0 @@ })();

/*! For license information please see tsparticles.updater.roll.min.js.LICENSE.txt */
!function(e,l){if("object"==typeof exports&&"object"==typeof module)module.exports=l(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],l);else{var o="object"==typeof exports?l(require("@tsparticles/engine")):l(e.window);for(var t in o)("object"==typeof exports?exports:e)[t]=o[t]}}(this,(e=>(()=>{"use strict";var l={533:l=>{l.exports=e}},o={};function t(e){var n=o[e];if(void 0!==n)return n.exports;var a=o[e]={exports:{}};return l[e](a,a.exports,t),a.exports}t.d=(e,l)=>{for(var o in l)t.o(l,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:l[o]})},t.o=(e,l)=>Object.prototype.hasOwnProperty.call(e,l),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{t.r(n),t.d(n,{loadRollUpdater:()=>r});var e=t(533);class l{constructor(){this.enable=!1,this.value=0}load(l){l&&(void 0!==l.enable&&(this.enable=l.enable),void 0!==l.value&&(this.value=(0,e.setRangeValue)(l.value)))}}class o{constructor(){this.darken=new l,this.enable=!1,this.enlighten=new l,this.mode="vertical",this.speed=25}load(l){l&&(void 0!==l.backColor&&(this.backColor=e.OptionsColor.create(this.backColor,l.backColor)),this.darken.load(l.darken),void 0!==l.enable&&(this.enable=l.enable),this.enlighten.load(l.enlighten),void 0!==l.mode&&(this.mode=l.mode),void 0!==l.speed&&(this.speed=(0,e.setRangeValue)(l.speed)))}}class a{getTransformValues(e){var l;const o=(null===(l=e.roll)||void 0===l?void 0:l.enable)&&e.roll,t=o&&o.horizontal,n=o&&o.vertical;return{a:t?Math.cos(o.angle):void 0,d:n?Math.sin(o.angle):void 0}}init(l){const o=l.options.roll;if(null==o?void 0:o.enable)if(l.roll={enable:o.enable,horizontal:"horizontal"===o.mode||"both"===o.mode,vertical:"vertical"===o.mode||"both"===o.mode,angle:(0,e.getRandom)()*Math.PI*2,speed:(0,e.getRangeValue)(o.speed)/360},o.backColor)l.backColor=(0,e.rangeColorToHsl)(o.backColor);else if(o.darken.enable&&o.enlighten.enable){const t=(0,e.getRandom)()>=.5?"darken":"enlighten";l.roll.alter={type:t,value:(0,e.getRangeValue)("darken"===t?o.darken.value:o.enlighten.value)}}else o.darken.enable?l.roll.alter={type:"darken",value:(0,e.getRangeValue)(o.darken.value)}:o.enlighten.enable&&(l.roll.alter={type:"enlighten",value:(0,e.getRangeValue)(o.enlighten.value)});else l.roll={enable:!1,horizontal:!1,vertical:!1,angle:0,speed:0}}isEnabled(e){const l=e.options.roll;return!e.destroyed&&!e.spawning&&!!(null==l?void 0:l.enable)}loadOptions(e,...l){e.roll||(e.roll=new o);for(const o of l)e.roll.load(null==o?void 0:o.roll)}update(e,l){this.isEnabled(e)&&function(e,l){const o=e.options.roll;if(!e.roll||!(null==o?void 0:o.enable))return;const t=e.roll.speed*l.factor,n=2*Math.PI;e.roll.angle+=t,e.roll.angle>n&&(e.roll.angle-=n)}(e,l)}}async function r(e){await e.addParticleUpdater("roll",(()=>new a))}})(),n})()));
!function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var l="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var t in l)("object"==typeof exports?exports:e)[t]=l[t]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},l={};function t(e){var n=l[e];if(void 0!==n)return n.exports;var a=l[e]={exports:{}};return o[e](a,a.exports,t),a.exports}t.d=(e,o)=>{for(var l in o)t.o(o,l)&&!t.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:o[l]})},t.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{t.r(n),t.d(n,{loadRollUpdater:()=>r});var e=t(533);class o{constructor(){this.enable=!1,this.value=0}load(o){o&&(void 0!==o.enable&&(this.enable=o.enable),void 0!==o.value&&(this.value=(0,e.setRangeValue)(o.value)))}}class l{constructor(){this.darken=new o,this.enable=!1,this.enlighten=new o,this.mode="vertical",this.speed=25}load(o){o&&(void 0!==o.backColor&&(this.backColor=e.OptionsColor.create(this.backColor,o.backColor)),this.darken.load(o.darken),void 0!==o.enable&&(this.enable=o.enable),this.enlighten.load(o.enlighten),void 0!==o.mode&&(this.mode=o.mode),void 0!==o.speed&&(this.speed=(0,e.setRangeValue)(o.speed)))}}class a{getTransformValues(e){const o=e.roll?.enable&&e.roll,l=o&&o.horizontal,t=o&&o.vertical;return{a:l?Math.cos(o.angle):void 0,d:t?Math.sin(o.angle):void 0}}init(o){!function(o){const l=o.options.roll;if(l?.enable)if(o.roll={enable:l.enable,horizontal:"horizontal"===l.mode||"both"===l.mode,vertical:"vertical"===l.mode||"both"===l.mode,angle:(0,e.getRandom)()*Math.PI*2,speed:(0,e.getRangeValue)(l.speed)/360},l.backColor)o.backColor=(0,e.rangeColorToHsl)(l.backColor);else if(l.darken.enable&&l.enlighten.enable){const t=(0,e.getRandom)()>=.5?"darken":"enlighten";o.roll.alter={type:t,value:(0,e.getRangeValue)("darken"===t?l.darken.value:l.enlighten.value)}}else l.darken.enable?o.roll.alter={type:"darken",value:(0,e.getRangeValue)(l.darken.value)}:l.enlighten.enable&&(o.roll.alter={type:"enlighten",value:(0,e.getRangeValue)(l.enlighten.value)});else o.roll={enable:!1,horizontal:!1,vertical:!1,angle:0,speed:0}}(o)}isEnabled(e){const o=e.options.roll;return!e.destroyed&&!e.spawning&&!!o?.enable}loadOptions(e,...o){e.roll||(e.roll=new l);for(const l of o)e.roll.load(l?.roll)}update(e,o){this.isEnabled(e)&&function(e,o){const l=e.options.roll,t=e.roll;if(!t||!l?.enable)return;const n=t.speed*o.factor,a=2*Math.PI;t.angle+=n,t.angle>a&&(t.angle-=a)}(e,o)}}async function r(e,o=!0){await e.addParticleUpdater("roll",(()=>new a),o)}})(),n})()));

@@ -1,8 +0,1 @@

/*!
* Author : Matteo Bruni
* MIT license: https://opensource.org/licenses/MIT
* Demo / Generator : https://particles.js.org/
* GitHub : https://www.github.com/matteobruni/tsparticles
* How to use? : Check the GitHub README
* v3.0.0-alpha.1
*/
/*! tsParticles Roll Updater v3.0.0-beta.0 by Matteo Bruni */
import type { Engine } from "@tsparticles/engine";
export declare function loadRollUpdater(engine: Engine): Promise<void>;
export declare function loadRollUpdater(engine: Engine, refresh?: boolean): Promise<void>;

@@ -1,3 +0,2 @@

import type { IOptionLoader, RangeValue, RecursivePartial } from "@tsparticles/engine";
import { OptionsColor } from "@tsparticles/engine";
import { type IOptionLoader, OptionsColor, type RangeValue, type RecursivePartial } from "@tsparticles/engine";
import type { IRoll } from "../Interfaces/IRoll";

@@ -4,0 +3,0 @@ import { RollLight } from "./RollLight";

@@ -1,2 +0,2 @@

import type { IOptionLoader, RangeValue, RecursivePartial } from "@tsparticles/engine";
import { type IOptionLoader, type RangeValue, type RecursivePartial } from "@tsparticles/engine";
import type { IRollLight } from "../Interfaces/IRollLight";

@@ -3,0 +3,0 @@ export declare class RollLight implements IRollLight, IOptionLoader<IRollLight> {

@@ -1,13 +0,3 @@

import type { IDelta, IParticleTransformValues, IParticleUpdater, IParticlesOptions, Particle, ParticlesOptions, RecursivePartial } from "@tsparticles/engine";
import type { IRoll } from "./Options/Interfaces/IRoll";
import { Roll } from "./Options/Classes/Roll";
type RollParticle = Particle & {
options: RollParticlesOptions;
};
type RollParticlesOptions = ParticlesOptions & {
roll?: Roll;
};
type IRollParticlesOptions = IParticlesOptions & {
roll?: IRoll;
};
import { type IDelta, type IParticleTransformValues, type IParticleUpdater, type Particle, type RecursivePartial } from "@tsparticles/engine";
import type { IRollParticlesOptions, RollParticle, RollParticlesOptions } from "./Types";
export declare class RollUpdater implements IParticleUpdater {

@@ -20,2 +10,1 @@ getTransformValues(particle: Particle): IParticleTransformValues;

}
export {};

@@ -14,6 +14,6 @@ (function (factory) {

const RollUpdater_1 = require("./RollUpdater");
async function loadRollUpdater(engine) {
await engine.addParticleUpdater("roll", () => new RollUpdater_1.RollUpdater());
async function loadRollUpdater(engine, refresh = true) {
await engine.addParticleUpdater("roll", () => new RollUpdater_1.RollUpdater(), refresh);
}
exports.loadRollUpdater = loadRollUpdater;
});

@@ -7,3 +7,3 @@ (function (factory) {

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Roll"], factory);
define(["require", "exports", "./Utils", "./Options/Classes/Roll"], factory);
}

@@ -14,19 +14,7 @@ })(function (require, exports) {

exports.RollUpdater = void 0;
const engine_1 = require("@tsparticles/engine");
const Utils_1 = require("./Utils");
const Roll_1 = require("./Options/Classes/Roll");
function updateRoll(particle, delta) {
const roll = particle.options.roll;
if (!particle.roll || !(roll === null || roll === void 0 ? void 0 : roll.enable)) {
return;
}
const speed = particle.roll.speed * delta.factor, max = 2 * Math.PI;
particle.roll.angle += speed;
if (particle.roll.angle > max) {
particle.roll.angle -= max;
}
}
class RollUpdater {
getTransformValues(particle) {
var _a;
const roll = ((_a = particle.roll) === null || _a === void 0 ? void 0 : _a.enable) && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
const roll = particle.roll?.enable && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
return {

@@ -38,47 +26,7 @@ a: rollHorizontal ? Math.cos(roll.angle) : undefined,

init(particle) {
const rollOpt = particle.options.roll;
if (rollOpt === null || rollOpt === void 0 ? void 0 : rollOpt.enable) {
particle.roll = {
enable: rollOpt.enable,
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
angle: (0, engine_1.getRandom)() * Math.PI * 2,
speed: (0, engine_1.getRangeValue)(rollOpt.speed) / 360,
};
if (rollOpt.backColor) {
particle.backColor = (0, engine_1.rangeColorToHsl)(rollOpt.backColor);
}
else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
const alterType = (0, engine_1.getRandom)() >= 0.5 ? "darken" : "enlighten";
particle.roll.alter = {
type: alterType,
value: (0, engine_1.getRangeValue)(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value),
};
}
else if (rollOpt.darken.enable) {
particle.roll.alter = {
type: "darken",
value: (0, engine_1.getRangeValue)(rollOpt.darken.value),
};
}
else if (rollOpt.enlighten.enable) {
particle.roll.alter = {
type: "enlighten",
value: (0, engine_1.getRangeValue)(rollOpt.enlighten.value),
};
}
}
else {
particle.roll = {
enable: false,
horizontal: false,
vertical: false,
angle: 0,
speed: 0,
};
}
(0, Utils_1.initParticle)(particle);
}
isEnabled(particle) {
const roll = particle.options.roll;
return !particle.destroyed && !particle.spawning && !!(roll === null || roll === void 0 ? void 0 : roll.enable);
return !particle.destroyed && !particle.spawning && !!roll?.enable;
}

@@ -90,3 +38,3 @@ loadOptions(options, ...sources) {

for (const source of sources) {
options.roll.load(source === null || source === void 0 ? void 0 : source.roll);
options.roll.load(source?.roll);
}

@@ -98,3 +46,3 @@ }

}
updateRoll(particle, delta);
(0, Utils_1.updateRoll)(particle, delta);
}

@@ -101,0 +49,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc