@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 +21 -0
- package/README.md +74 -0
- package/browser/IPathData.js +1 -0
- package/browser/SegmentType.js +9 -0
- package/browser/Utils.js +87 -0
- package/browser/index.js +2 -0
- package/browser/package.json +1 -0
- package/cjs/IPathData.js +1 -0
- package/cjs/SegmentType.js +9 -0
- package/cjs/Utils.js +87 -0
- package/cjs/index.js +2 -0
- package/cjs/package.json +1 -0
- package/esm/IPathData.js +1 -0
- package/esm/SegmentType.js +9 -0
- package/esm/Utils.js +87 -0
- package/esm/index.js +2 -0
- package/esm/package.json +1 -0
- package/package.json +109 -0
- package/report.html +40 -0
- package/tsparticles.path.utils.js +132 -0
- package/tsparticles.path.utils.min.js +2 -0
- package/tsparticles.path.utils.min.js.LICENSE.txt +1 -0
- package/types/IPathData.d.ts +10 -0
- package/types/SegmentType.d.ts +8 -0
- package/types/Utils.d.ts +2 -0
- package/types/index.d.ts +3 -0
- package/umd/IPathData.js +12 -0
- package/umd/SegmentType.js +22 -0
- package/umd/Utils.js +100 -0
- package/umd/index.js +28 -0
|
@@ -0,0 +1,132 @@
|
|
|
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.8
|
|
8
|
+
*/
|
|
9
|
+
/*
|
|
10
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
11
|
+
* This devtool is neither made for production nor for readable output files.
|
|
12
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
13
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
14
|
+
* or disable the default devtool with "devtool: false".
|
|
15
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
16
|
+
*/
|
|
17
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
18
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
19
|
+
module.exports = factory();
|
|
20
|
+
else if(typeof define === 'function' && define.amd)
|
|
21
|
+
define([], factory);
|
|
22
|
+
else {
|
|
23
|
+
var a = factory();
|
|
24
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
|
+
}
|
|
26
|
+
})(this, () => {
|
|
27
|
+
return /******/ (() => { // webpackBootstrap
|
|
28
|
+
/******/ "use strict";
|
|
29
|
+
/******/ var __webpack_modules__ = ({
|
|
30
|
+
|
|
31
|
+
/***/ "./dist/browser/SegmentType.js"
|
|
32
|
+
/*!*************************************!*\
|
|
33
|
+
!*** ./dist/browser/SegmentType.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 */ SegmentType: () => (/* binding */ SegmentType)\n/* harmony export */ });\nvar SegmentType;\n(function (SegmentType) {\n SegmentType[\"move\"] = \"move\";\n SegmentType[\"line\"] = \"line\";\n SegmentType[\"bezier\"] = \"bezier\";\n SegmentType[\"quadratic\"] = \"quadratic\";\n SegmentType[\"arc\"] = \"arc\";\n SegmentType[\"ellipse\"] = \"ellipse\";\n})(SegmentType || (SegmentType = {}));\n\n//# sourceURL=webpack://@tsparticles/path-utils/./dist/browser/SegmentType.js?\n}");
|
|
38
|
+
|
|
39
|
+
/***/ },
|
|
40
|
+
|
|
41
|
+
/***/ "./dist/browser/Utils.js"
|
|
42
|
+
/*!*******************************!*\
|
|
43
|
+
!*** ./dist/browser/Utils.js ***!
|
|
44
|
+
\*******************************/
|
|
45
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
46
|
+
|
|
47
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawPath: () => (/* binding */ drawPath)\n/* harmony export */ });\n/* harmony import */ var _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SegmentType.js */ \"./dist/browser/SegmentType.js\");\n\nconst firstIndex = 0,\n index2 = 1,\n index3 = 2,\n index4 = 3;\nfunction drawPath(ctx, radius, path) {\n const firstSegment = path.segments[firstIndex];\n if (!firstSegment) {\n return;\n }\n const firstValue = firstSegment.values[firstIndex];\n if (!firstValue) {\n return;\n }\n ctx.moveTo(firstValue.x * radius, firstValue.y * radius);\n for (const segment of path.segments) {\n const value = segment.values[firstIndex];\n if (!value) {\n continue;\n }\n const segmentValue2 = segment.values[index2],\n segmentValue3 = segment.values[index3],\n segmentValue4 = segment.values[index4];\n switch (segment.type) {\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.move:\n ctx.moveTo(value.x * radius, value.y * radius);\n break;\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.line:\n ctx.lineTo(value.x * radius, value.y * radius);\n break;\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier:\n if (!segmentValue2 || !segmentValue3 || !segmentValue4) {\n continue;\n }\n ctx.bezierCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius, segmentValue4.x * radius, segmentValue4.y * radius);\n break;\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.quadratic:\n if (!segmentValue2 || !segmentValue3) {\n continue;\n }\n ctx.quadraticCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius);\n break;\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.arc:\n if (!segmentValue2 || !segmentValue3) {\n continue;\n }\n ctx.arc(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue3.x, segmentValue3.y);\n break;\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.ellipse:\n if (!segmentValue2 || !segmentValue3 || !segmentValue4) {\n continue;\n }\n ctx.ellipse(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x, segmentValue4.x, segmentValue4.y);\n break;\n }\n }\n if (!path.half) {\n return;\n }\n const lengthOffset = 1,\n minLength = 0;\n for (let i = path.segments.length - lengthOffset; i >= minLength; i--) {\n const segment = path.segments[i];\n if (!segment) {\n continue;\n }\n const value = segment.values[firstIndex],\n index2 = 1,\n index3 = 2,\n segmentValue2 = segment.values[index2],\n segmentValue3 = segment.values[index3];\n switch (segment.type) {\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.line:\n if (!value) {\n break;\n }\n ctx.lineTo(value.x * -radius, value.y * radius);\n break;\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier:\n if (!value || !segmentValue2 || !segmentValue3) {\n break;\n }\n ctx.bezierCurveTo(-segmentValue3.x * radius, segmentValue3.y * radius, -segmentValue2.x * radius, segmentValue2.y * radius, -value.x * radius, value.y * radius);\n break;\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.quadratic:\n if (!segmentValue2 || !segmentValue3) {\n break;\n }\n ctx.quadraticCurveTo(-segmentValue2.x * radius, segmentValue2.y * radius, -segmentValue3.x * radius, segmentValue3.y * radius);\n break;\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.arc:\n case _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType.ellipse:\n default:\n break;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/path-utils/./dist/browser/Utils.js?\n}");
|
|
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 */ SegmentType: () => (/* reexport safe */ _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__.SegmentType),\n/* harmony export */ drawPath: () => (/* reexport safe */ _Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawPath)\n/* harmony export */ });\n/* harmony import */ var _SegmentType_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SegmentType.js */ \"./dist/browser/SegmentType.js\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\n\n//# sourceURL=webpack://@tsparticles/path-utils/./dist/browser/index.js?\n}");
|
|
58
|
+
|
|
59
|
+
/***/ }
|
|
60
|
+
|
|
61
|
+
/******/ });
|
|
62
|
+
/************************************************************************/
|
|
63
|
+
/******/ // The module cache
|
|
64
|
+
/******/ var __webpack_module_cache__ = {};
|
|
65
|
+
/******/
|
|
66
|
+
/******/ // The require function
|
|
67
|
+
/******/ function __webpack_require__(moduleId) {
|
|
68
|
+
/******/ // Check if module is in cache
|
|
69
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
70
|
+
/******/ if (cachedModule !== undefined) {
|
|
71
|
+
/******/ return cachedModule.exports;
|
|
72
|
+
/******/ }
|
|
73
|
+
/******/ // Check if module exists (development only)
|
|
74
|
+
/******/ if (__webpack_modules__[moduleId] === undefined) {
|
|
75
|
+
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
76
|
+
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
77
|
+
/******/ throw e;
|
|
78
|
+
/******/ }
|
|
79
|
+
/******/ // Create a new module (and put it into the cache)
|
|
80
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
81
|
+
/******/ // no module.id needed
|
|
82
|
+
/******/ // no module.loaded needed
|
|
83
|
+
/******/ exports: {}
|
|
84
|
+
/******/ };
|
|
85
|
+
/******/
|
|
86
|
+
/******/ // Execute the module function
|
|
87
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
88
|
+
/******/
|
|
89
|
+
/******/ // Return the exports of the module
|
|
90
|
+
/******/ return module.exports;
|
|
91
|
+
/******/ }
|
|
92
|
+
/******/
|
|
93
|
+
/************************************************************************/
|
|
94
|
+
/******/ /* webpack/runtime/define property getters */
|
|
95
|
+
/******/ (() => {
|
|
96
|
+
/******/ // define getter functions for harmony exports
|
|
97
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
98
|
+
/******/ for(var key in definition) {
|
|
99
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
100
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
101
|
+
/******/ }
|
|
102
|
+
/******/ }
|
|
103
|
+
/******/ };
|
|
104
|
+
/******/ })();
|
|
105
|
+
/******/
|
|
106
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
107
|
+
/******/ (() => {
|
|
108
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
109
|
+
/******/ })();
|
|
110
|
+
/******/
|
|
111
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
112
|
+
/******/ (() => {
|
|
113
|
+
/******/ // define __esModule on exports
|
|
114
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
115
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
116
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
117
|
+
/******/ }
|
|
118
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
119
|
+
/******/ };
|
|
120
|
+
/******/ })();
|
|
121
|
+
/******/
|
|
122
|
+
/************************************************************************/
|
|
123
|
+
/******/
|
|
124
|
+
/******/ // startup
|
|
125
|
+
/******/ // Load entry module and return exports
|
|
126
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
127
|
+
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
128
|
+
/******/
|
|
129
|
+
/******/ return __webpack_exports__;
|
|
130
|
+
/******/ })()
|
|
131
|
+
;
|
|
132
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.path.utils.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(()=>(()=>{var e,t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};t.r(o),t.d(o,{SegmentType:()=>e,drawPath:()=>s}),function(e){e.move="move",e.line="line",e.bezier="bezier",e.quadratic="quadratic",e.arc="arc",e.ellipse="ellipse"}(e||(e={}));const r=0,a=1,i=2,n=3;function s(t,o,s){const c=s.segments[r];if(!c)return;const l=c.values[r];if(!l)return;t.moveTo(l.x*o,l.y*o);for(const c of s.segments){const s=c.values[r];if(!s)continue;const l=c.values[a],u=c.values[i],f=c.values[n];switch(c.type){case e.move:t.moveTo(s.x*o,s.y*o);break;case e.line:t.lineTo(s.x*o,s.y*o);break;case e.bezier:if(!l||!u||!f)continue;t.bezierCurveTo(l.x*o,l.y*o,u.x*o,u.y*o,f.x*o,f.y*o);break;case e.quadratic:if(!l||!u)continue;t.quadraticCurveTo(l.x*o,l.y*o,u.x*o,u.y*o);break;case e.arc:if(!l||!u)continue;t.arc(s.x*o,s.y*o,l.x*o,u.x,u.y);break;case e.ellipse:if(!l||!u||!f)continue;t.ellipse(s.x*o,s.y*o,l.x*o,l.y*o,u.x,f.x,f.y)}}if(!s.half)return;for(let a=s.segments.length-1;a>=0;a--){const i=s.segments[a];if(!i)continue;const n=i.values[r],c=1,l=2,u=i.values[c],f=i.values[l];switch(i.type){case e.line:if(!n)break;t.lineTo(n.x*-o,n.y*o);break;case e.bezier:if(!n||!u||!f)break;t.bezierCurveTo(-f.x*o,f.y*o,-u.x*o,u.y*o,-n.x*o,n.y*o);break;case e.quadratic:if(!u||!f)break;t.quadraticCurveTo(-u.x*o,u.y*o,-f.x*o,f.y*o);case e.arc:case e.ellipse:}}}return o})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Path Utils v4.0.0-alpha.8 by Matteo Bruni */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ICoordinates } from "@tsparticles/engine";
|
|
2
|
+
import type { SegmentType } from "./SegmentType.js";
|
|
3
|
+
export interface IPathSegmentData {
|
|
4
|
+
type: SegmentType;
|
|
5
|
+
values: ICoordinates[];
|
|
6
|
+
}
|
|
7
|
+
export interface IPathData {
|
|
8
|
+
half: boolean;
|
|
9
|
+
segments: IPathSegmentData[];
|
|
10
|
+
}
|
package/types/Utils.d.ts
ADDED
package/types/index.d.ts
ADDED
package/umd/IPathData.js
ADDED
|
@@ -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,22 @@
|
|
|
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["move"] = "move";
|
|
16
|
+
SegmentType["line"] = "line";
|
|
17
|
+
SegmentType["bezier"] = "bezier";
|
|
18
|
+
SegmentType["quadratic"] = "quadratic";
|
|
19
|
+
SegmentType["arc"] = "arc";
|
|
20
|
+
SegmentType["ellipse"] = "ellipse";
|
|
21
|
+
})(SegmentType || (exports.SegmentType = SegmentType = {}));
|
|
22
|
+
});
|
package/umd/Utils.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
const firstIndex = 0, index2 = 1, index3 = 2, index4 = 3;
|
|
15
|
+
function drawPath(ctx, radius, path) {
|
|
16
|
+
const firstSegment = path.segments[firstIndex];
|
|
17
|
+
if (!firstSegment) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const firstValue = firstSegment.values[firstIndex];
|
|
21
|
+
if (!firstValue) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
ctx.moveTo(firstValue.x * radius, firstValue.y * radius);
|
|
25
|
+
for (const segment of path.segments) {
|
|
26
|
+
const value = segment.values[firstIndex];
|
|
27
|
+
if (!value) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3], segmentValue4 = segment.values[index4];
|
|
31
|
+
switch (segment.type) {
|
|
32
|
+
case SegmentType_js_1.SegmentType.move:
|
|
33
|
+
ctx.moveTo(value.x * radius, value.y * radius);
|
|
34
|
+
break;
|
|
35
|
+
case SegmentType_js_1.SegmentType.line:
|
|
36
|
+
ctx.lineTo(value.x * radius, value.y * radius);
|
|
37
|
+
break;
|
|
38
|
+
case SegmentType_js_1.SegmentType.bezier:
|
|
39
|
+
if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
ctx.bezierCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius, segmentValue4.x * radius, segmentValue4.y * radius);
|
|
43
|
+
break;
|
|
44
|
+
case SegmentType_js_1.SegmentType.quadratic:
|
|
45
|
+
if (!segmentValue2 || !segmentValue3) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
ctx.quadraticCurveTo(segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x * radius, segmentValue3.y * radius);
|
|
49
|
+
break;
|
|
50
|
+
case SegmentType_js_1.SegmentType.arc:
|
|
51
|
+
if (!segmentValue2 || !segmentValue3) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
ctx.arc(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue3.x, segmentValue3.y);
|
|
55
|
+
break;
|
|
56
|
+
case SegmentType_js_1.SegmentType.ellipse:
|
|
57
|
+
if (!segmentValue2 || !segmentValue3 || !segmentValue4) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
ctx.ellipse(value.x * radius, value.y * radius, segmentValue2.x * radius, segmentValue2.y * radius, segmentValue3.x, segmentValue4.x, segmentValue4.y);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!path.half) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const lengthOffset = 1, minLength = 0;
|
|
68
|
+
for (let i = path.segments.length - lengthOffset; i >= minLength; i--) {
|
|
69
|
+
const segment = path.segments[i];
|
|
70
|
+
if (!segment) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const value = segment.values[firstIndex], index2 = 1, index3 = 2, segmentValue2 = segment.values[index2], segmentValue3 = segment.values[index3];
|
|
74
|
+
switch (segment.type) {
|
|
75
|
+
case SegmentType_js_1.SegmentType.line:
|
|
76
|
+
if (!value) {
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
ctx.lineTo(value.x * -radius, value.y * radius);
|
|
80
|
+
break;
|
|
81
|
+
case SegmentType_js_1.SegmentType.bezier:
|
|
82
|
+
if (!value || !segmentValue2 || !segmentValue3) {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
ctx.bezierCurveTo(-segmentValue3.x * radius, segmentValue3.y * radius, -segmentValue2.x * radius, segmentValue2.y * radius, -value.x * radius, value.y * radius);
|
|
86
|
+
break;
|
|
87
|
+
case SegmentType_js_1.SegmentType.quadratic:
|
|
88
|
+
if (!segmentValue2 || !segmentValue3) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
ctx.quadraticCurveTo(-segmentValue2.x * radius, segmentValue2.y * radius, -segmentValue3.x * radius, segmentValue3.y * radius);
|
|
92
|
+
break;
|
|
93
|
+
case SegmentType_js_1.SegmentType.arc:
|
|
94
|
+
case SegmentType_js_1.SegmentType.ellipse:
|
|
95
|
+
default:
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
(function (factory) {
|
|
16
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
17
|
+
var v = factory(require, exports);
|
|
18
|
+
if (v !== undefined) module.exports = v;
|
|
19
|
+
}
|
|
20
|
+
else if (typeof define === "function" && define.amd) {
|
|
21
|
+
define(["require", "exports", "./SegmentType.js", "./Utils.js"], factory);
|
|
22
|
+
}
|
|
23
|
+
})(function (require, exports) {
|
|
24
|
+
"use strict";
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
__exportStar(require("./SegmentType.js"), exports);
|
|
27
|
+
__exportStar(require("./Utils.js"), exports);
|
|
28
|
+
});
|