@tsparticles/path-utils 4.0.0-alpha.8

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matteo Bruni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ [![banner](https://particles.js.org/images/banner3.png)](https://particles.js.org)
2
+
3
+ # tsParticles Path Utils Library
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/path-utils/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/path-utils)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/path-utils.svg)](https://www.npmjs.com/package/@tsparticles/path-utils)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/path-utils)](https://www.npmjs.com/package/@tsparticles/path-utils) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/tsparticles/tsparticles) path plugin for path utils movement.
10
+
11
+ ## How to use it
12
+
13
+ ### CDN / Vanilla JS / jQuery
14
+
15
+ The CDN/Vanilla version JS has one required file in vanilla configuration:
16
+
17
+ Including the `tsparticles.path.utils.min.js` file will export the function to load the path plugin:
18
+
19
+ ```text
20
+ loadPathUtilsPath
21
+ ```
22
+
23
+ ### Usage
24
+
25
+ Once the scripts are loaded you can set up `tsParticles` and the path plugin like this:
26
+
27
+ ```javascript
28
+ (async () => {
29
+ await loadPathUtilsPath(tsParticles);
30
+
31
+ await tsParticles.load({
32
+ id: "tsparticles",
33
+ options: {
34
+ /* options */
35
+ },
36
+ });
37
+ })();
38
+ ```
39
+
40
+ ### ESM / CommonJS
41
+
42
+ This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
+
44
+ ```shell
45
+ $ npm install @tsparticles/path-utils
46
+ ```
47
+
48
+ or
49
+
50
+ ```shell
51
+ $ yarn add @tsparticles/path-utils
52
+ ```
53
+
54
+ Then you need to import it in the app, like this:
55
+
56
+ ```javascript
57
+ const { tsParticles } = require("@tsparticles/engine");
58
+ const { loadPathUtilsPath } = require("@tsparticles/path-utils");
59
+
60
+ (async () => {
61
+ await loadPathUtilsPath(tsParticles);
62
+ })();
63
+ ```
64
+
65
+ or
66
+
67
+ ```javascript
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadPathUtilsPath } from "@tsparticles/path-utils";
70
+
71
+ (async () => {
72
+ await loadPathUtilsPath(tsParticles);
73
+ })();
74
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export var SegmentType;
2
+ (function (SegmentType) {
3
+ SegmentType["move"] = "move";
4
+ SegmentType["line"] = "line";
5
+ SegmentType["bezier"] = "bezier";
6
+ SegmentType["quadratic"] = "quadratic";
7
+ SegmentType["arc"] = "arc";
8
+ SegmentType["ellipse"] = "ellipse";
9
+ })(SegmentType || (SegmentType = {}));
@@ -0,0 +1,87 @@
1
+ import { SegmentType } from "./SegmentType.js";
2
+ const firstIndex = 0, index2 = 1, index3 = 2, index4 = 3;
3
+ export function drawPath(ctx, radius, path) {
4
+ const firstSegment = path.segments[firstIndex];
5
+ if (!firstSegment) {
6
+ return;
7
+ }
8
+ const firstValue = firstSegment.values[firstIndex];
9
+ if (!firstValue) {
10
+ return;
11
+ }
12
+ ctx.moveTo(firstValue.x * radius, firstValue.y * radius);
13
+ for (const segment of path.segments) {
14
+ const value = segment.values[firstIndex];
15
+ if (!value) {
16
+ continue;
17
+ }
18
+ const segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3], segmentValue4 = segment.values[index4];
19
+ switch (segment.type) {
20
+ case SegmentType.move:
21
+ ctx.moveTo(value.x * radius, value.y * radius);
22
+ break;
23
+ case SegmentType.line:
24
+ ctx.lineTo(value.x * radius, value.y * radius);
25
+ break;
26
+ case SegmentType.bezier:
27
+ if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
28
+ continue;
29
+ }
30
+ ctx.bezierCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius, segmentValue4.x * radius, segmentValue4.y * radius);
31
+ break;
32
+ case SegmentType.quadratic:
33
+ if (!segmentValue2 || !segmentValue3) {
34
+ continue;
35
+ }
36
+ ctx.quadraticCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius);
37
+ break;
38
+ case SegmentType.arc:
39
+ if (!segmentValue2 || !segmentValue3) {
40
+ continue;
41
+ }
42
+ ctx.arc(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue3.x, segmentValue3.y);
43
+ break;
44
+ case SegmentType.ellipse:
45
+ if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
46
+ continue;
47
+ }
48
+ ctx.ellipse(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x, segmentValue4.x, segmentValue4.y);
49
+ break;
50
+ }
51
+ }
52
+ if (!path.half) {
53
+ return;
54
+ }
55
+ const lengthOffset = 1, minLength = 0;
56
+ for (let i = path.segments.length - lengthOffset; i >= minLength; i--) {
57
+ const segment = path.segments[i];
58
+ if (!segment) {
59
+ continue;
60
+ }
61
+ const value = segment.values[firstIndex], index2 = 1, index3 = 2, segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3];
62
+ switch (segment.type) {
63
+ case SegmentType.line:
64
+ if (!value) {
65
+ break;
66
+ }
67
+ ctx.lineTo(value.x * -radius, value.y * radius);
68
+ break;
69
+ case SegmentType.bezier:
70
+ if (!value || !segmentValue2 || !segmentValue3) {
71
+ break;
72
+ }
73
+ ctx.bezierCurveTo(-segmentValue3.x * radius, segmentValue3.y * radius, -segmentValue2.x * radius, segmentValue2.y * radius, -value.x * radius, value.y * radius);
74
+ break;
75
+ case SegmentType.quadratic:
76
+ if (!segmentValue2 || !segmentValue3) {
77
+ break;
78
+ }
79
+ ctx.quadraticCurveTo(-segmentValue2.x * radius, segmentValue2.y * radius, -segmentValue3.x * radius, segmentValue3.y * radius);
80
+ break;
81
+ case SegmentType.arc:
82
+ case SegmentType.ellipse:
83
+ default:
84
+ break;
85
+ }
86
+ }
87
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./SegmentType.js";
2
+ export * from "./Utils.js";
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export var SegmentType;
2
+ (function (SegmentType) {
3
+ SegmentType["move"] = "move";
4
+ SegmentType["line"] = "line";
5
+ SegmentType["bezier"] = "bezier";
6
+ SegmentType["quadratic"] = "quadratic";
7
+ SegmentType["arc"] = "arc";
8
+ SegmentType["ellipse"] = "ellipse";
9
+ })(SegmentType || (SegmentType = {}));
package/cjs/Utils.js ADDED
@@ -0,0 +1,87 @@
1
+ import { SegmentType } from "./SegmentType.js";
2
+ const firstIndex = 0, index2 = 1, index3 = 2, index4 = 3;
3
+ export function drawPath(ctx, radius, path) {
4
+ const firstSegment = path.segments[firstIndex];
5
+ if (!firstSegment) {
6
+ return;
7
+ }
8
+ const firstValue = firstSegment.values[firstIndex];
9
+ if (!firstValue) {
10
+ return;
11
+ }
12
+ ctx.moveTo(firstValue.x * radius, firstValue.y * radius);
13
+ for (const segment of path.segments) {
14
+ const value = segment.values[firstIndex];
15
+ if (!value) {
16
+ continue;
17
+ }
18
+ const segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3], segmentValue4 = segment.values[index4];
19
+ switch (segment.type) {
20
+ case SegmentType.move:
21
+ ctx.moveTo(value.x * radius, value.y * radius);
22
+ break;
23
+ case SegmentType.line:
24
+ ctx.lineTo(value.x * radius, value.y * radius);
25
+ break;
26
+ case SegmentType.bezier:
27
+ if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
28
+ continue;
29
+ }
30
+ ctx.bezierCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius, segmentValue4.x * radius, segmentValue4.y * radius);
31
+ break;
32
+ case SegmentType.quadratic:
33
+ if (!segmentValue2 || !segmentValue3) {
34
+ continue;
35
+ }
36
+ ctx.quadraticCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius);
37
+ break;
38
+ case SegmentType.arc:
39
+ if (!segmentValue2 || !segmentValue3) {
40
+ continue;
41
+ }
42
+ ctx.arc(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue3.x, segmentValue3.y);
43
+ break;
44
+ case SegmentType.ellipse:
45
+ if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
46
+ continue;
47
+ }
48
+ ctx.ellipse(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x, segmentValue4.x, segmentValue4.y);
49
+ break;
50
+ }
51
+ }
52
+ if (!path.half) {
53
+ return;
54
+ }
55
+ const lengthOffset = 1, minLength = 0;
56
+ for (let i = path.segments.length - lengthOffset; i >= minLength; i--) {
57
+ const segment = path.segments[i];
58
+ if (!segment) {
59
+ continue;
60
+ }
61
+ const value = segment.values[firstIndex], index2 = 1, index3 = 2, segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3];
62
+ switch (segment.type) {
63
+ case SegmentType.line:
64
+ if (!value) {
65
+ break;
66
+ }
67
+ ctx.lineTo(value.x * -radius, value.y * radius);
68
+ break;
69
+ case SegmentType.bezier:
70
+ if (!value || !segmentValue2 || !segmentValue3) {
71
+ break;
72
+ }
73
+ ctx.bezierCurveTo(-segmentValue3.x * radius, segmentValue3.y * radius, -segmentValue2.x * radius, segmentValue2.y * radius, -value.x * radius, value.y * radius);
74
+ break;
75
+ case SegmentType.quadratic:
76
+ if (!segmentValue2 || !segmentValue3) {
77
+ break;
78
+ }
79
+ ctx.quadraticCurveTo(-segmentValue2.x * radius, segmentValue2.y * radius, -segmentValue3.x * radius, segmentValue3.y * radius);
80
+ break;
81
+ case SegmentType.arc:
82
+ case SegmentType.ellipse:
83
+ default:
84
+ break;
85
+ }
86
+ }
87
+ }
package/cjs/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./SegmentType.js";
2
+ export * from "./Utils.js";
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export var SegmentType;
2
+ (function (SegmentType) {
3
+ SegmentType["move"] = "move";
4
+ SegmentType["line"] = "line";
5
+ SegmentType["bezier"] = "bezier";
6
+ SegmentType["quadratic"] = "quadratic";
7
+ SegmentType["arc"] = "arc";
8
+ SegmentType["ellipse"] = "ellipse";
9
+ })(SegmentType || (SegmentType = {}));
package/esm/Utils.js ADDED
@@ -0,0 +1,87 @@
1
+ import { SegmentType } from "./SegmentType.js";
2
+ const firstIndex = 0, index2 = 1, index3 = 2, index4 = 3;
3
+ export function drawPath(ctx, radius, path) {
4
+ const firstSegment = path.segments[firstIndex];
5
+ if (!firstSegment) {
6
+ return;
7
+ }
8
+ const firstValue = firstSegment.values[firstIndex];
9
+ if (!firstValue) {
10
+ return;
11
+ }
12
+ ctx.moveTo(firstValue.x * radius, firstValue.y * radius);
13
+ for (const segment of path.segments) {
14
+ const value = segment.values[firstIndex];
15
+ if (!value) {
16
+ continue;
17
+ }
18
+ const segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3], segmentValue4 = segment.values[index4];
19
+ switch (segment.type) {
20
+ case SegmentType.move:
21
+ ctx.moveTo(value.x * radius, value.y * radius);
22
+ break;
23
+ case SegmentType.line:
24
+ ctx.lineTo(value.x * radius, value.y * radius);
25
+ break;
26
+ case SegmentType.bezier:
27
+ if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
28
+ continue;
29
+ }
30
+ ctx.bezierCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius, segmentValue4.x * radius, segmentValue4.y * radius);
31
+ break;
32
+ case SegmentType.quadratic:
33
+ if (!segmentValue2 || !segmentValue3) {
34
+ continue;
35
+ }
36
+ ctx.quadraticCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius);
37
+ break;
38
+ case SegmentType.arc:
39
+ if (!segmentValue2 || !segmentValue3) {
40
+ continue;
41
+ }
42
+ ctx.arc(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue3.x, segmentValue3.y);
43
+ break;
44
+ case SegmentType.ellipse:
45
+ if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
46
+ continue;
47
+ }
48
+ ctx.ellipse(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x, segmentValue4.x, segmentValue4.y);
49
+ break;
50
+ }
51
+ }
52
+ if (!path.half) {
53
+ return;
54
+ }
55
+ const lengthOffset = 1, minLength = 0;
56
+ for (let i = path.segments.length - lengthOffset; i >= minLength; i--) {
57
+ const segment = path.segments[i];
58
+ if (!segment) {
59
+ continue;
60
+ }
61
+ const value = segment.values[firstIndex], index2 = 1, index3 = 2, segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3];
62
+ switch (segment.type) {
63
+ case SegmentType.line:
64
+ if (!value) {
65
+ break;
66
+ }
67
+ ctx.lineTo(value.x * -radius, value.y * radius);
68
+ break;
69
+ case SegmentType.bezier:
70
+ if (!value || !segmentValue2 || !segmentValue3) {
71
+ break;
72
+ }
73
+ ctx.bezierCurveTo(-segmentValue3.x * radius, segmentValue3.y * radius, -segmentValue2.x * radius, segmentValue2.y * radius, -value.x * radius, value.y * radius);
74
+ break;
75
+ case SegmentType.quadratic:
76
+ if (!segmentValue2 || !segmentValue3) {
77
+ break;
78
+ }
79
+ ctx.quadraticCurveTo(-segmentValue2.x * radius, segmentValue2.y * radius, -segmentValue3.x * radius, segmentValue3.y * radius);
80
+ break;
81
+ case SegmentType.arc:
82
+ case SegmentType.ellipse:
83
+ default:
84
+ break;
85
+ }
86
+ }
87
+ }
package/esm/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./SegmentType.js";
2
+ export * from "./Utils.js";
@@ -0,0 +1 @@
1
+ { "type": "module" }
package/package.json ADDED
@@ -0,0 +1,109 @@
1
+ {
2
+ "name": "@tsparticles/path-utils",
3
+ "version": "4.0.0-alpha.8",
4
+ "description": "tsParticles path utils library",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/tsparticles/tsparticles.git",
9
+ "directory": "utils/pathUtils"
10
+ },
11
+ "keywords": [
12
+ "front-end",
13
+ "frontend",
14
+ "tsparticles",
15
+ "particles.js",
16
+ "particlesjs",
17
+ "particles",
18
+ "particle",
19
+ "canvas",
20
+ "jsparticles",
21
+ "xparticles",
22
+ "particles-js",
23
+ "particles-bg",
24
+ "particles-bg-vue",
25
+ "particles-ts",
26
+ "particles.ts",
27
+ "react-particles-js",
28
+ "react-particles.js",
29
+ "react-particles",
30
+ "react",
31
+ "reactjs",
32
+ "vue-particles",
33
+ "ngx-particles",
34
+ "angular-particles",
35
+ "particleground",
36
+ "vue",
37
+ "vuejs",
38
+ "preact",
39
+ "preactjs",
40
+ "jquery",
41
+ "angularjs",
42
+ "angular",
43
+ "typescript",
44
+ "javascript",
45
+ "animation",
46
+ "web",
47
+ "html5",
48
+ "web-design",
49
+ "webdesign",
50
+ "css",
51
+ "html",
52
+ "css3",
53
+ "animated",
54
+ "background",
55
+ "confetti",
56
+ "canvas",
57
+ "fireworks",
58
+ "fireworks-js",
59
+ "confetti-js",
60
+ "confettijs",
61
+ "fireworksjs",
62
+ "canvas-confetti",
63
+ "tsparticles-plugin"
64
+ ],
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "author": "Matteo Bruni <matteo.bruni@me.com>",
69
+ "license": "MIT",
70
+ "bugs": {
71
+ "url": "https://github.com/tsparticles/tsparticles/issues"
72
+ },
73
+ "funding": [
74
+ {
75
+ "type": "github",
76
+ "url": "https://github.com/sponsors/matteobruni"
77
+ },
78
+ {
79
+ "type": "github",
80
+ "url": "https://github.com/sponsors/tsparticles"
81
+ },
82
+ {
83
+ "type": "buymeacoffee",
84
+ "url": "https://www.buymeacoffee.com/matteobruni"
85
+ }
86
+ ],
87
+ "sideEffects": false,
88
+ "jsdelivr": "tsparticles.path.utils.min.js",
89
+ "unpkg": "tsparticles.path.utils.min.js",
90
+ "browser": "browser/index.js",
91
+ "main": "cjs/index.js",
92
+ "module": "esm/index.js",
93
+ "types": "types/index.d.ts",
94
+ "exports": {
95
+ ".": {
96
+ "types": "./types/index.d.ts",
97
+ "browser": "./browser/index.js",
98
+ "import": "./esm/index.js",
99
+ "require": "./cjs/index.js",
100
+ "umd": "./umd/index.js",
101
+ "default": "./cjs/index.js"
102
+ },
103
+ "./package.json": "./package.json"
104
+ },
105
+ "dependencies": {
106
+ "@tsparticles/engine": "4.0.0-alpha.8"
107
+ },
108
+ "type": "module"
109
+ }