@tsparticles/shape-cards 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.
@@ -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.2
7
+ * v3.0.0-beta.4
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -61,18 +61,22 @@ __webpack_require__.d(__webpack_exports__, {
61
61
  });
62
62
 
63
63
  ;// CONCATENATED MODULE: ./dist/browser/Utils.js
64
- function drawPath(ctx, radius, path) {
64
+ function drawPath(data, path) {
65
65
  if (!path.segments.length || !path.segments[0].values.length) {
66
66
  return;
67
67
  }
68
- ctx.moveTo(path.segments[0].values[0].x * radius, path.segments[0].values[0].y * radius);
68
+ const {
69
+ context,
70
+ radius
71
+ } = data;
72
+ context.moveTo(path.segments[0].values[0].x * radius, path.segments[0].values[0].y * radius);
69
73
  for (let i = 0; i < path.segments.length; i++) {
70
74
  const segment = path.segments[i];
71
- ctx.bezierCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius, segment.values[3].x * radius, segment.values[3].y * radius);
75
+ context.bezierCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius, segment.values[3].x * radius, segment.values[3].y * radius);
72
76
  }
73
77
  for (let i = path.segments.length - 1; i >= 0; i--) {
74
78
  const segment = path.segments[i];
75
- ctx.bezierCurveTo(-segment.values[2].x * radius, segment.values[2].y * radius, -segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[0].x * radius, segment.values[0].y * radius);
79
+ context.bezierCurveTo(-segment.values[2].x * radius, segment.values[2].y * radius, -segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[0].x * radius, segment.values[0].y * radius);
76
80
  }
77
81
  }
78
82
  const n = 1.0 / 2;
@@ -317,23 +321,23 @@ const paths = {
317
321
  ;// CONCATENATED MODULE: ./dist/browser/CardsSuitsDrawers.js
318
322
 
319
323
  class SpadeDrawer {
320
- draw(context, _particle, radius) {
321
- drawPath(context, radius, paths.spade);
324
+ draw(data) {
325
+ drawPath(data, paths.spade);
322
326
  }
323
327
  }
324
328
  class HeartDrawer {
325
- draw(context, _particle, radius) {
326
- drawPath(context, radius, paths.heart);
329
+ draw(data) {
330
+ drawPath(data, paths.heart);
327
331
  }
328
332
  }
329
333
  class DiamondDrawer {
330
- draw(context, _particle, radius) {
331
- drawPath(context, radius, paths.diamond);
334
+ draw(data) {
335
+ drawPath(data, paths.diamond);
332
336
  }
333
337
  }
334
338
  class ClubDrawer {
335
- draw(context, _particle, radius) {
336
- drawPath(context, radius, paths.club);
339
+ draw(data) {
340
+ drawPath(data, paths.club);
337
341
  }
338
342
  }
339
343
  ;// CONCATENATED MODULE: ./dist/browser/index.js
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.shape.cards.min.js.LICENSE.txt */
2
- !function(e,s){if("object"==typeof exports&&"object"==typeof module)module.exports=s();else if("function"==typeof define&&define.amd)define([],s);else{var y=s();for(var a in y)("object"==typeof exports?exports:e)[a]=y[a]}}(this,(()=>(()=>{"use strict";var e={d:(s,y)=>{for(var a in y)e.o(y,a)&&!e.o(s,a)&&Object.defineProperty(s,a,{enumerable:!0,get:y[a]})},o:(e,s)=>Object.prototype.hasOwnProperty.call(e,s),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},s={};function y(e,s,y){if(y.segments.length&&y.segments[0].values.length){e.moveTo(y.segments[0].values[0].x*s,y.segments[0].values[0].y*s);for(let a=0;a<y.segments.length;a++){const x=y.segments[a];e.bezierCurveTo(x.values[1].x*s,x.values[1].y*s,x.values[2].x*s,x.values[2].y*s,x.values[3].x*s,x.values[3].y*s)}for(let a=y.segments.length-1;a>=0;a--){const x=y.segments[a];e.bezierCurveTo(-x.values[2].x*s,x.values[2].y*s,-x.values[1].x*s,x.values[1].y*s,-x.values[0].x*s,x.values[0].y*s)}}}e.r(s),e.d(s,{loadCardsShape:()=>o});const a=.5,x={heart:{segments:[{values:[{x:0,y:a},{x:0,y:a},{x:a,y:0},{x:a,y:-a/2}]},{values:[{x:a,y:-a/2},{x:a,y:-a/2},{x:a,y:-a},{x:a/2,y:-a}]},{values:[{x:a/2,y:-a},{x:a/2,y:-a},{x:0,y:-a},{x:0,y:-a/2}]}]},diamond:{segments:[{values:[{x:0,y:a},{x:0,y:a},{x:.375,y:0},{x:.375,y:0}]},{values:[{x:.375,y:0},{x:.375,y:0},{x:0,y:-a},{x:0,y:-a}]}]},club:{segments:[{values:[{x:0,y:-a},{x:0,y:-a},{x:a/2,y:-a},{x:a/2,y:-a/2}]},{values:[{x:a/2,y:-a/2},{x:a/2,y:-a/2},{x:a,y:-a/2},{x:a,y:0}]},{values:[{x:a,y:0},{x:a,y:0},{x:a,y:a/2},{x:a/2,y:a/2}]},{values:[{x:a/2,y:a/2},{x:a/2,y:a/2},{x:a/8,y:a/2},{x:a/8,y:a/8}]},{values:[{x:a/8,y:a/8},{x:a/8,y:a/2},{x:a/2,y:a},{x:a/2,y:a}]},{values:[{x:a/2,y:a},{x:a/2,y:a},{x:0,y:a},{x:0,y:a}]}]},spade:{segments:[{values:[{x:0,y:-a},{x:0,y:-a},{x:a,y:-a/2},{x:a,y:0}]},{values:[{x:a,y:0},{x:a,y:0},{x:a,y:a/2},{x:a/2,y:a/2}]},{values:[{x:a/2,y:a/2},{x:a/2,y:a/2},{x:a/8,y:a/2},{x:a/8,y:a/8}]},{values:[{x:a/8,y:a/8},{x:a/8,y:a/2},{x:a/2,y:a},{x:a/2,y:a}]},{values:[{x:a/2,y:a},{x:a/2,y:a},{x:0,y:a},{x:0,y:a}]}]}};class t{draw(e,s,a){y(e,a,x.spade)}}class l{draw(e,s,a){y(e,a,x.heart)}}class n{draw(e,s,a){y(e,a,x.diamond)}}class u{draw(e,s,a){y(e,a,x.club)}}async function o(e,s=!0){await e.addShape(["spade","spades"],new t,s),await e.addShape(["heart","hearts"],new l,s),await e.addShape(["diamond","diamonds"],new n,s),await e.addShape(["club","clubs"],new u,s)}return s})()));
2
+ !function(e,s){if("object"==typeof exports&&"object"==typeof module)module.exports=s();else if("function"==typeof define&&define.amd)define([],s);else{var y=s();for(var a in y)("object"==typeof exports?exports:e)[a]=y[a]}}(this,(()=>(()=>{"use strict";var e={d:(s,y)=>{for(var a in y)e.o(y,a)&&!e.o(s,a)&&Object.defineProperty(s,a,{enumerable:!0,get:y[a]})},o:(e,s)=>Object.prototype.hasOwnProperty.call(e,s),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},s={};function y(e,s){if(!s.segments.length||!s.segments[0].values.length)return;const{context:y,radius:a}=e;y.moveTo(s.segments[0].values[0].x*a,s.segments[0].values[0].y*a);for(let e=0;e<s.segments.length;e++){const x=s.segments[e];y.bezierCurveTo(x.values[1].x*a,x.values[1].y*a,x.values[2].x*a,x.values[2].y*a,x.values[3].x*a,x.values[3].y*a)}for(let e=s.segments.length-1;e>=0;e--){const x=s.segments[e];y.bezierCurveTo(-x.values[2].x*a,x.values[2].y*a,-x.values[1].x*a,x.values[1].y*a,-x.values[0].x*a,x.values[0].y*a)}}e.r(s),e.d(s,{loadCardsShape:()=>o});const a=.5,x={heart:{segments:[{values:[{x:0,y:a},{x:0,y:a},{x:a,y:0},{x:a,y:-a/2}]},{values:[{x:a,y:-a/2},{x:a,y:-a/2},{x:a,y:-a},{x:a/2,y:-a}]},{values:[{x:a/2,y:-a},{x:a/2,y:-a},{x:0,y:-a},{x:0,y:-a/2}]}]},diamond:{segments:[{values:[{x:0,y:a},{x:0,y:a},{x:.375,y:0},{x:.375,y:0}]},{values:[{x:.375,y:0},{x:.375,y:0},{x:0,y:-a},{x:0,y:-a}]}]},club:{segments:[{values:[{x:0,y:-a},{x:0,y:-a},{x:a/2,y:-a},{x:a/2,y:-a/2}]},{values:[{x:a/2,y:-a/2},{x:a/2,y:-a/2},{x:a,y:-a/2},{x:a,y:0}]},{values:[{x:a,y:0},{x:a,y:0},{x:a,y:a/2},{x:a/2,y:a/2}]},{values:[{x:a/2,y:a/2},{x:a/2,y:a/2},{x:a/8,y:a/2},{x:a/8,y:a/8}]},{values:[{x:a/8,y:a/8},{x:a/8,y:a/2},{x:a/2,y:a},{x:a/2,y:a}]},{values:[{x:a/2,y:a},{x:a/2,y:a},{x:0,y:a},{x:0,y:a}]}]},spade:{segments:[{values:[{x:0,y:-a},{x:0,y:-a},{x:a,y:-a/2},{x:a,y:0}]},{values:[{x:a,y:0},{x:a,y:0},{x:a,y:a/2},{x:a/2,y:a/2}]},{values:[{x:a/2,y:a/2},{x:a/2,y:a/2},{x:a/8,y:a/2},{x:a/8,y:a/8}]},{values:[{x:a/8,y:a/8},{x:a/8,y:a/2},{x:a/2,y:a},{x:a/2,y:a}]},{values:[{x:a/2,y:a},{x:a/2,y:a},{x:0,y:a},{x:0,y:a}]}]}};class t{draw(e){y(e,x.spade)}}class l{draw(e){y(e,x.heart)}}class n{draw(e){y(e,x.diamond)}}class u{draw(e){y(e,x.club)}}async function o(e,s=!0){await e.addShape(["spade","spades"],new t,s),await e.addShape(["heart","hearts"],new l,s),await e.addShape(["diamond","diamonds"],new n,s),await e.addShape(["club","clubs"],new u,s)}return s})()));
@@ -1 +1 @@
1
- /*! tsParticles Cards Shape v3.0.0-beta.2 by Matteo Bruni */
1
+ /*! tsParticles Cards Shape v3.0.0-beta.4 by Matteo Bruni */
@@ -1,13 +1,13 @@
1
- import type { IParticle, IShapeDrawer } from "@tsparticles/engine";
1
+ import type { IShapeDrawData, IShapeDrawer } from "@tsparticles/engine";
2
2
  export declare class SpadeDrawer implements IShapeDrawer {
3
- draw(context: CanvasRenderingContext2D, _particle: IParticle, radius: number): void;
3
+ draw(data: IShapeDrawData): void;
4
4
  }
5
5
  export declare class HeartDrawer implements IShapeDrawer {
6
- draw(context: CanvasRenderingContext2D, _particle: IParticle, radius: number): void;
6
+ draw(data: IShapeDrawData): void;
7
7
  }
8
8
  export declare class DiamondDrawer implements IShapeDrawer {
9
- draw(context: CanvasRenderingContext2D, _particle: IParticle, radius: number): void;
9
+ draw(data: IShapeDrawData): void;
10
10
  }
11
11
  export declare class ClubDrawer implements IShapeDrawer {
12
- draw(context: CanvasRenderingContext2D, _particle: IParticle, radius: number): void;
12
+ draw(data: IShapeDrawData): void;
13
13
  }
package/types/Utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { ICardsPath, IPath } from "./ICardsPath.js";
2
- export declare function drawPath(ctx: CanvasRenderingContext2D, radius: number, path: IPath): void;
2
+ import type { IShapeDrawData } from "@tsparticles/engine";
3
+ export declare function drawPath(data: IShapeDrawData, path: IPath): void;
3
4
  export declare const paths: ICardsPath;
@@ -12,26 +12,26 @@
12
12
  exports.ClubDrawer = exports.DiamondDrawer = exports.HeartDrawer = exports.SpadeDrawer = void 0;
13
13
  const Utils_js_1 = require("./Utils.js");
14
14
  class SpadeDrawer {
15
- draw(context, _particle, radius) {
16
- (0, Utils_js_1.drawPath)(context, radius, Utils_js_1.paths.spade);
15
+ draw(data) {
16
+ (0, Utils_js_1.drawPath)(data, Utils_js_1.paths.spade);
17
17
  }
18
18
  }
19
19
  exports.SpadeDrawer = SpadeDrawer;
20
20
  class HeartDrawer {
21
- draw(context, _particle, radius) {
22
- (0, Utils_js_1.drawPath)(context, radius, Utils_js_1.paths.heart);
21
+ draw(data) {
22
+ (0, Utils_js_1.drawPath)(data, Utils_js_1.paths.heart);
23
23
  }
24
24
  }
25
25
  exports.HeartDrawer = HeartDrawer;
26
26
  class DiamondDrawer {
27
- draw(context, _particle, radius) {
28
- (0, Utils_js_1.drawPath)(context, radius, Utils_js_1.paths.diamond);
27
+ draw(data) {
28
+ (0, Utils_js_1.drawPath)(data, Utils_js_1.paths.diamond);
29
29
  }
30
30
  }
31
31
  exports.DiamondDrawer = DiamondDrawer;
32
32
  class ClubDrawer {
33
- draw(context, _particle, radius) {
34
- (0, Utils_js_1.drawPath)(context, radius, Utils_js_1.paths.club);
33
+ draw(data) {
34
+ (0, Utils_js_1.drawPath)(data, Utils_js_1.paths.club);
35
35
  }
36
36
  }
37
37
  exports.ClubDrawer = ClubDrawer;
package/umd/Utils.js CHANGED
@@ -10,18 +10,19 @@
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.paths = exports.drawPath = void 0;
13
- function drawPath(ctx, radius, path) {
13
+ function drawPath(data, path) {
14
14
  if (!path.segments.length || !path.segments[0].values.length) {
15
15
  return;
16
16
  }
17
- ctx.moveTo(path.segments[0].values[0].x * radius, path.segments[0].values[0].y * radius);
17
+ const { context, radius } = data;
18
+ context.moveTo(path.segments[0].values[0].x * radius, path.segments[0].values[0].y * radius);
18
19
  for (let i = 0; i < path.segments.length; i++) {
19
20
  const segment = path.segments[i];
20
- ctx.bezierCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius, segment.values[3].x * radius, segment.values[3].y * radius);
21
+ context.bezierCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius, segment.values[3].x * radius, segment.values[3].y * radius);
21
22
  }
22
23
  for (let i = path.segments.length - 1; i >= 0; i--) {
23
24
  const segment = path.segments[i];
24
- ctx.bezierCurveTo(-segment.values[2].x * radius, segment.values[2].y * radius, -segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[0].x * radius, segment.values[0].y * radius);
25
+ context.bezierCurveTo(-segment.values[2].x * radius, segment.values[2].y * radius, -segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[0].x * radius, segment.values[0].y * radius);
25
26
  }
26
27
  }
27
28
  exports.drawPath = drawPath;