@tsparticles/updater-orbit 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 +70 -0
- package/browser/Options/Classes/Orbit.js +33 -0
- package/browser/Options/Classes/OrbitRotation.js +15 -0
- package/browser/Options/Interfaces/IOrbit.js +1 -0
- package/browser/OrbitUpdater.js +93 -0
- package/browser/index.js +4 -0
- package/cjs/Options/Classes/Orbit.js +37 -0
- package/cjs/Options/Classes/OrbitRotation.js +19 -0
- package/cjs/Options/Interfaces/IOrbit.js +2 -0
- package/cjs/OrbitUpdater.js +97 -0
- package/cjs/index.js +8 -0
- package/esm/Options/Classes/Orbit.js +33 -0
- package/esm/Options/Classes/OrbitRotation.js +15 -0
- package/esm/Options/Interfaces/IOrbit.js +1 -0
- package/esm/OrbitUpdater.js +93 -0
- package/esm/index.js +4 -0
- package/package.json +92 -0
- package/report.html +39 -0
- package/tsparticles.updater.orbit.js +252 -0
- package/tsparticles.updater.orbit.min.js +2 -0
- package/tsparticles.updater.orbit.min.js.LICENSE.txt +8 -0
- package/types/Options/Classes/Orbit.d.ts +15 -0
- package/types/Options/Classes/OrbitRotation.d.ts +6 -0
- package/types/Options/Interfaces/IOrbit.d.ts +9 -0
- package/types/OrbitUpdater.d.ts +42 -0
- package/types/index.d.ts +2 -0
- package/umd/Options/Classes/Orbit.js +47 -0
- package/umd/Options/Classes/OrbitRotation.js +29 -0
- package/umd/Options/Interfaces/IOrbit.js +12 -0
- package/umd/OrbitUpdater.js +107 -0
- package/umd/index.js +18 -0
|
@@ -0,0 +1,252 @@
|
|
|
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
|
+
"loadOrbitUpdater": () => (/* binding */ loadOrbitUpdater)
|
|
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/Options/Classes/OrbitRotation.js
|
|
100
|
+
|
|
101
|
+
class OrbitRotation extends engine_root_window_.ValueWithRandom {
|
|
102
|
+
constructor() {
|
|
103
|
+
super();
|
|
104
|
+
this.value = 45;
|
|
105
|
+
this.random.enable = false;
|
|
106
|
+
this.random.minimumValue = 0;
|
|
107
|
+
}
|
|
108
|
+
load(data) {
|
|
109
|
+
if (data === undefined) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
super.load(data);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Orbit.js
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class Orbit {
|
|
119
|
+
constructor() {
|
|
120
|
+
this.animation = new engine_root_window_.AnimationOptions();
|
|
121
|
+
this.enable = false;
|
|
122
|
+
this.opacity = 1;
|
|
123
|
+
this.rotation = new OrbitRotation();
|
|
124
|
+
this.width = 1;
|
|
125
|
+
}
|
|
126
|
+
load(data) {
|
|
127
|
+
if (!data) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
this.animation.load(data.animation);
|
|
131
|
+
this.rotation.load(data.rotation);
|
|
132
|
+
if (data.enable !== undefined) {
|
|
133
|
+
this.enable = data.enable;
|
|
134
|
+
}
|
|
135
|
+
if (data.opacity !== undefined) {
|
|
136
|
+
this.opacity = (0,engine_root_window_.setRangeValue)(data.opacity);
|
|
137
|
+
}
|
|
138
|
+
if (data.width !== undefined) {
|
|
139
|
+
this.width = (0,engine_root_window_.setRangeValue)(data.width);
|
|
140
|
+
}
|
|
141
|
+
if (data.radius !== undefined) {
|
|
142
|
+
this.radius = (0,engine_root_window_.setRangeValue)(data.radius);
|
|
143
|
+
}
|
|
144
|
+
if (data.color !== undefined) {
|
|
145
|
+
this.color = engine_root_window_.OptionsColor.create(this.color, data.color);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
;// CONCATENATED MODULE: ./dist/browser/OrbitUpdater.js
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
function drawEllipse(context, particle, fillColorValue, radius, opacity, width, rotation, start, end) {
|
|
153
|
+
if (width <= 0) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const pos = particle.getPosition();
|
|
157
|
+
if (fillColorValue) {
|
|
158
|
+
context.strokeStyle = (0,engine_root_window_.getStyleFromHsl)(fillColorValue, opacity);
|
|
159
|
+
}
|
|
160
|
+
context.lineWidth = width;
|
|
161
|
+
const rotationRadian = rotation * Math.PI / 180;
|
|
162
|
+
context.beginPath();
|
|
163
|
+
context.ellipse(pos.x, pos.y, radius / 2, radius * 2, rotationRadian, start, end);
|
|
164
|
+
context.stroke();
|
|
165
|
+
}
|
|
166
|
+
class OrbitUpdater {
|
|
167
|
+
constructor(container) {
|
|
168
|
+
this.container = container;
|
|
169
|
+
}
|
|
170
|
+
afterDraw(particle) {
|
|
171
|
+
const orbitOptions = particle.options.orbit;
|
|
172
|
+
if (orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable) {
|
|
173
|
+
this.drawOrbit(particle, "front");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
beforeDraw(particle) {
|
|
177
|
+
const orbitOptions = particle.options.orbit;
|
|
178
|
+
if (orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable) {
|
|
179
|
+
this.drawOrbit(particle, "back");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
drawOrbit(particle, type) {
|
|
183
|
+
const container = this.container;
|
|
184
|
+
let start, end;
|
|
185
|
+
switch (type) {
|
|
186
|
+
case "back":
|
|
187
|
+
start = Math.PI / 2;
|
|
188
|
+
end = Math.PI * 3 / 2;
|
|
189
|
+
break;
|
|
190
|
+
case "front":
|
|
191
|
+
start = Math.PI * 3 / 2;
|
|
192
|
+
end = Math.PI / 2;
|
|
193
|
+
break;
|
|
194
|
+
default:
|
|
195
|
+
start = 0;
|
|
196
|
+
end = 2 * Math.PI;
|
|
197
|
+
}
|
|
198
|
+
container.canvas.draw(ctx => {
|
|
199
|
+
var _a, _b, _c, _d, _e, _f;
|
|
200
|
+
drawEllipse(ctx, particle, (_a = particle.orbitColor) !== null && _a !== void 0 ? _a : particle.getFillColor(), (_c = (_b = particle.retina.orbitRadius) !== null && _b !== void 0 ? _b : container.retina.orbitRadius) !== null && _c !== void 0 ? _c : particle.getRadius(), (_d = particle.orbitOpacity) !== null && _d !== void 0 ? _d : 1, (_e = particle.orbitWidth) !== null && _e !== void 0 ? _e : 1, ((_f = particle.orbitRotation) !== null && _f !== void 0 ? _f : 0) * container.retina.pixelRatio, start, end);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
init(particle) {
|
|
204
|
+
const container = this.container,
|
|
205
|
+
particlesOptions = particle.options,
|
|
206
|
+
orbitOptions = particlesOptions.orbit;
|
|
207
|
+
if (!(orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable)) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
particle.orbitRotation = (0,engine_root_window_.getRangeValue)(orbitOptions.rotation.value);
|
|
211
|
+
particle.orbitColor = (0,engine_root_window_.rangeColorToHsl)(orbitOptions.color);
|
|
212
|
+
particle.retina.orbitRadius = orbitOptions.radius !== undefined ? (0,engine_root_window_.getRangeValue)(orbitOptions.radius) * container.retina.pixelRatio : undefined;
|
|
213
|
+
container.retina.orbitRadius = particle.retina.orbitRadius;
|
|
214
|
+
particle.orbitAnimationSpeed = orbitOptions.animation.enable ? (0,engine_root_window_.getRangeValue)(orbitOptions.animation.speed) : 0;
|
|
215
|
+
particle.orbitWidth = (0,engine_root_window_.getRangeValue)(orbitOptions.width);
|
|
216
|
+
particle.orbitOpacity = (0,engine_root_window_.getRangeValue)(orbitOptions.opacity);
|
|
217
|
+
}
|
|
218
|
+
isEnabled(particle) {
|
|
219
|
+
var _a;
|
|
220
|
+
const orbitAnimations = (_a = particle.options.orbit) === null || _a === void 0 ? void 0 : _a.animation;
|
|
221
|
+
return !particle.destroyed && !particle.spawning && !!(orbitAnimations === null || orbitAnimations === void 0 ? void 0 : orbitAnimations.enable);
|
|
222
|
+
}
|
|
223
|
+
loadOptions(options, ...sources) {
|
|
224
|
+
if (!options.orbit) {
|
|
225
|
+
options.orbit = new Orbit();
|
|
226
|
+
}
|
|
227
|
+
for (const source of sources) {
|
|
228
|
+
options.orbit.load(source === null || source === void 0 ? void 0 : source.orbit);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
update(particle, delta) {
|
|
232
|
+
var _a;
|
|
233
|
+
if (!this.isEnabled(particle)) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (particle.orbitRotation === undefined) {
|
|
237
|
+
particle.orbitRotation = 0;
|
|
238
|
+
}
|
|
239
|
+
particle.orbitRotation += ((_a = particle.orbitAnimationSpeed) !== null && _a !== void 0 ? _a : 0 / (Math.PI * 2)) * delta.factor;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
243
|
+
|
|
244
|
+
function loadOrbitUpdater(engine) {
|
|
245
|
+
engine.addParticleUpdater("orbit", container => new OrbitUpdater(container));
|
|
246
|
+
}
|
|
247
|
+
})();
|
|
248
|
+
|
|
249
|
+
/******/ return __webpack_exports__;
|
|
250
|
+
/******/ })()
|
|
251
|
+
;
|
|
252
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.updater.orbit.min.js.LICENSE.txt */
|
|
2
|
+
!function(t,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var i="object"==typeof exports?o(require("@tsparticles/engine")):o(t.window);for(var e in i)("object"==typeof exports?exports:t)[e]=i[e]}}(this,(t=>(()=>{"use strict";var o={533:o=>{o.exports=t}},i={};function e(t){var a=i[t];if(void 0!==a)return a.exports;var r=i[t]={exports:{}};return o[t](r,r.exports,e),r.exports}e.d=(t,o)=>{for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},e.o=(t,o)=>Object.prototype.hasOwnProperty.call(t,o),e.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var a={};return(()=>{e.r(a),e.d(a,{loadOrbitUpdater:()=>n});var t=e(533);class o extends t.ValueWithRandom{constructor(){super(),this.value=45,this.random.enable=!1,this.random.minimumValue=0}load(t){void 0!==t&&super.load(t)}}class i{constructor(){this.animation=new t.AnimationOptions,this.enable=!1,this.opacity=1,this.rotation=new o,this.width=1}load(o){o&&(this.animation.load(o.animation),this.rotation.load(o.rotation),void 0!==o.enable&&(this.enable=o.enable),void 0!==o.opacity&&(this.opacity=(0,t.setRangeValue)(o.opacity)),void 0!==o.width&&(this.width=(0,t.setRangeValue)(o.width)),void 0!==o.radius&&(this.radius=(0,t.setRangeValue)(o.radius)),void 0!==o.color&&(this.color=t.OptionsColor.create(this.color,o.color)))}}class r{constructor(t){this.container=t}afterDraw(t){const o=t.options.orbit;(null==o?void 0:o.enable)&&this.drawOrbit(t,"front")}beforeDraw(t){const o=t.options.orbit;(null==o?void 0:o.enable)&&this.drawOrbit(t,"back")}drawOrbit(o,i){const e=this.container;let a,r;switch(i){case"back":a=Math.PI/2,r=3*Math.PI/2;break;case"front":a=3*Math.PI/2,r=Math.PI/2;break;default:a=0,r=2*Math.PI}e.canvas.draw((i=>{var n,l,s,d,u,b;!function(o,i,e,a,r,n,l,s,d){if(n<=0)return;const u=i.getPosition();e&&(o.strokeStyle=(0,t.getStyleFromHsl)(e,r)),o.lineWidth=n;const b=l*Math.PI/180;o.beginPath(),o.ellipse(u.x,u.y,a/2,2*a,b,s,d),o.stroke()}(i,o,null!==(n=o.orbitColor)&&void 0!==n?n:o.getFillColor(),null!==(s=null!==(l=o.retina.orbitRadius)&&void 0!==l?l:e.retina.orbitRadius)&&void 0!==s?s:o.getRadius(),null!==(d=o.orbitOpacity)&&void 0!==d?d:1,null!==(u=o.orbitWidth)&&void 0!==u?u:1,(null!==(b=o.orbitRotation)&&void 0!==b?b:0)*e.retina.pixelRatio,a,r)}))}init(o){const i=this.container,e=o.options.orbit;(null==e?void 0:e.enable)&&(o.orbitRotation=(0,t.getRangeValue)(e.rotation.value),o.orbitColor=(0,t.rangeColorToHsl)(e.color),o.retina.orbitRadius=void 0!==e.radius?(0,t.getRangeValue)(e.radius)*i.retina.pixelRatio:void 0,i.retina.orbitRadius=o.retina.orbitRadius,o.orbitAnimationSpeed=e.animation.enable?(0,t.getRangeValue)(e.animation.speed):0,o.orbitWidth=(0,t.getRangeValue)(e.width),o.orbitOpacity=(0,t.getRangeValue)(e.opacity))}isEnabled(t){var o;const i=null===(o=t.options.orbit)||void 0===o?void 0:o.animation;return!t.destroyed&&!t.spawning&&!!(null==i?void 0:i.enable)}loadOptions(t,...o){t.orbit||(t.orbit=new i);for(const i of o)t.orbit.load(null==i?void 0:i.orbit)}update(t,o){var i;this.isEnabled(t)&&(void 0===t.orbitRotation&&(t.orbitRotation=0),t.orbitRotation+=(null!==(i=t.orbitAnimationSpeed)&&void 0!==i?i:0/(2*Math.PI))*o.factor)}}function n(t){t.addParticleUpdater("orbit",(t=>new r(t)))}})(),a})()));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AnimationOptions, OptionsColor } from "@tsparticles/engine";
|
|
2
|
+
import type { IAnimatable, IOptionLoader, RangeValue, RecursivePartial } from "@tsparticles/engine";
|
|
3
|
+
import type { IOrbit } from "../Interfaces/IOrbit";
|
|
4
|
+
import { OrbitRotation } from "./OrbitRotation";
|
|
5
|
+
export declare class Orbit implements IOrbit, IOptionLoader<IOrbit>, IAnimatable<AnimationOptions> {
|
|
6
|
+
animation: AnimationOptions;
|
|
7
|
+
color?: OptionsColor;
|
|
8
|
+
enable: boolean;
|
|
9
|
+
opacity: RangeValue;
|
|
10
|
+
radius?: RangeValue;
|
|
11
|
+
rotation: OrbitRotation;
|
|
12
|
+
width: RangeValue;
|
|
13
|
+
constructor();
|
|
14
|
+
load(data?: RecursivePartial<IOrbit>): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IValueWithRandom, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import { ValueWithRandom } from "@tsparticles/engine";
|
|
3
|
+
export declare class OrbitRotation extends ValueWithRandom {
|
|
4
|
+
constructor();
|
|
5
|
+
load(data?: RecursivePartial<IValueWithRandom>): void;
|
|
6
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IAnimatable, IAnimation, IOptionsColor, IValueWithRandom, RangeValue } from "@tsparticles/engine";
|
|
2
|
+
export interface IOrbit extends IAnimatable<IAnimation> {
|
|
3
|
+
color?: string | IOptionsColor;
|
|
4
|
+
enable: boolean;
|
|
5
|
+
opacity: RangeValue;
|
|
6
|
+
radius?: RangeValue;
|
|
7
|
+
rotation: IValueWithRandom;
|
|
8
|
+
width: RangeValue;
|
|
9
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Container, IDelta, IHsl, IParticleRetinaProps, IParticleUpdater, IParticlesOptions, Particle, ParticlesOptions, RecursivePartial, Retina } from "@tsparticles/engine";
|
|
2
|
+
import type { IOrbit } from "./Options/Interfaces/IOrbit";
|
|
3
|
+
import { Orbit } from "./Options/Classes/Orbit";
|
|
4
|
+
export declare const enum OrbitType {
|
|
5
|
+
front = "front",
|
|
6
|
+
back = "back"
|
|
7
|
+
}
|
|
8
|
+
type IOrbitParticlesOptions = IParticlesOptions & {
|
|
9
|
+
orbit?: IOrbit;
|
|
10
|
+
};
|
|
11
|
+
type OrbitParticlesOptions = ParticlesOptions & {
|
|
12
|
+
orbit?: Orbit;
|
|
13
|
+
};
|
|
14
|
+
type OrbitRetina = Retina & {
|
|
15
|
+
orbitRadius?: number;
|
|
16
|
+
};
|
|
17
|
+
type OrbitContainer = Container & {
|
|
18
|
+
retina: OrbitRetina;
|
|
19
|
+
};
|
|
20
|
+
type OrbitParticle = Particle & {
|
|
21
|
+
options: OrbitParticlesOptions;
|
|
22
|
+
orbitAnimationSpeed?: number;
|
|
23
|
+
orbitColor?: IHsl;
|
|
24
|
+
orbitOpacity?: number;
|
|
25
|
+
orbitRotation?: number;
|
|
26
|
+
orbitWidth?: number;
|
|
27
|
+
retina: IParticleRetinaProps & {
|
|
28
|
+
orbitRadius?: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare class OrbitUpdater implements IParticleUpdater {
|
|
32
|
+
private readonly container;
|
|
33
|
+
constructor(container: OrbitContainer);
|
|
34
|
+
afterDraw(particle: OrbitParticle): void;
|
|
35
|
+
beforeDraw(particle: OrbitParticle): void;
|
|
36
|
+
drawOrbit(particle: OrbitParticle, type: OrbitType): void;
|
|
37
|
+
init(particle: OrbitParticle): void;
|
|
38
|
+
isEnabled(particle: OrbitParticle): boolean;
|
|
39
|
+
loadOptions(options: OrbitParticlesOptions, ...sources: (RecursivePartial<IOrbitParticlesOptions> | undefined)[]): void;
|
|
40
|
+
update(particle: OrbitParticle, delta: IDelta): void;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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", "./OrbitRotation"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Orbit = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const OrbitRotation_1 = require("./OrbitRotation");
|
|
15
|
+
class Orbit {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.animation = new engine_1.AnimationOptions();
|
|
18
|
+
this.enable = false;
|
|
19
|
+
this.opacity = 1;
|
|
20
|
+
this.rotation = new OrbitRotation_1.OrbitRotation();
|
|
21
|
+
this.width = 1;
|
|
22
|
+
}
|
|
23
|
+
load(data) {
|
|
24
|
+
if (!data) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.animation.load(data.animation);
|
|
28
|
+
this.rotation.load(data.rotation);
|
|
29
|
+
if (data.enable !== undefined) {
|
|
30
|
+
this.enable = data.enable;
|
|
31
|
+
}
|
|
32
|
+
if (data.opacity !== undefined) {
|
|
33
|
+
this.opacity = (0, engine_1.setRangeValue)(data.opacity);
|
|
34
|
+
}
|
|
35
|
+
if (data.width !== undefined) {
|
|
36
|
+
this.width = (0, engine_1.setRangeValue)(data.width);
|
|
37
|
+
}
|
|
38
|
+
if (data.radius !== undefined) {
|
|
39
|
+
this.radius = (0, engine_1.setRangeValue)(data.radius);
|
|
40
|
+
}
|
|
41
|
+
if (data.color !== undefined) {
|
|
42
|
+
this.color = engine_1.OptionsColor.create(this.color, data.color);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.Orbit = Orbit;
|
|
47
|
+
});
|
|
@@ -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", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OrbitRotation = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
class OrbitRotation extends engine_1.ValueWithRandom {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.value = 45;
|
|
18
|
+
this.random.enable = false;
|
|
19
|
+
this.random.minimumValue = 0;
|
|
20
|
+
}
|
|
21
|
+
load(data) {
|
|
22
|
+
if (data === undefined) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
super.load(data);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.OrbitRotation = OrbitRotation;
|
|
29
|
+
});
|
|
@@ -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,107 @@
|
|
|
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", "./Options/Classes/Orbit"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OrbitUpdater = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const Orbit_1 = require("./Options/Classes/Orbit");
|
|
15
|
+
function drawEllipse(context, particle, fillColorValue, radius, opacity, width, rotation, start, end) {
|
|
16
|
+
if (width <= 0) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const pos = particle.getPosition();
|
|
20
|
+
if (fillColorValue) {
|
|
21
|
+
context.strokeStyle = (0, engine_1.getStyleFromHsl)(fillColorValue, opacity);
|
|
22
|
+
}
|
|
23
|
+
context.lineWidth = width;
|
|
24
|
+
const rotationRadian = (rotation * Math.PI) / 180;
|
|
25
|
+
context.beginPath();
|
|
26
|
+
context.ellipse(pos.x, pos.y, radius / 2, radius * 2, rotationRadian, start, end);
|
|
27
|
+
context.stroke();
|
|
28
|
+
}
|
|
29
|
+
class OrbitUpdater {
|
|
30
|
+
constructor(container) {
|
|
31
|
+
this.container = container;
|
|
32
|
+
}
|
|
33
|
+
afterDraw(particle) {
|
|
34
|
+
const orbitOptions = particle.options.orbit;
|
|
35
|
+
if (orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable) {
|
|
36
|
+
this.drawOrbit(particle, "front");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
beforeDraw(particle) {
|
|
40
|
+
const orbitOptions = particle.options.orbit;
|
|
41
|
+
if (orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable) {
|
|
42
|
+
this.drawOrbit(particle, "back");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
drawOrbit(particle, type) {
|
|
46
|
+
const container = this.container;
|
|
47
|
+
let start, end;
|
|
48
|
+
switch (type) {
|
|
49
|
+
case "back":
|
|
50
|
+
start = Math.PI / 2;
|
|
51
|
+
end = (Math.PI * 3) / 2;
|
|
52
|
+
break;
|
|
53
|
+
case "front":
|
|
54
|
+
start = (Math.PI * 3) / 2;
|
|
55
|
+
end = Math.PI / 2;
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
start = 0;
|
|
59
|
+
end = 2 * Math.PI;
|
|
60
|
+
}
|
|
61
|
+
container.canvas.draw((ctx) => {
|
|
62
|
+
var _a, _b, _c, _d, _e, _f;
|
|
63
|
+
drawEllipse(ctx, particle, (_a = particle.orbitColor) !== null && _a !== void 0 ? _a : particle.getFillColor(), (_c = (_b = particle.retina.orbitRadius) !== null && _b !== void 0 ? _b : container.retina.orbitRadius) !== null && _c !== void 0 ? _c : particle.getRadius(), (_d = particle.orbitOpacity) !== null && _d !== void 0 ? _d : 1, (_e = particle.orbitWidth) !== null && _e !== void 0 ? _e : 1, ((_f = particle.orbitRotation) !== null && _f !== void 0 ? _f : 0) * container.retina.pixelRatio, start, end);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
init(particle) {
|
|
67
|
+
const container = this.container, particlesOptions = particle.options, orbitOptions = particlesOptions.orbit;
|
|
68
|
+
if (!(orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
particle.orbitRotation = (0, engine_1.getRangeValue)(orbitOptions.rotation.value);
|
|
72
|
+
particle.orbitColor = (0, engine_1.rangeColorToHsl)(orbitOptions.color);
|
|
73
|
+
particle.retina.orbitRadius =
|
|
74
|
+
orbitOptions.radius !== undefined
|
|
75
|
+
? (0, engine_1.getRangeValue)(orbitOptions.radius) * container.retina.pixelRatio
|
|
76
|
+
: undefined;
|
|
77
|
+
container.retina.orbitRadius = particle.retina.orbitRadius;
|
|
78
|
+
particle.orbitAnimationSpeed = orbitOptions.animation.enable ? (0, engine_1.getRangeValue)(orbitOptions.animation.speed) : 0;
|
|
79
|
+
particle.orbitWidth = (0, engine_1.getRangeValue)(orbitOptions.width);
|
|
80
|
+
particle.orbitOpacity = (0, engine_1.getRangeValue)(orbitOptions.opacity);
|
|
81
|
+
}
|
|
82
|
+
isEnabled(particle) {
|
|
83
|
+
var _a;
|
|
84
|
+
const orbitAnimations = (_a = particle.options.orbit) === null || _a === void 0 ? void 0 : _a.animation;
|
|
85
|
+
return !particle.destroyed && !particle.spawning && !!(orbitAnimations === null || orbitAnimations === void 0 ? void 0 : orbitAnimations.enable);
|
|
86
|
+
}
|
|
87
|
+
loadOptions(options, ...sources) {
|
|
88
|
+
if (!options.orbit) {
|
|
89
|
+
options.orbit = new Orbit_1.Orbit();
|
|
90
|
+
}
|
|
91
|
+
for (const source of sources) {
|
|
92
|
+
options.orbit.load(source === null || source === void 0 ? void 0 : source.orbit);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
update(particle, delta) {
|
|
96
|
+
var _a;
|
|
97
|
+
if (!this.isEnabled(particle)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (particle.orbitRotation === undefined) {
|
|
101
|
+
particle.orbitRotation = 0;
|
|
102
|
+
}
|
|
103
|
+
particle.orbitRotation += ((_a = particle.orbitAnimationSpeed) !== null && _a !== void 0 ? _a : 0 / (Math.PI * 2)) * delta.factor;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.OrbitUpdater = OrbitUpdater;
|
|
107
|
+
});
|
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", "./OrbitUpdater"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadOrbitUpdater = void 0;
|
|
13
|
+
const OrbitUpdater_1 = require("./OrbitUpdater");
|
|
14
|
+
function loadOrbitUpdater(engine) {
|
|
15
|
+
engine.addParticleUpdater("orbit", (container) => new OrbitUpdater_1.OrbitUpdater(container));
|
|
16
|
+
}
|
|
17
|
+
exports.loadOrbitUpdater = loadOrbitUpdater;
|
|
18
|
+
});
|