@tsparticles/shape-cog 3.0.0-beta.2 → 3.0.0-beta.4

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.
@@ -1,6 +1,7 @@
1
1
  import { getRangeValue } from "@tsparticles/engine";
2
2
  export class CogDrawer {
3
- afterEffect(ctx, particle, radius) {
3
+ afterDraw(data) {
4
+ const { context, particle, radius } = data;
4
5
  if (particle.cogHoleRadius === undefined ||
5
6
  particle.cogInnerRadius === undefined ||
6
7
  particle.cogInnerTaper === undefined ||
@@ -9,15 +10,16 @@ export class CogDrawer {
9
10
  return;
10
11
  }
11
12
  const pi2 = 2 * Math.PI, holeRadius = (radius * particle.cogHoleRadius) / 100;
12
- ctx.globalCompositeOperation = "destination-out";
13
- ctx.beginPath();
14
- ctx.moveTo(holeRadius, 0);
15
- ctx.arc(0, 0, holeRadius, 0, pi2);
16
- ctx.closePath();
17
- ctx.fill();
18
- ctx.globalCompositeOperation = "source-over";
13
+ context.globalCompositeOperation = "destination-out";
14
+ context.beginPath();
15
+ context.moveTo(holeRadius, 0);
16
+ context.arc(0, 0, holeRadius, 0, pi2);
17
+ context.closePath();
18
+ context.fill();
19
+ context.globalCompositeOperation = "source-over";
19
20
  }
20
- draw(ctx, particle, radius) {
21
+ draw(data) {
22
+ const { context, particle, radius } = data;
21
23
  if (particle.cogHoleRadius === undefined ||
22
24
  particle.cogInnerRadius === undefined ||
23
25
  particle.cogInnerTaper === undefined ||
@@ -27,15 +29,15 @@ export class CogDrawer {
27
29
  }
28
30
  const pi2 = 2 * Math.PI, angle = pi2 / (particle.cogNotches * 2), taperAI = angle * particle.cogInnerTaper * 0.005, taperAO = angle * particle.cogOuterTaper * 0.005, innerRadius = (radius * particle.cogInnerRadius) / 100;
29
31
  let a = angle, toggle = false;
30
- ctx.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
32
+ context.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
31
33
  for (; a <= pi2; a += angle) {
32
34
  if (toggle) {
33
- ctx.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
34
- ctx.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
35
+ context.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
36
+ context.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
35
37
  }
36
38
  else {
37
- ctx.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
38
- ctx.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
39
+ context.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
40
+ context.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
39
41
  }
40
42
  toggle = !toggle;
41
43
  }
package/cjs/CogDrawer.js CHANGED
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CogDrawer = void 0;
4
4
  const engine_1 = require("@tsparticles/engine");
5
5
  class CogDrawer {
6
- afterEffect(ctx, particle, radius) {
6
+ afterDraw(data) {
7
+ const { context, particle, radius } = data;
7
8
  if (particle.cogHoleRadius === undefined ||
8
9
  particle.cogInnerRadius === undefined ||
9
10
  particle.cogInnerTaper === undefined ||
@@ -12,15 +13,16 @@ class CogDrawer {
12
13
  return;
13
14
  }
14
15
  const pi2 = 2 * Math.PI, holeRadius = (radius * particle.cogHoleRadius) / 100;
15
- ctx.globalCompositeOperation = "destination-out";
16
- ctx.beginPath();
17
- ctx.moveTo(holeRadius, 0);
18
- ctx.arc(0, 0, holeRadius, 0, pi2);
19
- ctx.closePath();
20
- ctx.fill();
21
- ctx.globalCompositeOperation = "source-over";
16
+ context.globalCompositeOperation = "destination-out";
17
+ context.beginPath();
18
+ context.moveTo(holeRadius, 0);
19
+ context.arc(0, 0, holeRadius, 0, pi2);
20
+ context.closePath();
21
+ context.fill();
22
+ context.globalCompositeOperation = "source-over";
22
23
  }
23
- draw(ctx, particle, radius) {
24
+ draw(data) {
25
+ const { context, particle, radius } = data;
24
26
  if (particle.cogHoleRadius === undefined ||
25
27
  particle.cogInnerRadius === undefined ||
26
28
  particle.cogInnerTaper === undefined ||
@@ -30,15 +32,15 @@ class CogDrawer {
30
32
  }
31
33
  const pi2 = 2 * Math.PI, angle = pi2 / (particle.cogNotches * 2), taperAI = angle * particle.cogInnerTaper * 0.005, taperAO = angle * particle.cogOuterTaper * 0.005, innerRadius = (radius * particle.cogInnerRadius) / 100;
32
34
  let a = angle, toggle = false;
33
- ctx.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
35
+ context.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
34
36
  for (; a <= pi2; a += angle) {
35
37
  if (toggle) {
36
- ctx.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
37
- ctx.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
38
+ context.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
39
+ context.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
38
40
  }
39
41
  else {
40
- ctx.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
41
- ctx.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
42
+ context.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
43
+ context.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
42
44
  }
43
45
  toggle = !toggle;
44
46
  }
package/esm/CogDrawer.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { getRangeValue } from "@tsparticles/engine";
2
2
  export class CogDrawer {
3
- afterEffect(ctx, particle, radius) {
3
+ afterDraw(data) {
4
+ const { context, particle, radius } = data;
4
5
  if (particle.cogHoleRadius === undefined ||
5
6
  particle.cogInnerRadius === undefined ||
6
7
  particle.cogInnerTaper === undefined ||
@@ -9,15 +10,16 @@ export class CogDrawer {
9
10
  return;
10
11
  }
11
12
  const pi2 = 2 * Math.PI, holeRadius = (radius * particle.cogHoleRadius) / 100;
12
- ctx.globalCompositeOperation = "destination-out";
13
- ctx.beginPath();
14
- ctx.moveTo(holeRadius, 0);
15
- ctx.arc(0, 0, holeRadius, 0, pi2);
16
- ctx.closePath();
17
- ctx.fill();
18
- ctx.globalCompositeOperation = "source-over";
13
+ context.globalCompositeOperation = "destination-out";
14
+ context.beginPath();
15
+ context.moveTo(holeRadius, 0);
16
+ context.arc(0, 0, holeRadius, 0, pi2);
17
+ context.closePath();
18
+ context.fill();
19
+ context.globalCompositeOperation = "source-over";
19
20
  }
20
- draw(ctx, particle, radius) {
21
+ draw(data) {
22
+ const { context, particle, radius } = data;
21
23
  if (particle.cogHoleRadius === undefined ||
22
24
  particle.cogInnerRadius === undefined ||
23
25
  particle.cogInnerTaper === undefined ||
@@ -27,15 +29,15 @@ export class CogDrawer {
27
29
  }
28
30
  const pi2 = 2 * Math.PI, angle = pi2 / (particle.cogNotches * 2), taperAI = angle * particle.cogInnerTaper * 0.005, taperAO = angle * particle.cogOuterTaper * 0.005, innerRadius = (radius * particle.cogInnerRadius) / 100;
29
31
  let a = angle, toggle = false;
30
- ctx.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
32
+ context.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
31
33
  for (; a <= pi2; a += angle) {
32
34
  if (toggle) {
33
- ctx.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
34
- ctx.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
35
+ context.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
36
+ context.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
35
37
  }
36
38
  else {
37
- ctx.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
38
- ctx.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
39
+ context.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
40
+ context.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
39
41
  }
40
42
  toggle = !toggle;
41
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/shape-cog",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.4",
4
4
  "description": "tsParticles cog shape",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -60,7 +60,7 @@
60
60
  "confettijs",
61
61
  "fireworksjs",
62
62
  "canvas-confetti",
63
- "@tsparticles/shape"
63
+ "tsparticles-shape"
64
64
  ],
65
65
  "author": "Matteo Bruni <matteo.bruni@me.com>",
66
66
  "license": "MIT",
@@ -100,7 +100,7 @@
100
100
  "./package.json": "./package.json"
101
101
  },
102
102
  "dependencies": {
103
- "@tsparticles/engine": "^3.0.0-beta.2"
103
+ "@tsparticles/engine": "^3.0.0-beta.4"
104
104
  },
105
105
  "publishConfig": {
106
106
  "access": "public"