@tsparticles/shape-path 3.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.
@@ -0,0 +1,167 @@
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
+ * v3.0.0-alpha.0
8
+ */
9
+ (function webpackUniversalModuleDefinition(root, factory) {
10
+ if(typeof exports === 'object' && typeof module === 'object')
11
+ module.exports = factory(require("@tsparticles/engine"));
12
+ else if(typeof define === 'function' && define.amd)
13
+ define(["@tsparticles/engine"], factory);
14
+ else {
15
+ var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
16
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
+ }
18
+ })(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
19
+ return /******/ (() => { // webpackBootstrap
20
+ /******/ "use strict";
21
+ /******/ var __webpack_modules__ = ({
22
+
23
+ /***/ 533:
24
+ /***/ ((module) => {
25
+
26
+ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
27
+
28
+ /***/ })
29
+
30
+ /******/ });
31
+ /************************************************************************/
32
+ /******/ // The module cache
33
+ /******/ var __webpack_module_cache__ = {};
34
+ /******/
35
+ /******/ // The require function
36
+ /******/ function __webpack_require__(moduleId) {
37
+ /******/ // Check if module is in cache
38
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
39
+ /******/ if (cachedModule !== undefined) {
40
+ /******/ return cachedModule.exports;
41
+ /******/ }
42
+ /******/ // Create a new module (and put it into the cache)
43
+ /******/ var module = __webpack_module_cache__[moduleId] = {
44
+ /******/ // no module.id needed
45
+ /******/ // no module.loaded needed
46
+ /******/ exports: {}
47
+ /******/ };
48
+ /******/
49
+ /******/ // Execute the module function
50
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
51
+ /******/
52
+ /******/ // Return the exports of the module
53
+ /******/ return module.exports;
54
+ /******/ }
55
+ /******/
56
+ /************************************************************************/
57
+ /******/ /* webpack/runtime/define property getters */
58
+ /******/ (() => {
59
+ /******/ // define getter functions for harmony exports
60
+ /******/ __webpack_require__.d = (exports, definition) => {
61
+ /******/ for(var key in definition) {
62
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
63
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
64
+ /******/ }
65
+ /******/ }
66
+ /******/ };
67
+ /******/ })();
68
+ /******/
69
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
70
+ /******/ (() => {
71
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
72
+ /******/ })();
73
+ /******/
74
+ /******/ /* webpack/runtime/make namespace object */
75
+ /******/ (() => {
76
+ /******/ // define __esModule on exports
77
+ /******/ __webpack_require__.r = (exports) => {
78
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
79
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
80
+ /******/ }
81
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
82
+ /******/ };
83
+ /******/ })();
84
+ /******/
85
+ /************************************************************************/
86
+ var __webpack_exports__ = {};
87
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
88
+ (() => {
89
+ // ESM COMPAT FLAG
90
+ __webpack_require__.r(__webpack_exports__);
91
+
92
+ // EXPORTS
93
+ __webpack_require__.d(__webpack_exports__, {
94
+ "loadPathShape": () => (/* binding */ loadPathShape)
95
+ });
96
+
97
+ // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
98
+ var engine_root_window_ = __webpack_require__(533);
99
+ ;// CONCATENATED MODULE: ./dist/browser/Utils.js
100
+ function drawPath(ctx, radius, path) {
101
+ ctx.moveTo(path.segments[0].values[0].x * radius, path.segments[0].values[0].y * radius);
102
+ for (let i = 0; i < path.segments.length; i++) {
103
+ const segment = path.segments[i];
104
+ switch (segment.type) {
105
+ case "line":
106
+ ctx.lineTo(segment.values[0].x * radius, segment.values[0].y * radius);
107
+ break;
108
+ case "bezier":
109
+ ctx.bezierCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius, segment.values[3].x * radius, segment.values[3].y * radius);
110
+ break;
111
+ case "quadratic":
112
+ ctx.quadraticCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius);
113
+ break;
114
+ case "arc":
115
+ ctx.arc(segment.values[0].x * radius, segment.values[0].y * radius, segment.values[1].x * radius, segment.values[2].x, segment.values[2].y);
116
+ break;
117
+ case "ellipse":
118
+ ctx.ellipse(segment.values[0].x * radius, segment.values[0].y * radius, segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x, segment.values[3].x, segment.values[3].y);
119
+ }
120
+ }
121
+ if (!path.half) {
122
+ return;
123
+ }
124
+ for (let i = path.segments.length - 1; i >= 0; i--) {
125
+ const segment = path.segments[i];
126
+ switch (segment.type) {
127
+ case "line":
128
+ ctx.lineTo(segment.values[0].x * -radius, segment.values[0].y * radius);
129
+ break;
130
+ case "bezier":
131
+ ctx.bezierCurveTo(-segment.values[2].x * radius, segment.values[2].y * radius, -segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[0].x * radius, segment.values[0].y * radius);
132
+ break;
133
+ case "quadratic":
134
+ ctx.quadraticCurveTo(-segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[2].x * radius, segment.values[2].y * radius);
135
+ break;
136
+ }
137
+ }
138
+ }
139
+ ;// CONCATENATED MODULE: ./dist/browser/PathDrawer.js
140
+
141
+
142
+ class PathDrawer {
143
+ draw(context, particle, radius) {
144
+ if (!particle.pathData) {
145
+ return;
146
+ }
147
+ drawPath(context, radius, particle.pathData);
148
+ }
149
+ particleInit(container, particle) {
150
+ const shape = particle.shapeData;
151
+ if (!shape) {
152
+ return;
153
+ }
154
+ particle.pathData = (0,engine_root_window_.deepExtend)({}, shape);
155
+ }
156
+ }
157
+ ;// CONCATENATED MODULE: ./dist/browser/index.js
158
+
159
+ async function loadPathShape(engine) {
160
+ await engine.addShape("path", new PathDrawer());
161
+ }
162
+ })();
163
+
164
+ /******/ return __webpack_exports__;
165
+ /******/ })()
166
+ ;
167
+ });
@@ -0,0 +1,2 @@
1
+ /*! For license information please see tsparticles.shape.path.min.js.LICENSE.txt */
2
+ !function(e,a){if("object"==typeof exports&&"object"==typeof module)module.exports=a(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],a);else{var s="object"==typeof exports?a(require("@tsparticles/engine")):a(e.window);for(var t in s)("object"==typeof exports?exports:e)[t]=s[t]}}(this,(e=>(()=>{"use strict";var a={533:a=>{a.exports=e}},s={};function t(e){var r=s[e];if(void 0!==r)return r.exports;var l=s[e]={exports:{}};return a[e](l,l.exports,t),l.exports}t.d=(e,a)=>{for(var s in a)t.o(a,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:a[s]})},t.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{t.r(r),t.d(r,{loadPathShape:()=>s});var e=t(533);class a{draw(e,a,s){a.pathData&&function(e,a,s){e.moveTo(s.segments[0].values[0].x*a,s.segments[0].values[0].y*a);for(let t=0;t<s.segments.length;t++){const r=s.segments[t];switch(r.type){case"line":e.lineTo(r.values[0].x*a,r.values[0].y*a);break;case"bezier":e.bezierCurveTo(r.values[1].x*a,r.values[1].y*a,r.values[2].x*a,r.values[2].y*a,r.values[3].x*a,r.values[3].y*a);break;case"quadratic":e.quadraticCurveTo(r.values[1].x*a,r.values[1].y*a,r.values[2].x*a,r.values[2].y*a);break;case"arc":e.arc(r.values[0].x*a,r.values[0].y*a,r.values[1].x*a,r.values[2].x,r.values[2].y);break;case"ellipse":e.ellipse(r.values[0].x*a,r.values[0].y*a,r.values[1].x*a,r.values[1].y*a,r.values[2].x,r.values[3].x,r.values[3].y)}}if(s.half)for(let t=s.segments.length-1;t>=0;t--){const r=s.segments[t];switch(r.type){case"line":e.lineTo(r.values[0].x*-a,r.values[0].y*a);break;case"bezier":e.bezierCurveTo(-r.values[2].x*a,r.values[2].y*a,-r.values[1].x*a,r.values[1].y*a,-r.values[0].x*a,r.values[0].y*a);break;case"quadratic":e.quadraticCurveTo(-r.values[1].x*a,r.values[1].y*a,-r.values[2].x*a,r.values[2].y*a)}}}(e,s,a.pathData)}particleInit(a,s){const t=s.shapeData;t&&(s.pathData=(0,e.deepExtend)({},t))}}async function s(e){await e.addShape("path",new a)}})(),r})()));
@@ -0,0 +1,8 @@
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
+ * v3.0.0-alpha.0
8
+ */
@@ -0,0 +1,10 @@
1
+ import type { ICoordinates, IShapeValues } from "@tsparticles/engine";
2
+ import type { SegmentType } from "./SegmentType";
3
+ export interface IPathData extends IShapeValues {
4
+ half: boolean;
5
+ segments: ISegmentData[];
6
+ }
7
+ export interface ISegmentData {
8
+ type: SegmentType;
9
+ values: ICoordinates[];
10
+ }
@@ -0,0 +1,6 @@
1
+ import type { Container, IShapeDrawer } from "@tsparticles/engine";
2
+ import type { PathParticle } from "./PathParticle";
3
+ export declare class PathDrawer implements IShapeDrawer {
4
+ draw(context: CanvasRenderingContext2D, particle: PathParticle, radius: number): void;
5
+ particleInit(container: Container, particle: PathParticle): void;
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { IPathData } from "./IPathData";
2
+ import type { Particle } from "@tsparticles/engine";
3
+ export type PathParticle = Particle & {
4
+ pathData?: IPathData;
5
+ };
@@ -0,0 +1,7 @@
1
+ export declare const enum SegmentType {
2
+ line = "line",
3
+ bezier = "bezier",
4
+ quadratic = "quadratic",
5
+ arc = "arc",
6
+ ellipse = "ellipse"
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { IPathData } from "./IPathData";
2
+ export declare function drawPath(ctx: CanvasRenderingContext2D, radius: number, path: IPathData): void;
@@ -0,0 +1,2 @@
1
+ import type { Engine } from "@tsparticles/engine";
2
+ export declare function loadPathShape(engine: Engine): Promise<void>;
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,31 @@
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", "@tsparticles/engine", "./Utils"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PathDrawer = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const Utils_1 = require("./Utils");
15
+ class PathDrawer {
16
+ draw(context, particle, radius) {
17
+ if (!particle.pathData) {
18
+ return;
19
+ }
20
+ (0, Utils_1.drawPath)(context, radius, particle.pathData);
21
+ }
22
+ particleInit(container, particle) {
23
+ const shape = particle.shapeData;
24
+ if (!shape) {
25
+ return;
26
+ }
27
+ particle.pathData = (0, engine_1.deepExtend)({}, shape);
28
+ }
29
+ }
30
+ exports.PathDrawer = PathDrawer;
31
+ });
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,12 @@
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
+ });
package/umd/Utils.js ADDED
@@ -0,0 +1,53 @@
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.drawPath = void 0;
13
+ function drawPath(ctx, radius, path) {
14
+ ctx.moveTo(path.segments[0].values[0].x * radius, path.segments[0].values[0].y * radius);
15
+ for (let i = 0; i < path.segments.length; i++) {
16
+ const segment = path.segments[i];
17
+ switch (segment.type) {
18
+ case "line":
19
+ ctx.lineTo(segment.values[0].x * radius, segment.values[0].y * radius);
20
+ break;
21
+ case "bezier":
22
+ ctx.bezierCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius, segment.values[3].x * radius, segment.values[3].y * radius);
23
+ break;
24
+ case "quadratic":
25
+ ctx.quadraticCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius);
26
+ break;
27
+ case "arc":
28
+ ctx.arc(segment.values[0].x * radius, segment.values[0].y * radius, segment.values[1].x * radius, segment.values[2].x, segment.values[2].y);
29
+ break;
30
+ case "ellipse":
31
+ ctx.ellipse(segment.values[0].x * radius, segment.values[0].y * radius, segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x, segment.values[3].x, segment.values[3].y);
32
+ }
33
+ }
34
+ if (!path.half) {
35
+ return;
36
+ }
37
+ for (let i = path.segments.length - 1; i >= 0; i--) {
38
+ const segment = path.segments[i];
39
+ switch (segment.type) {
40
+ case "line":
41
+ ctx.lineTo(segment.values[0].x * -radius, segment.values[0].y * radius);
42
+ break;
43
+ case "bezier":
44
+ ctx.bezierCurveTo(-segment.values[2].x * radius, segment.values[2].y * radius, -segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[0].x * radius, segment.values[0].y * radius);
45
+ break;
46
+ case "quadratic":
47
+ ctx.quadraticCurveTo(-segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[2].x * radius, segment.values[2].y * radius);
48
+ break;
49
+ }
50
+ }
51
+ }
52
+ exports.drawPath = drawPath;
53
+ });
package/umd/index.js ADDED
@@ -0,0 +1,18 @@
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", "./PathDrawer"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.loadPathShape = void 0;
13
+ const PathDrawer_1 = require("./PathDrawer");
14
+ async function loadPathShape(engine) {
15
+ await engine.addShape("path", new PathDrawer_1.PathDrawer());
16
+ }
17
+ exports.loadPathShape = loadPathShape;
18
+ });