@tsparticles/shape-cog 3.9.0 → 4.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/385.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 385.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_shape_cog=this.webpackChunk_tsparticles_shape_cog||[]).push([[385],{385(e,o,a){a.d(o,{CogDrawer:()=>r});var t=a(303);const n=2*Math.PI,c=0,i=0;class r{constructor(){this.validTypes=["cog"]}afterDraw(e){!function(e){const{context:o,particle:a,radius:r}=e;if(void 0===a.cogHoleRadius||void 0===a.cogInnerRadius||void 0===a.cogInnerTaper||void 0===a.cogNotches||void 0===a.cogOuterTaper)return;const s=r*a.cogHoleRadius/t.percentDenominator;o.globalCompositeOperation="destination-out",o.beginPath(),o.moveTo(s,i),o.arc(c,i,s,0,n),o.closePath(),o.fill(),o.globalCompositeOperation="source-over"}(e)}draw(e){!function(e){const{context:o,particle:a,radius:c}=e;if(void 0===a.cogHoleRadius||void 0===a.cogInnerRadius||void 0===a.cogInnerTaper||void 0===a.cogNotches||void 0===a.cogOuterTaper)return;const i=n/(2*a.cogNotches),r=i*a.cogInnerTaper*.005,s=i*a.cogOuterTaper*.005,g=c*a.cogInnerRadius/t.percentDenominator;let u=i,l=!1;for(o.moveTo(c*Math.cos(s),c*Math.sin(s));u<=n;u+=i)l?(o.lineTo(g*Math.cos(u-r),g*Math.sin(u-r)),o.lineTo(c*Math.cos(u+s),c*Math.sin(u+s))):(o.lineTo(c*Math.cos(u-s),c*Math.sin(u-s)),o.lineTo(g*Math.cos(u+r),g*Math.sin(u+r))),l=!l}(e)}particleInit(e,o){const a=o.shapeData;o.cogHoleRadius=(0,t.getRangeValue)(a?.holeRadius??44),o.cogInnerRadius=(0,t.getRangeValue)(a?.innerRadius??72),o.cogInnerTaper=(0,t.getRangeValue)(a?.innerTaper??35),o.cogNotches=(0,t.getRangeValue)(a?.notches??7),o.cogOuterTaper=(0,t.getRangeValue)(a?.outerTaper??50)}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Cog Shape v4.0.0-alpha.0 by Matteo Bruni */
@@ -11,7 +11,7 @@ export class CogDrawer {
11
11
  draw(data) {
12
12
  drawCog(data);
13
13
  }
14
- particleInit(container, particle) {
14
+ particleInit(_container, particle) {
15
15
  const shapeData = particle.shapeData;
16
16
  particle.cogHoleRadius = getRangeValue(shapeData?.holeRadius ?? defaultHoleRadius);
17
17
  particle.cogInnerRadius = getRangeValue(shapeData?.innerRadius ?? defaultInnerRadius);
package/browser/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { CogDrawer } from "./CogDrawer.js";
2
- export async function loadCogShape(engine, refresh = true) {
3
- engine.checkVersion("3.9.0");
4
- await engine.addShape(new CogDrawer(), refresh);
1
+ export function loadCogShape(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { CogDrawer } = await import("./CogDrawer.js");
5
+ e.addShape(new CogDrawer());
6
+ });
5
7
  }
package/cjs/CogDrawer.js CHANGED
@@ -1,26 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CogDrawer = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const Utils_js_1 = require("./Utils.js");
1
+ import { getRangeValue } from "@tsparticles/engine";
2
+ import { drawCog, drawCogHole } from "./Utils.js";
6
3
  const defaultHoleRadius = 44, defaultInnerRadius = 72, defaultInnerTaper = 35, defaultNotches = 7, defaultOuterTaper = 50;
7
- class CogDrawer {
4
+ export class CogDrawer {
8
5
  constructor() {
9
6
  this.validTypes = ["cog"];
10
7
  }
11
8
  afterDraw(data) {
12
- (0, Utils_js_1.drawCogHole)(data);
9
+ drawCogHole(data);
13
10
  }
14
11
  draw(data) {
15
- (0, Utils_js_1.drawCog)(data);
12
+ drawCog(data);
16
13
  }
17
- particleInit(container, particle) {
14
+ particleInit(_container, particle) {
18
15
  const shapeData = particle.shapeData;
19
- particle.cogHoleRadius = (0, engine_1.getRangeValue)(shapeData?.holeRadius ?? defaultHoleRadius);
20
- particle.cogInnerRadius = (0, engine_1.getRangeValue)(shapeData?.innerRadius ?? defaultInnerRadius);
21
- particle.cogInnerTaper = (0, engine_1.getRangeValue)(shapeData?.innerTaper ?? defaultInnerTaper);
22
- particle.cogNotches = (0, engine_1.getRangeValue)(shapeData?.notches ?? defaultNotches);
23
- particle.cogOuterTaper = (0, engine_1.getRangeValue)(shapeData?.outerTaper ?? defaultOuterTaper);
16
+ particle.cogHoleRadius = getRangeValue(shapeData?.holeRadius ?? defaultHoleRadius);
17
+ particle.cogInnerRadius = getRangeValue(shapeData?.innerRadius ?? defaultInnerRadius);
18
+ particle.cogInnerTaper = getRangeValue(shapeData?.innerTaper ?? defaultInnerTaper);
19
+ particle.cogNotches = getRangeValue(shapeData?.notches ?? defaultNotches);
20
+ particle.cogOuterTaper = getRangeValue(shapeData?.outerTaper ?? defaultOuterTaper);
24
21
  }
25
22
  }
26
- exports.CogDrawer = CogDrawer;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/ICogData.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/Utils.js CHANGED
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.drawCogHole = drawCogHole;
4
- exports.drawCog = drawCog;
5
- const engine_1 = require("@tsparticles/engine");
1
+ import { percentDenominator } from "@tsparticles/engine";
6
2
  const double = 2, doublePI = Math.PI * double, minAngle = 0, origin = { x: 0, y: 0 }, taperFactor = 0.005;
7
- function drawCogHole(data) {
3
+ export function drawCogHole(data) {
8
4
  const { context, particle, radius } = data;
9
5
  if (particle.cogHoleRadius === undefined ||
10
6
  particle.cogInnerRadius === undefined ||
@@ -13,7 +9,7 @@ function drawCogHole(data) {
13
9
  particle.cogOuterTaper === undefined) {
14
10
  return;
15
11
  }
16
- const holeRadius = (radius * particle.cogHoleRadius) / engine_1.percentDenominator;
12
+ const holeRadius = (radius * particle.cogHoleRadius) / percentDenominator;
17
13
  context.globalCompositeOperation = "destination-out";
18
14
  context.beginPath();
19
15
  context.moveTo(holeRadius, origin.y);
@@ -22,7 +18,7 @@ function drawCogHole(data) {
22
18
  context.fill();
23
19
  context.globalCompositeOperation = "source-over";
24
20
  }
25
- function drawCog(data) {
21
+ export function drawCog(data) {
26
22
  const { context, particle, radius } = data;
27
23
  if (particle.cogHoleRadius === undefined ||
28
24
  particle.cogInnerRadius === undefined ||
@@ -31,7 +27,7 @@ function drawCog(data) {
31
27
  particle.cogOuterTaper === undefined) {
32
28
  return;
33
29
  }
34
- const angle = doublePI / (particle.cogNotches * double), taperAI = angle * particle.cogInnerTaper * taperFactor, taperAO = angle * particle.cogOuterTaper * taperFactor, innerRadius = (radius * particle.cogInnerRadius) / engine_1.percentDenominator;
30
+ const angle = doublePI / (particle.cogNotches * double), taperAI = angle * particle.cogInnerTaper * taperFactor, taperAO = angle * particle.cogOuterTaper * taperFactor, innerRadius = (radius * particle.cogInnerRadius) / percentDenominator;
35
31
  let a = angle, toggle = false;
36
32
  context.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
37
33
  for (; a <= doublePI; a += angle) {
package/cjs/index.js CHANGED
@@ -1,8 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadCogShape = loadCogShape;
4
- const CogDrawer_js_1 = require("./CogDrawer.js");
5
- async function loadCogShape(engine, refresh = true) {
6
- engine.checkVersion("3.9.0");
7
- await engine.addShape(new CogDrawer_js_1.CogDrawer(), refresh);
1
+ export function loadCogShape(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { CogDrawer } = await import("./CogDrawer.js");
5
+ e.addShape(new CogDrawer());
6
+ });
8
7
  }
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v4.0.0-alpha.0
8
+ */
9
+ "use strict";
10
+ /*
11
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
+ * This devtool is neither made for production nor for readable output files.
13
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
14
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
+ * or disable the default devtool with "devtool: false".
16
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
+ */
18
+ (this["webpackChunk_tsparticles_shape_cog"] = this["webpackChunk_tsparticles_shape_cog"] || []).push([["dist_browser_CogDrawer_js"],{
19
+
20
+ /***/ "./dist/browser/CogDrawer.js"
21
+ /*!***********************************!*\
22
+ !*** ./dist/browser/CogDrawer.js ***!
23
+ \***********************************/
24
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
+
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CogDrawer: () => (/* binding */ CogDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst defaultHoleRadius = 44,\n defaultInnerRadius = 72,\n defaultInnerTaper = 35,\n defaultNotches = 7,\n defaultOuterTaper = 50;\nclass CogDrawer {\n constructor() {\n this.validTypes = [\"cog\"];\n }\n afterDraw(data) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawCogHole)(data);\n }\n draw(data) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawCog)(data);\n }\n particleInit(_container, particle) {\n const shapeData = particle.shapeData;\n particle.cogHoleRadius = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(shapeData?.holeRadius ?? defaultHoleRadius);\n particle.cogInnerRadius = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(shapeData?.innerRadius ?? defaultInnerRadius);\n particle.cogInnerTaper = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(shapeData?.innerTaper ?? defaultInnerTaper);\n particle.cogNotches = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(shapeData?.notches ?? defaultNotches);\n particle.cogOuterTaper = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(shapeData?.outerTaper ?? defaultOuterTaper);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-cog/./dist/browser/CogDrawer.js?\n}");
27
+
28
+ /***/ },
29
+
30
+ /***/ "./dist/browser/Utils.js"
31
+ /*!*******************************!*\
32
+ !*** ./dist/browser/Utils.js ***!
33
+ \*******************************/
34
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
35
+
36
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawCog: () => (/* binding */ drawCog),\n/* harmony export */ drawCogHole: () => (/* binding */ drawCogHole)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst double = 2,\n doublePI = Math.PI * double,\n minAngle = 0,\n origin = {\n x: 0,\n y: 0\n },\n taperFactor = 0.005;\nfunction drawCogHole(data) {\n const {\n context,\n particle,\n radius\n } = data;\n if (particle.cogHoleRadius === undefined || particle.cogInnerRadius === undefined || particle.cogInnerTaper === undefined || particle.cogNotches === undefined || particle.cogOuterTaper === undefined) {\n return;\n }\n const holeRadius = radius * particle.cogHoleRadius / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n context.globalCompositeOperation = \"destination-out\";\n context.beginPath();\n context.moveTo(holeRadius, origin.y);\n context.arc(origin.x, origin.y, holeRadius, minAngle, doublePI);\n context.closePath();\n context.fill();\n context.globalCompositeOperation = \"source-over\";\n}\nfunction drawCog(data) {\n const {\n context,\n particle,\n radius\n } = data;\n if (particle.cogHoleRadius === undefined || particle.cogInnerRadius === undefined || particle.cogInnerTaper === undefined || particle.cogNotches === undefined || particle.cogOuterTaper === undefined) {\n return;\n }\n const angle = doublePI / (particle.cogNotches * double),\n taperAI = angle * particle.cogInnerTaper * taperFactor,\n taperAO = angle * particle.cogOuterTaper * taperFactor,\n innerRadius = radius * particle.cogInnerRadius / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n let a = angle,\n toggle = false;\n context.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));\n for (; a <= doublePI; a += angle) {\n if (toggle) {\n context.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));\n context.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));\n } else {\n context.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));\n context.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));\n }\n toggle = !toggle;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-cog/./dist/browser/Utils.js?\n}");
37
+
38
+ /***/ }
39
+
40
+ }]);
package/esm/CogDrawer.js CHANGED
@@ -11,7 +11,7 @@ export class CogDrawer {
11
11
  draw(data) {
12
12
  drawCog(data);
13
13
  }
14
- particleInit(container, particle) {
14
+ particleInit(_container, particle) {
15
15
  const shapeData = particle.shapeData;
16
16
  particle.cogHoleRadius = getRangeValue(shapeData?.holeRadius ?? defaultHoleRadius);
17
17
  particle.cogInnerRadius = getRangeValue(shapeData?.innerRadius ?? defaultInnerRadius);
package/esm/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { CogDrawer } from "./CogDrawer.js";
2
- export async function loadCogShape(engine, refresh = true) {
3
- engine.checkVersion("3.9.0");
4
- await engine.addShape(new CogDrawer(), refresh);
1
+ export function loadCogShape(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { CogDrawer } = await import("./CogDrawer.js");
5
+ e.addShape(new CogDrawer());
6
+ });
5
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/shape-cog",
3
- "version": "3.9.0",
3
+ "version": "4.0.0-alpha.0",
4
4
  "description": "tsParticles cog shape",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -100,9 +100,10 @@
100
100
  "./package.json": "./package.json"
101
101
  },
102
102
  "dependencies": {
103
- "@tsparticles/engine": "3.9.0"
103
+ "@tsparticles/engine": "4.0.0-alpha.0"
104
104
  },
105
105
  "publishConfig": {
106
106
  "access": "public"
107
- }
107
+ },
108
+ "type": "module"
108
109
  }