@tsparticles/shape-square 3.0.0-alpha.0 → 3.0.0-beta.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.
@@ -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.0
7
+ * v3.0.0-beta.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -57,14 +57,16 @@ __webpack_require__.r(__webpack_exports__);
57
57
 
58
58
  // EXPORTS
59
59
  __webpack_require__.d(__webpack_exports__, {
60
- "loadSquareShape": () => (/* binding */ loadSquareShape)
60
+ loadSquareShape: () => (/* binding */ loadSquareShape)
61
61
  });
62
62
 
63
63
  ;// CONCATENATED MODULE: ./dist/browser/SquareDrawer.js
64
64
  const fixFactor = Math.sqrt(2);
65
65
  class SquareDrawer {
66
66
  draw(context, particle, radius) {
67
- context.rect(-radius / fixFactor, -radius / fixFactor, radius * 2 / fixFactor, radius * 2 / fixFactor);
67
+ const fixedRadius = radius / fixFactor,
68
+ fixedDiameter = fixedRadius * 2;
69
+ context.rect(-fixedRadius, -fixedRadius, fixedDiameter, fixedDiameter);
68
70
  }
69
71
  getSidesCount() {
70
72
  return 4;
@@ -72,9 +74,8 @@ class SquareDrawer {
72
74
  }
73
75
  ;// CONCATENATED MODULE: ./dist/browser/index.js
74
76
 
75
- async function loadSquareShape(engine) {
76
- const drawer = new SquareDrawer();
77
- await engine.addShape(["edge", "square"], drawer);
77
+ async function loadSquareShape(engine, refresh = true) {
78
+ await engine.addShape(["edge", "square"], new SquareDrawer(), refresh);
78
79
  }
79
80
  /******/ return __webpack_exports__;
80
81
  /******/ })()
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.shape.square.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,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,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})}},t={};e.r(t),e.d(t,{loadSquareShape:()=>n});const o=Math.sqrt(2);class r{draw(e,t,r){e.rect(-r/o,-r/o,2*r/o,2*r/o)}getSidesCount(){return 4}}async function n(e){const t=new r;await e.addShape(["edge","square"],t)}return t})()));
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,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,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})}},t={};e.r(t),e.d(t,{loadSquareShape:()=>n});const o=Math.sqrt(2);class r{draw(e,t,r){const n=r/o,a=2*n;e.rect(-n,-n,a,a)}getSidesCount(){return 4}}async function n(e,t=!0){await e.addShape(["edge","square"],new r,t)}return t})()));
@@ -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.0
8
- */
1
+ /*! tsParticles Square Shape v3.0.0-beta.0 by Matteo Bruni */
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Engine } from "@tsparticles/engine";
2
- export declare function loadSquareShape(engine: Engine): Promise<void>;
2
+ export declare function loadSquareShape(engine: Engine, refresh?: boolean): Promise<void>;
@@ -13,7 +13,8 @@
13
13
  const fixFactor = Math.sqrt(2);
14
14
  class SquareDrawer {
15
15
  draw(context, particle, radius) {
16
- context.rect(-radius / fixFactor, -radius / fixFactor, (radius * 2) / fixFactor, (radius * 2) / fixFactor);
16
+ const fixedRadius = radius / fixFactor, fixedDiameter = fixedRadius * 2;
17
+ context.rect(-fixedRadius, -fixedRadius, fixedDiameter, fixedDiameter);
17
18
  }
18
19
  getSidesCount() {
19
20
  return 4;
package/umd/index.js CHANGED
@@ -11,9 +11,8 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.loadSquareShape = void 0;
13
13
  const SquareDrawer_1 = require("./SquareDrawer");
14
- async function loadSquareShape(engine) {
15
- const drawer = new SquareDrawer_1.SquareDrawer();
16
- await engine.addShape(["edge", "square"], drawer);
14
+ async function loadSquareShape(engine, refresh = true) {
15
+ await engine.addShape(["edge", "square"], new SquareDrawer_1.SquareDrawer(), refresh);
17
16
  }
18
17
  exports.loadSquareShape = loadSquareShape;
19
18
  });