@tsparticles/shape-star 3.0.0-alpha.1 → 3.0.0-beta.1

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.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v3.0.0-alpha.1
7
+ * v3.0.0-beta.1
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -91,7 +91,7 @@ __webpack_require__.r(__webpack_exports__);
91
91
 
92
92
  // EXPORTS
93
93
  __webpack_require__.d(__webpack_exports__, {
94
- "loadStarShape": () => (/* binding */ loadStarShape)
94
+ loadStarShape: () => (/* binding */ loadStarShape)
95
95
  });
96
96
 
97
97
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
@@ -100,9 +100,8 @@ var engine_root_window_ = __webpack_require__(533);
100
100
 
101
101
  class StarDrawer {
102
102
  draw(context, particle, radius) {
103
- var _a;
104
103
  const sides = particle.sides,
105
- inset = (_a = particle.starInset) !== null && _a !== void 0 ? _a : 2;
104
+ inset = particle.starInset ?? 2;
106
105
  context.moveTo(0, 0 - radius);
107
106
  for (let i = 0; i < sides; i++) {
108
107
  context.rotate(Math.PI / sides);
@@ -112,21 +111,18 @@ class StarDrawer {
112
111
  }
113
112
  }
114
113
  getSidesCount(particle) {
115
- var _a, _b;
116
114
  const star = particle.shapeData;
117
- return Math.round((0,engine_root_window_.getRangeValue)((_b = (_a = star === null || star === void 0 ? void 0 : star.sides) !== null && _a !== void 0 ? _a : star === null || star === void 0 ? void 0 : star.nb_sides) !== null && _b !== void 0 ? _b : 5));
115
+ return Math.round((0,engine_root_window_.getRangeValue)(star?.sides ?? 5));
118
116
  }
119
117
  particleInit(container, particle) {
120
- var _a;
121
- const star = particle.shapeData,
122
- inset = (0,engine_root_window_.getRangeValue)((_a = star === null || star === void 0 ? void 0 : star.inset) !== null && _a !== void 0 ? _a : 2);
123
- particle.starInset = inset;
118
+ const star = particle.shapeData;
119
+ particle.starInset = (0,engine_root_window_.getRangeValue)(star?.inset ?? 2);
124
120
  }
125
121
  }
126
122
  ;// CONCATENATED MODULE: ./dist/browser/index.js
127
123
 
128
- async function loadStarShape(engine) {
129
- await engine.addShape("star", new StarDrawer());
124
+ async function loadStarShape(engine, refresh = true) {
125
+ await engine.addShape("star", new StarDrawer(), refresh);
130
126
  }
131
127
  })();
132
128
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.shape.star.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function r(e){var n=o[e];if(void 0!==n)return n.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{loadStarShape:()=>o});var e=r(533);class t{draw(e,t,o){var r;const n=t.sides,a=null!==(r=t.starInset)&&void 0!==r?r:2;e.moveTo(0,0-o);for(let t=0;t<n;t++)e.rotate(Math.PI/n),e.lineTo(0,0-o*a),e.rotate(Math.PI/n),e.lineTo(0,0-o)}getSidesCount(t){var o,r;const n=t.shapeData;return Math.round((0,e.getRangeValue)(null!==(r=null!==(o=null==n?void 0:n.sides)&&void 0!==o?o:null==n?void 0:n.nb_sides)&&void 0!==r?r:5))}particleInit(t,o){var r;const n=o.shapeData,a=(0,e.getRangeValue)(null!==(r=null==n?void 0:n.inset)&&void 0!==r?r:2);o.starInset=a}}async function o(e){await e.addShape("star",new t)}})(),n})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},r={};function o(e){var a=r[e];if(void 0!==a)return a.exports;var n=r[e]={exports:{}};return t[e](n,n.exports,o),n.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{o.r(a),o.d(a,{loadStarShape:()=>r});var e=o(533);class t{draw(e,t,r){const o=t.sides,a=t.starInset??2;e.moveTo(0,0-r);for(let t=0;t<o;t++)e.rotate(Math.PI/o),e.lineTo(0,0-r*a),e.rotate(Math.PI/o),e.lineTo(0,0-r)}getSidesCount(t){const r=t.shapeData;return Math.round((0,e.getRangeValue)(r?.sides??5))}particleInit(t,r){const o=r.shapeData;r.starInset=(0,e.getRangeValue)(o?.inset??2)}}async function r(e,r=!0){await e.addShape("star",new t,r)}})(),a})()));
@@ -1,8 +1 @@
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.1
8
- */
1
+ /*! tsParticles Star Shape v3.0.0-beta.1 by Matteo Bruni */
@@ -1,5 +1,5 @@
1
- import type { Container, IShapeDrawer, Particle } from "@tsparticles/engine";
2
- import type { StarParticle } from "./StarParticle";
1
+ import { type Container, type IShapeDrawer, type Particle } from "@tsparticles/engine";
2
+ import type { StarParticle } from "./StarParticle.js";
3
3
  export declare class StarDrawer implements IShapeDrawer {
4
4
  draw(context: CanvasRenderingContext2D, particle: StarParticle, radius: number): void;
5
5
  getSidesCount(particle: Particle): number;
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Engine } from "@tsparticles/engine";
2
- export declare function loadStarShape(engine: Engine): Promise<void>;
2
+ export declare function loadStarShape(engine: Engine, refresh?: boolean): Promise<void>;
package/umd/StarDrawer.js CHANGED
@@ -13,8 +13,7 @@
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class StarDrawer {
15
15
  draw(context, particle, radius) {
16
- var _a;
17
- const sides = particle.sides, inset = (_a = particle.starInset) !== null && _a !== void 0 ? _a : 2;
16
+ const sides = particle.sides, inset = particle.starInset ?? 2;
18
17
  context.moveTo(0, 0 - radius);
19
18
  for (let i = 0; i < sides; i++) {
20
19
  context.rotate(Math.PI / sides);
@@ -24,14 +23,12 @@
24
23
  }
25
24
  }
26
25
  getSidesCount(particle) {
27
- var _a, _b;
28
26
  const star = particle.shapeData;
29
- return Math.round((0, engine_1.getRangeValue)((_b = (_a = star === null || star === void 0 ? void 0 : star.sides) !== null && _a !== void 0 ? _a : star === null || star === void 0 ? void 0 : star.nb_sides) !== null && _b !== void 0 ? _b : 5));
27
+ return Math.round((0, engine_1.getRangeValue)(star?.sides ?? 5));
30
28
  }
31
29
  particleInit(container, particle) {
32
- var _a;
33
- const star = particle.shapeData, inset = (0, engine_1.getRangeValue)((_a = star === null || star === void 0 ? void 0 : star.inset) !== null && _a !== void 0 ? _a : 2);
34
- particle.starInset = inset;
30
+ const star = particle.shapeData;
31
+ particle.starInset = (0, engine_1.getRangeValue)(star?.inset ?? 2);
35
32
  }
36
33
  }
37
34
  exports.StarDrawer = StarDrawer;
package/umd/index.js CHANGED
@@ -4,15 +4,15 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./StarDrawer"], factory);
7
+ define(["require", "exports", "./StarDrawer.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.loadStarShape = void 0;
13
- const StarDrawer_1 = require("./StarDrawer");
14
- async function loadStarShape(engine) {
15
- await engine.addShape("star", new StarDrawer_1.StarDrawer());
13
+ const StarDrawer_js_1 = require("./StarDrawer.js");
14
+ async function loadStarShape(engine, refresh = true) {
15
+ await engine.addShape("star", new StarDrawer_js_1.StarDrawer(), refresh);
16
16
  }
17
17
  exports.loadStarShape = loadStarShape;
18
18
  });