@tsparticles/shape-spiral 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.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/browser/ISpiralData.js +1 -0
- package/browser/ISpiralParticle.js +1 -0
- package/browser/SpiralDrawer.js +15 -0
- package/browser/index.js +4 -0
- package/cjs/ISpiralData.js +2 -0
- package/cjs/ISpiralParticle.js +2 -0
- package/cjs/SpiralDrawer.js +19 -0
- package/cjs/index.js +8 -0
- package/esm/ISpiralData.js +1 -0
- package/esm/ISpiralParticle.js +1 -0
- package/esm/SpiralDrawer.js +15 -0
- package/esm/index.js +4 -0
- package/package.json +91 -0
- package/report.html +39 -0
- package/tsparticles.shape.spiral.js +93 -0
- package/tsparticles.shape.spiral.min.js +2 -0
- package/tsparticles.shape.spiral.min.js.LICENSE.txt +8 -0
- package/types/ISpiralData.d.ts +5 -0
- package/types/ISpiralParticle.d.ts +5 -0
- package/types/SpiralDrawer.d.ts +5 -0
- package/types/index.d.ts +2 -0
- package/umd/ISpiralData.js +12 -0
- package/umd/ISpiralParticle.js +12 -0
- package/umd/SpiralDrawer.js +29 -0
- package/umd/index.js +18 -0
|
@@ -0,0 +1,93 @@
|
|
|
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();
|
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
|
13
|
+
define([], factory);
|
|
14
|
+
else {
|
|
15
|
+
var a = factory();
|
|
16
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
|
+
}
|
|
18
|
+
})(this, () => {
|
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
|
20
|
+
/******/ "use strict";
|
|
21
|
+
/******/ // The require scope
|
|
22
|
+
/******/ var __webpack_require__ = {};
|
|
23
|
+
/******/
|
|
24
|
+
/************************************************************************/
|
|
25
|
+
/******/ /* webpack/runtime/define property getters */
|
|
26
|
+
/******/ (() => {
|
|
27
|
+
/******/ // define getter functions for harmony exports
|
|
28
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
29
|
+
/******/ for(var key in definition) {
|
|
30
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
31
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
32
|
+
/******/ }
|
|
33
|
+
/******/ }
|
|
34
|
+
/******/ };
|
|
35
|
+
/******/ })();
|
|
36
|
+
/******/
|
|
37
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
38
|
+
/******/ (() => {
|
|
39
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
40
|
+
/******/ })();
|
|
41
|
+
/******/
|
|
42
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
43
|
+
/******/ (() => {
|
|
44
|
+
/******/ // define __esModule on exports
|
|
45
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
46
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
+
/******/ }
|
|
49
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
/******/ };
|
|
51
|
+
/******/ })();
|
|
52
|
+
/******/
|
|
53
|
+
/************************************************************************/
|
|
54
|
+
var __webpack_exports__ = {};
|
|
55
|
+
// ESM COMPAT FLAG
|
|
56
|
+
__webpack_require__.r(__webpack_exports__);
|
|
57
|
+
|
|
58
|
+
// EXPORTS
|
|
59
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
60
|
+
"loadSpiralShape": () => (/* binding */ loadSpiralShape)
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
;// CONCATENATED MODULE: ./dist/browser/SpiralDrawer.js
|
|
64
|
+
class SpiralDrawer {
|
|
65
|
+
draw(context, particle, radius) {
|
|
66
|
+
const spiral = particle,
|
|
67
|
+
realWidth = (radius - spiral.spiralInnerRadius) / spiral.spiralLineSpacing;
|
|
68
|
+
for (let i = 0; i < realWidth * 10; i++) {
|
|
69
|
+
const angle = 0.1 * i,
|
|
70
|
+
positionFactor = spiral.spiralInnerRadius + spiral.spiralLineSpacing * angle,
|
|
71
|
+
x = positionFactor * Math.cos(angle),
|
|
72
|
+
y = positionFactor * Math.sin(angle);
|
|
73
|
+
context.lineTo(x, y);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
particleInit(container, particle) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const pixelRatio = container.retina.pixelRatio,
|
|
79
|
+
shapeData = particle.shapeData,
|
|
80
|
+
spiral = particle;
|
|
81
|
+
spiral.spiralInnerRadius = ((_a = shapeData.innerRadius) !== null && _a !== void 0 ? _a : 1) * pixelRatio;
|
|
82
|
+
spiral.spiralLineSpacing = ((_b = shapeData.lineSpacing) !== null && _b !== void 0 ? _b : 1) * pixelRatio;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
86
|
+
|
|
87
|
+
function loadSpiralShape(engine) {
|
|
88
|
+
engine.addShape("spiral", new SpiralDrawer());
|
|
89
|
+
}
|
|
90
|
+
/******/ return __webpack_exports__;
|
|
91
|
+
/******/ })()
|
|
92
|
+
;
|
|
93
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.shape.spiral.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,i){if("object"==typeof exports&&"object"==typeof module)module.exports=i();else if("function"==typeof define&&define.amd)define([],i);else{var n=i();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(()=>(()=>{"use strict";var e={d:(i,n)=>{for(var o in n)e.o(n,o)&&!e.o(i,o)&&Object.defineProperty(i,o,{enumerable:!0,get:n[o]})},o:(e,i)=>Object.prototype.hasOwnProperty.call(e,i),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},i={};e.r(i),e.d(i,{loadSpiralShape:()=>o});class n{draw(e,i,n){const o=i,t=(n-o.spiralInnerRadius)/o.spiralLineSpacing;for(let i=0;i<10*t;i++){const n=.1*i,t=o.spiralInnerRadius+o.spiralLineSpacing*n,r=t*Math.cos(n),a=t*Math.sin(n);e.lineTo(r,a)}}particleInit(e,i){var n,o;const t=e.retina.pixelRatio,r=i.shapeData,a=i;a.spiralInnerRadius=(null!==(n=r.innerRadius)&&void 0!==n?n:1)*t,a.spiralLineSpacing=(null!==(o=r.lineSpacing)&&void 0!==o?o:1)*t}}function o(e){e.addShape("spiral",new n)}return i})()));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Container, IParticle, IShapeDrawer } from "@tsparticles/engine";
|
|
2
|
+
export declare class SpiralDrawer implements IShapeDrawer {
|
|
3
|
+
draw(context: CanvasRenderingContext2D, particle: IParticle, radius: number): void;
|
|
4
|
+
particleInit(container: Container, particle: IParticle): void;
|
|
5
|
+
}
|
package/types/index.d.ts
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,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,29 @@
|
|
|
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.SpiralDrawer = void 0;
|
|
13
|
+
class SpiralDrawer {
|
|
14
|
+
draw(context, particle, radius) {
|
|
15
|
+
const spiral = particle, realWidth = (radius - spiral.spiralInnerRadius) / spiral.spiralLineSpacing;
|
|
16
|
+
for (let i = 0; i < realWidth * 10; i++) {
|
|
17
|
+
const angle = 0.1 * i, positionFactor = spiral.spiralInnerRadius + spiral.spiralLineSpacing * angle, x = positionFactor * Math.cos(angle), y = positionFactor * Math.sin(angle);
|
|
18
|
+
context.lineTo(x, y);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
particleInit(container, particle) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const pixelRatio = container.retina.pixelRatio, shapeData = particle.shapeData, spiral = particle;
|
|
24
|
+
spiral.spiralInnerRadius = ((_a = shapeData.innerRadius) !== null && _a !== void 0 ? _a : 1) * pixelRatio;
|
|
25
|
+
spiral.spiralLineSpacing = ((_b = shapeData.lineSpacing) !== null && _b !== void 0 ? _b : 1) * pixelRatio;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.SpiralDrawer = SpiralDrawer;
|
|
29
|
+
});
|
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", "./SpiralDrawer"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadSpiralShape = void 0;
|
|
13
|
+
const SpiralDrawer_1 = require("./SpiralDrawer");
|
|
14
|
+
function loadSpiralShape(engine) {
|
|
15
|
+
engine.addShape("spiral", new SpiralDrawer_1.SpiralDrawer());
|
|
16
|
+
}
|
|
17
|
+
exports.loadSpiralShape = loadSpiralShape;
|
|
18
|
+
});
|