@tsparticles/shape-path 4.0.0-alpha.2 → 4.0.0-alpha.21

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.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-alpha.2
7
+ * v4.0.0-alpha.21
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -16,28 +16,18 @@
16
16
  */
17
17
  (function webpackUniversalModuleDefinition(root, factory) {
18
18
  if(typeof exports === 'object' && typeof module === 'object')
19
- module.exports = factory(require("@tsparticles/engine"));
19
+ module.exports = factory(require("@tsparticles/engine"), require("@tsparticles/path-utils"));
20
20
  else if(typeof define === 'function' && define.amd)
21
- define(["@tsparticles/engine"], factory);
21
+ define(["@tsparticles/engine", "@tsparticles/path-utils"], factory);
22
22
  else {
23
- var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
23
+ var a = typeof exports === 'object' ? factory(require("@tsparticles/engine"), require("@tsparticles/path-utils")) : factory(root["window"], root["window"]);
24
24
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
25
25
  }
26
- })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__, __WEBPACK_EXTERNAL_MODULE__tsparticles_path_utils__) => {
27
27
  return /******/ (() => { // webpackBootstrap
28
28
  /******/ "use strict";
29
29
  /******/ var __webpack_modules__ = ({
30
30
 
31
- /***/ "./dist/browser/index.js"
32
- /*!*******************************!*\
33
- !*** ./dist/browser/index.js ***!
34
- \*******************************/
35
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
36
-
37
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPathShape: () => (/* binding */ loadPathShape)\n/* harmony export */ });\nfunction loadPathShape(engine) {\n engine.checkVersion(\"4.0.0-alpha.2\");\n engine.register(async e => {\n const {\n PathDrawer\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_PathDrawer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./PathDrawer.js */ \"./dist/browser/PathDrawer.js\"));\n e.addShape(new PathDrawer());\n });\n}\n\n//# sourceURL=webpack://@tsparticles/shape-path/./dist/browser/index.js?\n}");
38
-
39
- /***/ },
40
-
41
31
  /***/ "@tsparticles/engine"
42
32
  /*!*********************************************************************************************************************************!*\
43
33
  !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
@@ -46,6 +36,26 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
46
36
 
47
37
  module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
48
38
 
39
+ /***/ },
40
+
41
+ /***/ "@tsparticles/path-utils"
42
+ /*!*********************************************************************************************************************************************!*\
43
+ !*** external {"commonjs":"@tsparticles/path-utils","commonjs2":"@tsparticles/path-utils","amd":"@tsparticles/path-utils","root":"window"} ***!
44
+ \*********************************************************************************************************************************************/
45
+ (module) {
46
+
47
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_path_utils__;
48
+
49
+ /***/ },
50
+
51
+ /***/ "./dist/browser/index.js"
52
+ /*!*******************************!*\
53
+ !*** ./dist/browser/index.js ***!
54
+ \*******************************/
55
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
56
+
57
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPathShape: () => (/* binding */ loadPathShape)\n/* harmony export */ });\nasync function loadPathShape(engine) {\n engine.checkVersion(\"4.0.0-alpha.21\");\n await engine.register((e)=>{\n e.addShape([\n \"path\"\n ], async ()=>{\n const { PathDrawer } = await __webpack_require__.e(/*! import() */ \"dist_browser_PathDrawer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./PathDrawer.js */ \"./dist/browser/PathDrawer.js\"));\n return new PathDrawer();\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-path/./dist/browser/index.js?\n}");
58
+
49
59
  /***/ }
50
60
 
51
61
  /******/ });
@@ -1,2 +1,2 @@
1
- /*! For license information please see tsparticles.shape.path.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{var t,r,o={303(t){t.exports=e}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.m=o,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/shape-path:",a.l=(e,o,n,i)=>{if(t[e])t[e].push(o);else{var s,p;if(void 0!==n)for(var c=document.getElementsByTagName("script"),l=0;l<c.length;l++){var u=c[l];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==r+n){s=u;break}}s||(p=!0,(s=document.createElement("script")).charset="utf-8",a.nc&&s.setAttribute("nonce",a.nc),s.setAttribute("data-webpack",r+n),s.src=e),t[e]=[o];var d=(r,o)=>{s.onerror=s.onload=null,clearTimeout(f);var n=t[e];if(delete t[e],s.parentNode&&s.parentNode.removeChild(s),n&&n.forEach((e=>e(o))),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.bind(null,s.onload),p&&document.head.appendChild(s)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={381:0};a.f.j=(t,r)=>{var o=a.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise(((r,n)=>o=e[t]=[r,n]));r.push(o[2]=n);var i=a.p+a.u(t),s=new Error;a.l(i,(r=>{if(a.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+i+")",s.name="ChunkLoadError",s.type=n,s.request=i,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,n,[i,s,p]=r,c=0;if(i.some((t=>0!==e[t]))){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);if(p)p(a)}for(t&&t(r);c<i.length;c++)n=i[c],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_shape_path=this.webpackChunk_tsparticles_shape_path||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};function s(e){e.checkVersion("4.0.0-alpha.2"),e.register((async e=>{const{PathDrawer:t}=await a.e(237).then(a.bind(a,237));e.addShape(new t)}))}return a.r(i),a.d(i,{loadPathShape:()=>s}),i})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/path-utils"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/path-utils"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/path-utils")):t(e.window,e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e,t)=>(()=>{"use strict";var r,o,i,a={303(t){t.exports=e},580(e){e.exports=t}},n={};function s(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return a[e](r,r.exports,s),r.exports}s.m=a,s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,r)=>(s.f[r](e,t),t),[])),s.u=e=>""+e+".min.js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p={},s.l=(e,t,r,o)=>{if(p[e])return void p[e].push(t);if(void 0!==r)for(var i,a,n=document.getElementsByTagName("script"),c=0;c<n.length;c++){var l=n[c];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")=="@tsparticles/shape-path:"+r){i=l;break}}i||(a=!0,(i=document.createElement("script")).charset="utf-8",s.nc&&i.setAttribute("nonce",s.nc),i.setAttribute("data-webpack","@tsparticles/shape-path:"+r),i.src=e),p[e]=[t];var u=(t,r)=>{i.onerror=i.onload=null,clearTimeout(d);var o=p[e];if(delete p[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=u.bind(null,i.onerror),i.onload=u.bind(null,i.onload),a&&document.head.appendChild(i)},s.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(c=s.g.location+"");var p,c,l=s.g.document;if(!c&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(c=l.currentScript.src),!c)){var u=l.getElementsByTagName("script");if(u.length)for(var d=u.length-1;d>-1&&(!c||!/^http(s?):/.test(c));)c=u[d--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");s.p=c=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={381:0},s.f.j=(e,t)=>{var o=s.o(r,e)?r[e]:void 0;if(0!==o)if(o)t.push(o[2]);else{var i=new Promise((t,i)=>o=r[e]=[t,i]);t.push(o[2]=i);var a=s.p+s.u(e),n=Error();s.l(a,t=>{if(s.o(r,e)&&(0!==(o=r[e])&&(r[e]=void 0),o)){var i=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;n.message="Loading chunk "+e+` failed.
2
+ (`+i+": "+a+")",n.name="ChunkLoadError",n.type=i,n.request=a,o[1](n)}},"chunk-"+e,e)}},o=(e,t)=>{var o,i,[a,n,p]=t,c=0;if(a.some(e=>0!==r[e])){for(o in n)s.o(n,o)&&(s.m[o]=n[o]);p&&p(s)}for(e&&e(t);c<a.length;c++)i=a[c],s.o(r,i)&&r[i]&&r[i][0](),r[i]=0},(i=this.webpackChunk_tsparticles_shape_path=this.webpackChunk_tsparticles_shape_path||[]).forEach(o.bind(null,0)),i.push=o.bind(null,i.push.bind(i));var h={};async function f(e){e.checkVersion("4.0.0-alpha.21"),await e.register(e=>{e.addShape(["path"],async()=>{let{PathDrawer:e}=await s.e(549).then(s.bind(s,549));return new e})})}return s.r(h),s.d(h,{loadPathShape:()=>f}),h})());
@@ -0,0 +1,4 @@
1
+ import type { IPathData } from "@tsparticles/path-utils";
2
+ import type { IShapeValues } from "@tsparticles/engine";
3
+ export interface IShapePathData extends IShapeValues, IPathData {
4
+ }
@@ -1,7 +1,6 @@
1
1
  import { type Container, type IShapeDrawData, type IShapeDrawer } from "@tsparticles/engine";
2
2
  import type { PathParticle } from "./PathParticle.js";
3
3
  export declare class PathDrawer implements IShapeDrawer<PathParticle> {
4
- readonly validTypes: readonly ["path"];
5
4
  draw(data: IShapeDrawData<PathParticle>): void;
6
5
  particleInit(_container: Container, particle: PathParticle): void;
7
6
  }
@@ -1,5 +1,5 @@
1
- import type { IPathData } from "./IPathData.js";
1
+ import type { IShapePathData } from "./IShapePathData.js";
2
2
  import type { Particle } from "@tsparticles/engine";
3
3
  export type PathParticle = Particle & {
4
- pathData?: IPathData;
4
+ pathData?: IShapePathData;
5
5
  };
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import { type Engine } from "@tsparticles/engine";
2
- export declare function loadPathShape(engine: Engine): void;
2
+ export declare function loadPathShape(engine: Engine): Promise<void>;
package/umd/PathDrawer.js CHANGED
@@ -4,24 +4,21 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./Utils.js"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "@tsparticles/path-utils"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PathDrawer = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
- const Utils_js_1 = require("./Utils.js");
14
+ const path_utils_1 = require("@tsparticles/path-utils");
15
15
  class PathDrawer {
16
- constructor() {
17
- this.validTypes = ["path"];
18
- }
19
16
  draw(data) {
20
17
  const { context, particle, radius } = data;
21
18
  if (!particle.pathData) {
22
19
  return;
23
20
  }
24
- (0, Utils_js_1.drawPath)(context, radius, particle.pathData);
21
+ (0, path_utils_1.drawPath)(context, radius, particle.pathData);
25
22
  }
26
23
  particleInit(_container, particle) {
27
24
  const shape = particle.shapeData;
package/umd/index.js CHANGED
@@ -44,11 +44,13 @@ var __importStar = (this && this.__importStar) || (function () {
44
44
  var __syncRequire = typeof module === "object" && typeof module.exports === "object";
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.loadPathShape = loadPathShape;
47
- function loadPathShape(engine) {
48
- engine.checkVersion("4.0.0-alpha.2");
49
- engine.register(async (e) => {
50
- const { PathDrawer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./PathDrawer.js"))) : new Promise((resolve_1, reject_1) => { require(["./PathDrawer.js"], resolve_1, reject_1); }).then(__importStar));
51
- e.addShape(new PathDrawer());
47
+ async function loadPathShape(engine) {
48
+ engine.checkVersion("4.0.0-alpha.21");
49
+ await engine.register(e => {
50
+ e.addShape(["path"], async () => {
51
+ const { PathDrawer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./PathDrawer.js"))) : new Promise((resolve_1, reject_1) => { require(["./PathDrawer.js"], resolve_1, reject_1); }).then(__importStar));
52
+ return new PathDrawer();
53
+ });
52
54
  });
53
55
  }
54
56
  });
package/237.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 237.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_shape_path=this.webpackChunk_tsparticles_shape_path||[]).push([[237],{237(e,a,s){s.d(a,{PathDrawer:()=>i});var t,r=s(303);!function(e){e.line="line",e.bezier="bezier",e.quadratic="quadratic",e.arc="arc",e.ellipse="ellipse"}(t||(t={}));class i{constructor(){this.validTypes=["path"]}draw(e){const{context:a,particle:s,radius:r}=e;s.pathData&&function(e,a,s){const r=s.segments[0];if(!r)return;const i=r.values[0];if(!i)return;e.moveTo(i.x*a,i.y*a);for(const r of s.segments){const s=r.values[0],i=1,c=2,n=3;if(!s)continue;const l=r.values[i],u=r.values[c],o=r.values[n];switch(r.type){case t.line:e.lineTo(s.x*a,s.y*a);break;case t.bezier:if(!l||!u||!o)break;e.bezierCurveTo(l.x*a,l.y*a,u.x*a,u.y*a,o.x*a,o.y*a);break;case t.quadratic:if(!l||!u)break;e.quadraticCurveTo(l.x*a,l.y*a,u.x*a,u.y*a);break;case t.arc:if(!l||!u)break;e.arc(s.x*a,s.y*a,l.x*a,u.x,u.y);break;case t.ellipse:if(!l||!u||!o)break;e.ellipse(s.x*a,s.y*a,l.x*a,l.y*a,u.x,o.x,o.y)}}if(!s.half)return;for(let r=s.segments.length-1;r>=0;r--){const i=s.segments[r];if(!i)continue;const c=i.values[0],n=1,l=2,u=i.values[n],o=i.values[l];switch(i.type){case t.line:if(!c)break;e.lineTo(c.x*-a,c.y*a);break;case t.bezier:if(!c||!u||!o)break;e.bezierCurveTo(-o.x*a,o.y*a,-u.x*a,u.y*a,c.x*a,c.y*a);break;case t.quadratic:if(!u||!o)break;e.quadraticCurveTo(-u.x*a,u.y*a,-o.x*a,o.y*a);case t.arc:case t.ellipse:}}}(a,r,s.pathData)}particleInit(e,a){const s=a.shapeData;s&&(a.pathData=(0,r.deepExtend)({},s))}}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles Path Shape v4.0.0-alpha.2 by Matteo Bruni */
@@ -1,8 +0,0 @@
1
- export var SegmentType;
2
- (function (SegmentType) {
3
- SegmentType["line"] = "line";
4
- SegmentType["bezier"] = "bezier";
5
- SegmentType["quadratic"] = "quadratic";
6
- SegmentType["arc"] = "arc";
7
- SegmentType["ellipse"] = "ellipse";
8
- })(SegmentType || (SegmentType = {}));
package/browser/Utils.js DELETED
@@ -1,82 +0,0 @@
1
- import { SegmentType } from "./SegmentType.js";
2
- export function drawPath(ctx, radius, path) {
3
- const firstIndex = 0, firstSegment = path.segments[firstIndex];
4
- if (!firstSegment) {
5
- return;
6
- }
7
- const firstValue = firstSegment.values[firstIndex];
8
- if (!firstValue) {
9
- return;
10
- }
11
- ctx.moveTo(firstValue.x * radius, firstValue.y * radius);
12
- for (const segment of path.segments) {
13
- const value = segment.values[firstIndex], index2 = 1, index3 = 2, index4 = 3;
14
- if (!value) {
15
- continue;
16
- }
17
- const segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3], segmentValue4 = segment.values[index4];
18
- switch (segment.type) {
19
- case SegmentType.line:
20
- ctx.lineTo(value.x * radius, value.y * radius);
21
- break;
22
- case SegmentType.bezier:
23
- if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
24
- break;
25
- }
26
- ctx.bezierCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius, segmentValue4.x * radius, segmentValue4.y * radius);
27
- break;
28
- case SegmentType.quadratic:
29
- if (!segmentValue2 || !segmentValue3) {
30
- break;
31
- }
32
- ctx.quadraticCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius);
33
- break;
34
- case SegmentType.arc:
35
- if (!segmentValue2 || !segmentValue3) {
36
- break;
37
- }
38
- ctx.arc(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue3.x, segmentValue3.y);
39
- break;
40
- case SegmentType.ellipse:
41
- if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
42
- break;
43
- }
44
- ctx.ellipse(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x, segmentValue4.x, segmentValue4.y);
45
- }
46
- }
47
- if (!path.half) {
48
- return;
49
- }
50
- const lengthOffset = 1, minLength = 0;
51
- for (let i = path.segments.length - lengthOffset; i >= minLength; i--) {
52
- const segment = path.segments[i];
53
- if (!segment) {
54
- continue;
55
- }
56
- const value = segment.values[firstIndex], index2 = 1, index3 = 2, segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3];
57
- switch (segment.type) {
58
- case SegmentType.line:
59
- if (!value) {
60
- break;
61
- }
62
- ctx.lineTo(value.x * -radius, value.y * radius);
63
- break;
64
- case SegmentType.bezier:
65
- if (!value || !segmentValue2 || !segmentValue3) {
66
- break;
67
- }
68
- ctx.bezierCurveTo(-segmentValue3.x * radius, segmentValue3.y * radius, -segmentValue2.x * radius, segmentValue2.y * radius, value.x * radius, value.y * radius);
69
- break;
70
- case SegmentType.quadratic:
71
- if (!segmentValue2 || !segmentValue3) {
72
- break;
73
- }
74
- ctx.quadraticCurveTo(-segmentValue2.x * radius, segmentValue2.y * radius, -segmentValue3.x * radius, segmentValue3.y * radius);
75
- break;
76
- case SegmentType.arc:
77
- case SegmentType.ellipse:
78
- default:
79
- break;
80
- }
81
- }
82
- }
@@ -1,8 +0,0 @@
1
- export var SegmentType;
2
- (function (SegmentType) {
3
- SegmentType["line"] = "line";
4
- SegmentType["bezier"] = "bezier";
5
- SegmentType["quadratic"] = "quadratic";
6
- SegmentType["arc"] = "arc";
7
- SegmentType["ellipse"] = "ellipse";
8
- })(SegmentType || (SegmentType = {}));
package/cjs/Utils.js DELETED
@@ -1,82 +0,0 @@
1
- import { SegmentType } from "./SegmentType.js";
2
- export function drawPath(ctx, radius, path) {
3
- const firstIndex = 0, firstSegment = path.segments[firstIndex];
4
- if (!firstSegment) {
5
- return;
6
- }
7
- const firstValue = firstSegment.values[firstIndex];
8
- if (!firstValue) {
9
- return;
10
- }
11
- ctx.moveTo(firstValue.x * radius, firstValue.y * radius);
12
- for (const segment of path.segments) {
13
- const value = segment.values[firstIndex], index2 = 1, index3 = 2, index4 = 3;
14
- if (!value) {
15
- continue;
16
- }
17
- const segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3], segmentValue4 = segment.values[index4];
18
- switch (segment.type) {
19
- case SegmentType.line:
20
- ctx.lineTo(value.x * radius, value.y * radius);
21
- break;
22
- case SegmentType.bezier:
23
- if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
24
- break;
25
- }
26
- ctx.bezierCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius, segmentValue4.x * radius, segmentValue4.y * radius);
27
- break;
28
- case SegmentType.quadratic:
29
- if (!segmentValue2 || !segmentValue3) {
30
- break;
31
- }
32
- ctx.quadraticCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius);
33
- break;
34
- case SegmentType.arc:
35
- if (!segmentValue2 || !segmentValue3) {
36
- break;
37
- }
38
- ctx.arc(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue3.x, segmentValue3.y);
39
- break;
40
- case SegmentType.ellipse:
41
- if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
42
- break;
43
- }
44
- ctx.ellipse(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x, segmentValue4.x, segmentValue4.y);
45
- }
46
- }
47
- if (!path.half) {
48
- return;
49
- }
50
- const lengthOffset = 1, minLength = 0;
51
- for (let i = path.segments.length - lengthOffset; i >= minLength; i--) {
52
- const segment = path.segments[i];
53
- if (!segment) {
54
- continue;
55
- }
56
- const value = segment.values[firstIndex], index2 = 1, index3 = 2, segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3];
57
- switch (segment.type) {
58
- case SegmentType.line:
59
- if (!value) {
60
- break;
61
- }
62
- ctx.lineTo(value.x * -radius, value.y * radius);
63
- break;
64
- case SegmentType.bezier:
65
- if (!value || !segmentValue2 || !segmentValue3) {
66
- break;
67
- }
68
- ctx.bezierCurveTo(-segmentValue3.x * radius, segmentValue3.y * radius, -segmentValue2.x * radius, segmentValue2.y * radius, value.x * radius, value.y * radius);
69
- break;
70
- case SegmentType.quadratic:
71
- if (!segmentValue2 || !segmentValue3) {
72
- break;
73
- }
74
- ctx.quadraticCurveTo(-segmentValue2.x * radius, segmentValue2.y * radius, -segmentValue3.x * radius, segmentValue3.y * radius);
75
- break;
76
- case SegmentType.arc:
77
- case SegmentType.ellipse:
78
- default:
79
- break;
80
- }
81
- }
82
- }
@@ -1,8 +0,0 @@
1
- export var SegmentType;
2
- (function (SegmentType) {
3
- SegmentType["line"] = "line";
4
- SegmentType["bezier"] = "bezier";
5
- SegmentType["quadratic"] = "quadratic";
6
- SegmentType["arc"] = "arc";
7
- SegmentType["ellipse"] = "ellipse";
8
- })(SegmentType || (SegmentType = {}));
package/esm/Utils.js DELETED
@@ -1,82 +0,0 @@
1
- import { SegmentType } from "./SegmentType.js";
2
- export function drawPath(ctx, radius, path) {
3
- const firstIndex = 0, firstSegment = path.segments[firstIndex];
4
- if (!firstSegment) {
5
- return;
6
- }
7
- const firstValue = firstSegment.values[firstIndex];
8
- if (!firstValue) {
9
- return;
10
- }
11
- ctx.moveTo(firstValue.x * radius, firstValue.y * radius);
12
- for (const segment of path.segments) {
13
- const value = segment.values[firstIndex], index2 = 1, index3 = 2, index4 = 3;
14
- if (!value) {
15
- continue;
16
- }
17
- const segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3], segmentValue4 = segment.values[index4];
18
- switch (segment.type) {
19
- case SegmentType.line:
20
- ctx.lineTo(value.x * radius, value.y * radius);
21
- break;
22
- case SegmentType.bezier:
23
- if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
24
- break;
25
- }
26
- ctx.bezierCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius, segmentValue4.x * radius, segmentValue4.y * radius);
27
- break;
28
- case SegmentType.quadratic:
29
- if (!segmentValue2 || !segmentValue3) {
30
- break;
31
- }
32
- ctx.quadraticCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius);
33
- break;
34
- case SegmentType.arc:
35
- if (!segmentValue2 || !segmentValue3) {
36
- break;
37
- }
38
- ctx.arc(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue3.x, segmentValue3.y);
39
- break;
40
- case SegmentType.ellipse:
41
- if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
42
- break;
43
- }
44
- ctx.ellipse(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x, segmentValue4.x, segmentValue4.y);
45
- }
46
- }
47
- if (!path.half) {
48
- return;
49
- }
50
- const lengthOffset = 1, minLength = 0;
51
- for (let i = path.segments.length - lengthOffset; i >= minLength; i--) {
52
- const segment = path.segments[i];
53
- if (!segment) {
54
- continue;
55
- }
56
- const value = segment.values[firstIndex], index2 = 1, index3 = 2, segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3];
57
- switch (segment.type) {
58
- case SegmentType.line:
59
- if (!value) {
60
- break;
61
- }
62
- ctx.lineTo(value.x * -radius, value.y * radius);
63
- break;
64
- case SegmentType.bezier:
65
- if (!value || !segmentValue2 || !segmentValue3) {
66
- break;
67
- }
68
- ctx.bezierCurveTo(-segmentValue3.x * radius, segmentValue3.y * radius, -segmentValue2.x * radius, segmentValue2.y * radius, value.x * radius, value.y * radius);
69
- break;
70
- case SegmentType.quadratic:
71
- if (!segmentValue2 || !segmentValue3) {
72
- break;
73
- }
74
- ctx.quadraticCurveTo(-segmentValue2.x * radius, segmentValue2.y * radius, -segmentValue3.x * radius, segmentValue3.y * radius);
75
- break;
76
- case SegmentType.arc:
77
- case SegmentType.ellipse:
78
- default:
79
- break;
80
- }
81
- }
82
- }
@@ -1 +0,0 @@
1
- /*! tsParticles Path Shape v4.0.0-alpha.2 by Matteo Bruni */
@@ -1,10 +0,0 @@
1
- import type { ICoordinates, IShapeValues } from "@tsparticles/engine";
2
- import type { SegmentType } from "./SegmentType.js";
3
- export interface IPathData extends IShapeValues {
4
- half: boolean;
5
- segments: ISegmentData[];
6
- }
7
- export interface ISegmentData {
8
- type: SegmentType;
9
- values: ICoordinates[];
10
- }
@@ -1,7 +0,0 @@
1
- export declare enum SegmentType {
2
- line = "line",
3
- bezier = "bezier",
4
- quadratic = "quadratic",
5
- arc = "arc",
6
- ellipse = "ellipse"
7
- }
package/types/Utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { IPathData } from "./IPathData.js";
2
- export declare function drawPath(ctx: CanvasRenderingContext2D, radius: number, path: IPathData): void;
@@ -1,21 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SegmentType = void 0;
13
- var SegmentType;
14
- (function (SegmentType) {
15
- SegmentType["line"] = "line";
16
- SegmentType["bezier"] = "bezier";
17
- SegmentType["quadratic"] = "quadratic";
18
- SegmentType["arc"] = "arc";
19
- SegmentType["ellipse"] = "ellipse";
20
- })(SegmentType || (exports.SegmentType = SegmentType = {}));
21
- });
package/umd/Utils.js DELETED
@@ -1,95 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./SegmentType.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.drawPath = drawPath;
13
- const SegmentType_js_1 = require("./SegmentType.js");
14
- function drawPath(ctx, radius, path) {
15
- const firstIndex = 0, firstSegment = path.segments[firstIndex];
16
- if (!firstSegment) {
17
- return;
18
- }
19
- const firstValue = firstSegment.values[firstIndex];
20
- if (!firstValue) {
21
- return;
22
- }
23
- ctx.moveTo(firstValue.x * radius, firstValue.y * radius);
24
- for (const segment of path.segments) {
25
- const value = segment.values[firstIndex], index2 = 1, index3 = 2, index4 = 3;
26
- if (!value) {
27
- continue;
28
- }
29
- const segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3], segmentValue4 = segment.values[index4];
30
- switch (segment.type) {
31
- case SegmentType_js_1.SegmentType.line:
32
- ctx.lineTo(value.x * radius, value.y * radius);
33
- break;
34
- case SegmentType_js_1.SegmentType.bezier:
35
- if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
36
- break;
37
- }
38
- ctx.bezierCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius, segmentValue4.x * radius, segmentValue4.y * radius);
39
- break;
40
- case SegmentType_js_1.SegmentType.quadratic:
41
- if (!segmentValue2 || !segmentValue3) {
42
- break;
43
- }
44
- ctx.quadraticCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius);
45
- break;
46
- case SegmentType_js_1.SegmentType.arc:
47
- if (!segmentValue2 || !segmentValue3) {
48
- break;
49
- }
50
- ctx.arc(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue3.x, segmentValue3.y);
51
- break;
52
- case SegmentType_js_1.SegmentType.ellipse:
53
- if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
54
- break;
55
- }
56
- ctx.ellipse(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x, segmentValue4.x, segmentValue4.y);
57
- }
58
- }
59
- if (!path.half) {
60
- return;
61
- }
62
- const lengthOffset = 1, minLength = 0;
63
- for (let i = path.segments.length - lengthOffset; i >= minLength; i--) {
64
- const segment = path.segments[i];
65
- if (!segment) {
66
- continue;
67
- }
68
- const value = segment.values[firstIndex], index2 = 1, index3 = 2, segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3];
69
- switch (segment.type) {
70
- case SegmentType_js_1.SegmentType.line:
71
- if (!value) {
72
- break;
73
- }
74
- ctx.lineTo(value.x * -radius, value.y * radius);
75
- break;
76
- case SegmentType_js_1.SegmentType.bezier:
77
- if (!value || !segmentValue2 || !segmentValue3) {
78
- break;
79
- }
80
- ctx.bezierCurveTo(-segmentValue3.x * radius, segmentValue3.y * radius, -segmentValue2.x * radius, segmentValue2.y * radius, value.x * radius, value.y * radius);
81
- break;
82
- case SegmentType_js_1.SegmentType.quadratic:
83
- if (!segmentValue2 || !segmentValue3) {
84
- break;
85
- }
86
- ctx.quadraticCurveTo(-segmentValue2.x * radius, segmentValue2.y * radius, -segmentValue3.x * radius, segmentValue3.y * radius);
87
- break;
88
- case SegmentType_js_1.SegmentType.arc:
89
- case SegmentType_js_1.SegmentType.ellipse:
90
- default:
91
- break;
92
- }
93
- }
94
- }
95
- });
File without changes
File without changes
File without changes
File without changes