@tsparticles/plugin-emitters-shape-path 3.0.3 → 3.2.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/umd/utils.js CHANGED
@@ -11,12 +11,13 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.generateRandomPointOnPathPerimeter = exports.generateRandomPointWithinPath = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
+ const maxAttempts = 100, half = 0.5;
14
15
  function generateRandomPointWithinPath(ctx, path, center, size) {
15
16
  let randomPoint = null;
16
- for (let attempts = 0; attempts < 100; attempts++) {
17
+ for (let attempts = 0; attempts < maxAttempts; attempts++) {
17
18
  const tmpPoint = {
18
- x: center.x + (0, engine_1.getRandom)() * size.width - size.width / 2,
19
- y: center.y + (0, engine_1.getRandom)() * size.height - size.height / 2,
19
+ x: center.x + (0, engine_1.getRandom)() * size.width - size.width * half,
20
+ y: center.y + (0, engine_1.getRandom)() * size.height - size.height * half,
20
21
  };
21
22
  if (ctx.isPointInPath(path, tmpPoint.x, tmpPoint.y)) {
22
23
  randomPoint = tmpPoint;
@@ -28,10 +29,10 @@
28
29
  exports.generateRandomPointWithinPath = generateRandomPointWithinPath;
29
30
  function generateRandomPointOnPathPerimeter(ctx, path, center, size) {
30
31
  let randomPoint = null;
31
- for (let attempts = 0; attempts < 100; attempts++) {
32
+ for (let attempts = 0; attempts < maxAttempts; attempts++) {
32
33
  const tmpPoint = {
33
- x: center.x + (0, engine_1.getRandom)() * size.width - size.width / 2,
34
- y: center.y + (0, engine_1.getRandom)() * size.height - size.height / 2,
34
+ x: center.x + (0, engine_1.getRandom)() * size.width - size.width * half,
35
+ y: center.y + (0, engine_1.getRandom)() * size.height - size.height * half,
35
36
  };
36
37
  if (ctx.isPointInStroke(path, tmpPoint.x, tmpPoint.y)) {
37
38
  randomPoint = tmpPoint;