@tsparticles/shape-cog 3.0.0-beta.1 → 3.0.0-beta.3

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-beta.1
7
+ * v3.0.0-beta.3
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -99,21 +99,31 @@ var engine_root_window_ = __webpack_require__(533);
99
99
  ;// CONCATENATED MODULE: ./dist/browser/CogDrawer.js
100
100
 
101
101
  class CogDrawer {
102
- afterEffect(ctx, particle, radius) {
102
+ afterEffect(data) {
103
+ const {
104
+ context,
105
+ particle,
106
+ radius
107
+ } = data;
103
108
  if (particle.cogHoleRadius === undefined || particle.cogInnerRadius === undefined || particle.cogInnerTaper === undefined || particle.cogNotches === undefined || particle.cogOuterTaper === undefined) {
104
109
  return;
105
110
  }
106
111
  const pi2 = 2 * Math.PI,
107
112
  holeRadius = radius * particle.cogHoleRadius / 100;
108
- ctx.globalCompositeOperation = "destination-out";
109
- ctx.beginPath();
110
- ctx.moveTo(holeRadius, 0);
111
- ctx.arc(0, 0, holeRadius, 0, pi2);
112
- ctx.closePath();
113
- ctx.fill();
114
- ctx.globalCompositeOperation = "source-over";
113
+ context.globalCompositeOperation = "destination-out";
114
+ context.beginPath();
115
+ context.moveTo(holeRadius, 0);
116
+ context.arc(0, 0, holeRadius, 0, pi2);
117
+ context.closePath();
118
+ context.fill();
119
+ context.globalCompositeOperation = "source-over";
115
120
  }
116
- draw(ctx, particle, radius) {
121
+ draw(data) {
122
+ const {
123
+ context,
124
+ particle,
125
+ radius
126
+ } = data;
117
127
  if (particle.cogHoleRadius === undefined || particle.cogInnerRadius === undefined || particle.cogInnerTaper === undefined || particle.cogNotches === undefined || particle.cogOuterTaper === undefined) {
118
128
  return;
119
129
  }
@@ -124,14 +134,14 @@ class CogDrawer {
124
134
  innerRadius = radius * particle.cogInnerRadius / 100;
125
135
  let a = angle,
126
136
  toggle = false;
127
- ctx.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
137
+ context.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
128
138
  for (; a <= pi2; a += angle) {
129
139
  if (toggle) {
130
- ctx.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
131
- ctx.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
140
+ context.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
141
+ context.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
132
142
  } else {
133
- ctx.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
134
- ctx.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
143
+ context.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
144
+ context.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
135
145
  }
136
146
  toggle = !toggle;
137
147
  }
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.shape.cog.min.js.LICENSE.txt */
2
- !function(e,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 t="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var r in t)("object"==typeof exports?exports:e)[r]=t[r]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},t={};function r(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return o[e](n,n.exports,r),n.exports}r.d=(e,o)=>{for(var t in o)r.o(o,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{r.r(a),r.d(a,{loadCogShape:()=>t});var e=r(533);class o{afterEffect(e,o,t){if(void 0===o.cogHoleRadius||void 0===o.cogInnerRadius||void 0===o.cogInnerTaper||void 0===o.cogNotches||void 0===o.cogOuterTaper)return;const r=2*Math.PI,a=t*o.cogHoleRadius/100;e.globalCompositeOperation="destination-out",e.beginPath(),e.moveTo(a,0),e.arc(0,0,a,0,r),e.closePath(),e.fill(),e.globalCompositeOperation="source-over"}draw(e,o,t){if(void 0===o.cogHoleRadius||void 0===o.cogInnerRadius||void 0===o.cogInnerTaper||void 0===o.cogNotches||void 0===o.cogOuterTaper)return;const r=2*Math.PI,a=r/(2*o.cogNotches),n=a*o.cogInnerTaper*.005,i=a*o.cogOuterTaper*.005,s=t*o.cogInnerRadius/100;let c=a,g=!1;for(e.moveTo(t*Math.cos(i),t*Math.sin(i));c<=r;c+=a)g?(e.lineTo(s*Math.cos(c-n),s*Math.sin(c-n)),e.lineTo(t*Math.cos(c+i),t*Math.sin(c+i))):(e.lineTo(t*Math.cos(c-i),t*Math.sin(c-i)),e.lineTo(s*Math.cos(c+n),s*Math.sin(c+n))),g=!g}particleInit(o,t){const r=t.shapeData;t.cogHoleRadius=(0,e.getRangeValue)(r?.holeRadius??44),t.cogInnerRadius=(0,e.getRangeValue)(r?.innerRadius??72),t.cogInnerTaper=(0,e.getRangeValue)(r?.innerTaper??35),t.cogNotches=(0,e.getRangeValue)(r?.notches??7),t.cogOuterTaper=(0,e.getRangeValue)(r?.outerTaper??50)}}async function t(e,t=!0){await e.addShape("cog",new o,t)}})(),a})()));
2
+ !function(e,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 t="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var r in t)("object"==typeof exports?exports:e)[r]=t[r]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},t={};function r(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return o[e](n,n.exports,r),n.exports}r.d=(e,o)=>{for(var t in o)r.o(o,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{r.r(a),r.d(a,{loadCogShape:()=>t});var e=r(533);class o{afterEffect(e){const{context:o,particle:t,radius:r}=e;if(void 0===t.cogHoleRadius||void 0===t.cogInnerRadius||void 0===t.cogInnerTaper||void 0===t.cogNotches||void 0===t.cogOuterTaper)return;const a=2*Math.PI,n=r*t.cogHoleRadius/100;o.globalCompositeOperation="destination-out",o.beginPath(),o.moveTo(n,0),o.arc(0,0,n,0,a),o.closePath(),o.fill(),o.globalCompositeOperation="source-over"}draw(e){const{context:o,particle:t,radius:r}=e;if(void 0===t.cogHoleRadius||void 0===t.cogInnerRadius||void 0===t.cogInnerTaper||void 0===t.cogNotches||void 0===t.cogOuterTaper)return;const a=2*Math.PI,n=a/(2*t.cogNotches),i=n*t.cogInnerTaper*.005,c=n*t.cogOuterTaper*.005,s=r*t.cogInnerRadius/100;let p=n,d=!1;for(o.moveTo(r*Math.cos(c),r*Math.sin(c));p<=a;p+=n)d?(o.lineTo(s*Math.cos(p-i),s*Math.sin(p-i)),o.lineTo(r*Math.cos(p+c),r*Math.sin(p+c))):(o.lineTo(r*Math.cos(p-c),r*Math.sin(p-c)),o.lineTo(s*Math.cos(p+i),s*Math.sin(p+i))),d=!d}particleInit(o,t){const r=t.shapeData;t.cogHoleRadius=(0,e.getRangeValue)(r?.holeRadius??44),t.cogInnerRadius=(0,e.getRangeValue)(r?.innerRadius??72),t.cogInnerTaper=(0,e.getRangeValue)(r?.innerTaper??35),t.cogNotches=(0,e.getRangeValue)(r?.notches??7),t.cogOuterTaper=(0,e.getRangeValue)(r?.outerTaper??50)}}async function t(e,t=!0){await e.addShape("cog",new o,t)}})(),a})()));
@@ -1 +1 @@
1
- /*! tsParticles Cog Shape v3.0.0-beta.1 by Matteo Bruni */
1
+ /*! tsParticles Cog Shape v3.0.0-beta.3 by Matteo Bruni */
@@ -1,7 +1,7 @@
1
- import { type Container, type IShapeDrawer } from "@tsparticles/engine";
1
+ import { type Container, type IShapeDrawData, type IShapeDrawer } from "@tsparticles/engine";
2
2
  import type { CogParticle } from "./CogParticle.js";
3
- export declare class CogDrawer implements IShapeDrawer {
4
- afterEffect(ctx: CanvasRenderingContext2D, particle: CogParticle, radius: number): void;
5
- draw(ctx: CanvasRenderingContext2D, particle: CogParticle, radius: number): void;
3
+ export declare class CogDrawer implements IShapeDrawer<CogParticle> {
4
+ afterEffect(data: IShapeDrawData<CogParticle>): void;
5
+ draw(data: IShapeDrawData<CogParticle>): void;
6
6
  particleInit(container: Container, particle: CogParticle): void;
7
7
  }
package/umd/CogDrawer.js CHANGED
@@ -12,7 +12,8 @@
12
12
  exports.CogDrawer = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class CogDrawer {
15
- afterEffect(ctx, particle, radius) {
15
+ afterEffect(data) {
16
+ const { context, particle, radius } = data;
16
17
  if (particle.cogHoleRadius === undefined ||
17
18
  particle.cogInnerRadius === undefined ||
18
19
  particle.cogInnerTaper === undefined ||
@@ -21,15 +22,16 @@
21
22
  return;
22
23
  }
23
24
  const pi2 = 2 * Math.PI, holeRadius = (radius * particle.cogHoleRadius) / 100;
24
- ctx.globalCompositeOperation = "destination-out";
25
- ctx.beginPath();
26
- ctx.moveTo(holeRadius, 0);
27
- ctx.arc(0, 0, holeRadius, 0, pi2);
28
- ctx.closePath();
29
- ctx.fill();
30
- ctx.globalCompositeOperation = "source-over";
25
+ context.globalCompositeOperation = "destination-out";
26
+ context.beginPath();
27
+ context.moveTo(holeRadius, 0);
28
+ context.arc(0, 0, holeRadius, 0, pi2);
29
+ context.closePath();
30
+ context.fill();
31
+ context.globalCompositeOperation = "source-over";
31
32
  }
32
- draw(ctx, particle, radius) {
33
+ draw(data) {
34
+ const { context, particle, radius } = data;
33
35
  if (particle.cogHoleRadius === undefined ||
34
36
  particle.cogInnerRadius === undefined ||
35
37
  particle.cogInnerTaper === undefined ||
@@ -39,15 +41,15 @@
39
41
  }
40
42
  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;
41
43
  let a = angle, toggle = false;
42
- ctx.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
44
+ context.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
43
45
  for (; a <= pi2; a += angle) {
44
46
  if (toggle) {
45
- ctx.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
46
- ctx.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
47
+ context.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
48
+ context.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
47
49
  }
48
50
  else {
49
- ctx.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
50
- ctx.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
51
+ context.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
52
+ context.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
51
53
  }
52
54
  toggle = !toggle;
53
55
  }