@tsparticles/shape-cards 4.0.0-alpha.4 → 4.0.0-alpha.8

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.
Files changed (113) hide show
  1. package/35.min.js +2 -0
  2. package/35.min.js.LICENSE.txt +1 -0
  3. package/475.min.js +1 -1
  4. package/475.min.js.LICENSE.txt +1 -1
  5. package/505.min.js +1 -1
  6. package/505.min.js.LICENSE.txt +1 -1
  7. package/657.min.js +1 -1
  8. package/657.min.js.LICENSE.txt +1 -1
  9. package/741.min.js +1 -1
  10. package/741.min.js.LICENSE.txt +1 -1
  11. package/README.md +1 -1
  12. package/browser/CardValue.js +16 -0
  13. package/browser/SuitType.js +7 -0
  14. package/browser/cards/CardDrawer.js +21 -0
  15. package/browser/cards/index.js +7 -0
  16. package/browser/clubs/ClubDrawer.js +4 -2
  17. package/browser/clubs/index.js +3 -3
  18. package/browser/diamonds/DiamondDrawer.js +4 -2
  19. package/browser/diamonds/index.js +3 -3
  20. package/browser/hearts/HeartDrawer.js +4 -2
  21. package/browser/hearts/index.js +3 -3
  22. package/browser/index.js +17 -8
  23. package/browser/paths.js +174 -0
  24. package/browser/spades/SpadeDrawer.js +4 -2
  25. package/browser/spades/index.js +3 -3
  26. package/browser/utils.js +90 -0
  27. package/cjs/CardParticle.js +1 -0
  28. package/cjs/CardValue.js +16 -0
  29. package/cjs/ICardData.js +1 -0
  30. package/cjs/ICardSuitsPath.js +1 -0
  31. package/cjs/SuitType.js +7 -0
  32. package/cjs/cards/CardDrawer.js +21 -0
  33. package/cjs/cards/index.js +7 -0
  34. package/cjs/clubs/ClubDrawer.js +4 -2
  35. package/cjs/clubs/index.js +3 -3
  36. package/cjs/diamonds/DiamondDrawer.js +4 -2
  37. package/cjs/diamonds/index.js +3 -3
  38. package/cjs/hearts/HeartDrawer.js +4 -2
  39. package/cjs/hearts/index.js +3 -3
  40. package/cjs/index.js +17 -8
  41. package/cjs/paths.js +174 -0
  42. package/cjs/spades/SpadeDrawer.js +4 -2
  43. package/cjs/spades/index.js +3 -3
  44. package/cjs/utils.js +90 -0
  45. package/dist_browser_cards_CardDrawer_js.js +60 -0
  46. package/dist_browser_clubs_ClubDrawer_js.js +17 -7
  47. package/dist_browser_diamonds_DiamondDrawer_js.js +17 -7
  48. package/dist_browser_hearts_HeartDrawer_js.js +17 -7
  49. package/dist_browser_spades_SpadeDrawer_js.js +15 -5
  50. package/esm/CardParticle.js +1 -0
  51. package/esm/CardValue.js +16 -0
  52. package/esm/ICardData.js +1 -0
  53. package/esm/ICardSuitsPath.js +1 -0
  54. package/esm/SuitType.js +7 -0
  55. package/esm/cards/CardDrawer.js +21 -0
  56. package/esm/cards/index.js +7 -0
  57. package/esm/clubs/ClubDrawer.js +4 -2
  58. package/esm/clubs/index.js +3 -3
  59. package/esm/diamonds/DiamondDrawer.js +4 -2
  60. package/esm/diamonds/index.js +3 -3
  61. package/esm/hearts/HeartDrawer.js +4 -2
  62. package/esm/hearts/index.js +3 -3
  63. package/esm/index.js +17 -8
  64. package/esm/paths.js +174 -0
  65. package/esm/spades/SpadeDrawer.js +4 -2
  66. package/esm/spades/index.js +3 -3
  67. package/esm/utils.js +90 -0
  68. package/package.json +3 -2
  69. package/report.html +3 -3
  70. package/tsparticles.shape.cards.js +40 -10
  71. package/tsparticles.shape.cards.min.js +1 -1
  72. package/tsparticles.shape.cards.min.js.LICENSE.txt +1 -1
  73. package/types/CardParticle.d.ts +5 -0
  74. package/types/CardValue.d.ts +15 -0
  75. package/types/ICardData.d.ts +7 -0
  76. package/types/ICardSuitsPath.d.ts +3 -0
  77. package/types/SuitType.d.ts +6 -0
  78. package/types/cards/CardDrawer.d.ts +7 -0
  79. package/types/cards/index.d.ts +2 -0
  80. package/types/clubs/index.d.ts +1 -1
  81. package/types/diamonds/index.d.ts +1 -1
  82. package/types/hearts/index.d.ts +1 -1
  83. package/types/index.d.ts +3 -1
  84. package/types/paths.d.ts +7 -0
  85. package/types/spades/index.d.ts +1 -1
  86. package/types/utils.d.ts +2 -0
  87. package/umd/CardValue.js +29 -0
  88. package/umd/ICardData.js +12 -0
  89. package/umd/ICardSuitsPath.js +12 -0
  90. package/umd/SuitType.js +20 -0
  91. package/umd/cards/CardDrawer.js +35 -0
  92. package/umd/cards/index.js +54 -0
  93. package/umd/clubs/ClubDrawer.js +5 -3
  94. package/umd/clubs/index.js +4 -4
  95. package/umd/diamonds/DiamondDrawer.js +5 -3
  96. package/umd/diamonds/index.js +4 -4
  97. package/umd/hearts/HeartDrawer.js +5 -3
  98. package/umd/hearts/index.js +4 -4
  99. package/umd/index.js +19 -9
  100. package/umd/paths.js +187 -0
  101. package/umd/spades/SpadeDrawer.js +5 -3
  102. package/umd/spades/index.js +4 -4
  103. package/umd/utils.js +103 -0
  104. package/browser/Utils.js +0 -161
  105. package/cjs/Utils.js +0 -161
  106. package/esm/Utils.js +0 -161
  107. package/types/ICardsPath.d.ts +0 -13
  108. package/types/Utils.d.ts +0 -4
  109. package/umd/Utils.js +0 -175
  110. /package/browser/{ICardsPath.js → CardParticle.js} +0 -0
  111. /package/{cjs/ICardsPath.js → browser/ICardData.js} +0 -0
  112. /package/{esm/ICardsPath.js → browser/ICardSuitsPath.js} +0 -0
  113. /package/umd/{ICardsPath.js → CardParticle.js} +0 -0
package/35.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 35.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[35],{35(e,t,y){y.d(t,{CardDrawer:()=>u});var a=y(303),s=y(355),r=y(580),l=y(792);const i=a.double*a.double/a.triple,n=a.double,p=new Map;function x(e,t,y,s,r){if(r)!function(e,t){m(e,t)}(e,t);else{const r=function(e,t){return`${e.toFixed(2)}-${t.suit}-${t.value}`}(t,y),l=t*i,x=t*n,m=l*a.half,u=x*a.half;if(!p.has(r)){const e=new OffscreenCanvas(l,x),a=e.getContext("2d");a&&(a.translate(m,u),o(a,t,y,s),p.set(r,e))}const g=p.get(r);g?e.drawImage(g,-m,-u,l,x):o(e,t,y,s)}}function o(e,t,y,p){const{suit:x,value:o}=y,u=t*n,g=t*i*a.half,c=u*a.half,d=.2*t,h=.4*t,f=.3*t,b=.9*t,v=.25*t,T=.1*t,S=x===s.U.hearts||x===s.U.diamonds?(0,a.getStyleFromRgb)({r:255,g:0,b:0},p):(0,a.getStyleFromRgb)({r:0,g:0,b:0},p);e.save(),m(e,t),e.fillStyle=(0,a.getStyleFromRgb)({r:255,g:255,b:255},p),e.fill(),e.strokeStyle=(0,a.getStyleFromRgb)({r:0,g:0,b:0},p),e.stroke(),e.fillStyle=S,e.font=`bold ${h.toString()}px Arial, serif`,e.textAlign="left",e.textBaseline="middle";const z=-g+d+T,P=-c+d+h*a.half;e.save(),e.translate(z,P),e.beginPath(),(0,r.drawPath)(e,f,l.f0[x]),e.fill(),e.restore(),e.fillText(o,z+v,P),e.save(),e.translate(g-d-T,c-d-h*a.half),e.rotate(Math.PI),e.save(),e.beginPath(),(0,r.drawPath)(e,f,l.f0[x]),e.fill(),e.restore(),e.fillText(o,a.originPoint.x+v,a.originPoint.y),e.restore(),e.save(),e.beginPath(),(0,r.drawPath)(e,b,l.f0[x]),e.fillStyle=S,e.fill(),e.restore(),e.beginPath(),e.arc(a.originPoint.x,a.originPoint.y,0,0,a.doublePI,!1),e.closePath(),e.restore()}function m(e,t){const y=t*n,s=t*i*a.half,r=y*a.half,l=.2*t;e.beginPath(),e.moveTo(-s+l,-r),e.lineTo(s-l,-r),e.quadraticCurveTo(s,-r,s,-r+l),e.lineTo(s,r-l),e.quadraticCurveTo(s,r,s-l,r),e.lineTo(-s+l,r),e.quadraticCurveTo(-s,r,-s,r-l),e.lineTo(-s,-r+l),e.quadraticCurveTo(-s,-r,-s+l,-r),e.closePath()}class u{constructor(){this.validTypes=["card"]}draw(e){const{context:t,particle:y,radius:a}=e;y.cardData&&x(t,a,y.cardData,y.container.hdr,y.isShowingBack())}particleInit(e,t){const y=t.shapeData;y&&(t.cardData=(0,a.deepExtend)({},y))}}},355(e,t,y){var a;y.d(t,{U:()=>a}),function(e){e.hearts="hearts",e.diamonds="diamonds",e.clubs="clubs",e.spades="spades"}(a||(a={}))},792(e,t,y){y.d(t,{f0:()=>h});var a=y(580),s=y(303),r=y(355);const l=s.quarter*s.half,i=s.half,n=i*s.half,p=-i,x=-n,o=i*l,m=i*s.threeQuarter,u={half:!0,segments:[{type:a.SegmentType.bezier,values:[{x:s.empty,y:p},{x:s.empty,y:p},{x:n,y:p},{x:n,y:x}]},{type:a.SegmentType.bezier,values:[{x:n,y:x},{x:n,y:x},{x:i,y:x},{x:i,y:s.empty}]},{type:a.SegmentType.bezier,values:[{x:i,y:s.empty},{x:i,y:s.empty},{x:i,y:n},{x:n,y:n}]},{type:a.SegmentType.bezier,values:[{x:n,y:n},{x:n,y:n},{x:o,y:n},{x:o,y:o}]},{type:a.SegmentType.bezier,values:[{x:o,y:o},{x:o,y:n},{x:n,y:i},{x:n,y:i}]},{type:a.SegmentType.bezier,values:[{x:n,y:i},{x:n,y:i},{x:s.empty,y:i},{x:s.empty,y:i}]}]},g={half:!0,segments:[{type:a.SegmentType.bezier,values:[{x:s.empty,y:i},{x:s.empty,y:i},{x:m,y:s.empty},{x:m,y:s.empty}]},{type:a.SegmentType.bezier,values:[{x:m,y:s.empty},{x:m,y:s.empty},{x:s.empty,y:p},{x:s.empty,y:p}]}]},c={half:!0,segments:[{type:a.SegmentType.bezier,values:[{x:s.empty,y:i},{x:s.empty,y:i},{x:i,y:s.empty},{x:i,y:x}]},{type:a.SegmentType.bezier,values:[{x:i,y:x},{x:i,y:x},{x:i,y:p},{x:n,y:p}]},{type:a.SegmentType.bezier,values:[{x:n,y:p},{x:n,y:p},{x:s.empty,y:p},{x:s.empty,y:x}]}]},d={half:!0,segments:[{type:a.SegmentType.bezier,values:[{x:s.empty,y:p},{x:s.empty,y:p},{x:i,y:x},{x:i,y:s.empty}]},{type:a.SegmentType.bezier,values:[{x:i,y:s.empty},{x:i,y:s.empty},{x:i,y:n},{x:n,y:n}]},{type:a.SegmentType.bezier,values:[{x:n,y:n},{x:n,y:n},{x:o,y:n},{x:o,y:o}]},{type:a.SegmentType.bezier,values:[{x:o,y:o},{x:o,y:n},{x:n,y:i},{x:n,y:i}]},{type:a.SegmentType.bezier,values:[{x:n,y:i},{x:n,y:i},{x:s.empty,y:i},{x:s.empty,y:i}]}]},h={[r.U.hearts]:c,[r.U.diamonds]:g,[r.U.clubs]:u,[r.U.spades]:d}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Cards Shape v4.0.0-alpha.8 by Matteo Bruni */
package/475.min.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 475.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[475],{413(e,s,x){function y(e,s){if(!s.segments.length||!s.segments[0].values.length)return;const{context:x,radius:y}=e;x.moveTo(s.segments[0].values[0].x*y,s.segments[0].values[0].y*y);for(const e of s.segments)x.bezierCurveTo(e.values[1].x*y,e.values[1].y*y,e.values[2].x*y,e.values[2].y*y,e.values[3].x*y,e.values[3].y*y);for(let e=s.segments.length-1;e>=0;e--){const a=s.segments[e];x.bezierCurveTo(-a.values[2].x*y,a.values[2].y*y,-a.values[1].x*y,a.values[1].y*y,-a.values[0].x*y,a.values[0].y*y)}}x.d(s,{f:()=>u,k:()=>y});const a=.5,u={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}]}]}}},475(e,s,x){x.d(s,{SpadeDrawer:()=>a});var y=x(413);class a{constructor(){this.validTypes=["spade","spades"]}draw(e){(0,y.k)(e,y.f.spade)}}}}]);
2
+ (this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[475],{355(e,y,t){var p;t.d(y,{U:()=>p}),function(e){e.hearts="hearts",e.diamonds="diamonds",e.clubs="clubs",e.spades="spades"}(p||(p={}))},475(e,y,t){t.d(y,{SpadeDrawer:()=>s});var p=t(580),x=t(792);class s{constructor(){this.validTypes=["spade","spades"]}draw(e){const{context:y,radius:t}=e;(0,p.drawPath)(y,t,x.f0.spades)}}},792(e,y,t){t.d(y,{f0:()=>v});var p=t(580),x=t(303),s=t(355);const a=x.quarter*x.half,m=x.half,r=m*x.half,n=-m,l=-r,i=m*a,u=m*x.threeQuarter,d={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:n},{x:x.empty,y:n},{x:r,y:n},{x:r,y:l}]},{type:p.SegmentType.bezier,values:[{x:r,y:l},{x:r,y:l},{x:m,y:l},{x:m,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:m,y:x.empty},{x:m,y:x.empty},{x:m,y:r},{x:r,y:r}]},{type:p.SegmentType.bezier,values:[{x:r,y:r},{x:r,y:r},{x:i,y:r},{x:i,y:i}]},{type:p.SegmentType.bezier,values:[{x:i,y:i},{x:i,y:r},{x:r,y:m},{x:r,y:m}]},{type:p.SegmentType.bezier,values:[{x:r,y:m},{x:r,y:m},{x:x.empty,y:m},{x:x.empty,y:m}]}]},b={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:m},{x:x.empty,y:m},{x:u,y:x.empty},{x:u,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:u,y:x.empty},{x:u,y:x.empty},{x:x.empty,y:n},{x:x.empty,y:n}]}]},g={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:m},{x:x.empty,y:m},{x:m,y:x.empty},{x:m,y:l}]},{type:p.SegmentType.bezier,values:[{x:m,y:l},{x:m,y:l},{x:m,y:n},{x:r,y:n}]},{type:p.SegmentType.bezier,values:[{x:r,y:n},{x:r,y:n},{x:x.empty,y:n},{x:x.empty,y:l}]}]},h={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:n},{x:x.empty,y:n},{x:m,y:l},{x:m,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:m,y:x.empty},{x:m,y:x.empty},{x:m,y:r},{x:r,y:r}]},{type:p.SegmentType.bezier,values:[{x:r,y:r},{x:r,y:r},{x:i,y:r},{x:i,y:i}]},{type:p.SegmentType.bezier,values:[{x:i,y:i},{x:i,y:r},{x:r,y:m},{x:r,y:m}]},{type:p.SegmentType.bezier,values:[{x:r,y:m},{x:r,y:m},{x:x.empty,y:m},{x:x.empty,y:m}]}]},v={[s.U.hearts]:g,[s.U.diamonds]:b,[s.U.clubs]:d,[s.U.spades]:h}}}]);
@@ -1 +1 @@
1
- /*! tsParticles Cards Shape v4.0.0-alpha.4 by Matteo Bruni */
1
+ /*! tsParticles Cards Shape v4.0.0-alpha.8 by Matteo Bruni */
package/505.min.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 505.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[505],{413(e,s,x){function y(e,s){if(!s.segments.length||!s.segments[0].values.length)return;const{context:x,radius:y}=e;x.moveTo(s.segments[0].values[0].x*y,s.segments[0].values[0].y*y);for(const e of s.segments)x.bezierCurveTo(e.values[1].x*y,e.values[1].y*y,e.values[2].x*y,e.values[2].y*y,e.values[3].x*y,e.values[3].y*y);for(let e=s.segments.length-1;e>=0;e--){const a=s.segments[e];x.bezierCurveTo(-a.values[2].x*y,a.values[2].y*y,-a.values[1].x*y,a.values[1].y*y,-a.values[0].x*y,a.values[0].y*y)}}x.d(s,{f:()=>u,k:()=>y});const a=.5,u={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}]}]}}},505(e,s,x){x.d(s,{DiamondDrawer:()=>a});var y=x(413);class a{constructor(){this.validTypes=["diamond","diamonds"]}draw(e){(0,y.k)(e,y.f.diamond)}}}}]);
2
+ (this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[505],{355(e,y,t){var p;t.d(y,{U:()=>p}),function(e){e.hearts="hearts",e.diamonds="diamonds",e.clubs="clubs",e.spades="spades"}(p||(p={}))},505(e,y,t){t.d(y,{DiamondDrawer:()=>s});var p=t(580),x=t(792);class s{constructor(){this.validTypes=["diamond","diamonds"]}draw(e){const{context:y,radius:t}=e;(0,p.drawPath)(y,t,x.f0.diamonds)}}},792(e,y,t){t.d(y,{f0:()=>v});var p=t(580),x=t(303),s=t(355);const a=x.quarter*x.half,m=x.half,r=m*x.half,n=-m,i=-r,l=m*a,u=m*x.threeQuarter,d={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:n},{x:x.empty,y:n},{x:r,y:n},{x:r,y:i}]},{type:p.SegmentType.bezier,values:[{x:r,y:i},{x:r,y:i},{x:m,y:i},{x:m,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:m,y:x.empty},{x:m,y:x.empty},{x:m,y:r},{x:r,y:r}]},{type:p.SegmentType.bezier,values:[{x:r,y:r},{x:r,y:r},{x:l,y:r},{x:l,y:l}]},{type:p.SegmentType.bezier,values:[{x:l,y:l},{x:l,y:r},{x:r,y:m},{x:r,y:m}]},{type:p.SegmentType.bezier,values:[{x:r,y:m},{x:r,y:m},{x:x.empty,y:m},{x:x.empty,y:m}]}]},b={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:m},{x:x.empty,y:m},{x:u,y:x.empty},{x:u,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:u,y:x.empty},{x:u,y:x.empty},{x:x.empty,y:n},{x:x.empty,y:n}]}]},g={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:m},{x:x.empty,y:m},{x:m,y:x.empty},{x:m,y:i}]},{type:p.SegmentType.bezier,values:[{x:m,y:i},{x:m,y:i},{x:m,y:n},{x:r,y:n}]},{type:p.SegmentType.bezier,values:[{x:r,y:n},{x:r,y:n},{x:x.empty,y:n},{x:x.empty,y:i}]}]},h={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:n},{x:x.empty,y:n},{x:m,y:i},{x:m,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:m,y:x.empty},{x:m,y:x.empty},{x:m,y:r},{x:r,y:r}]},{type:p.SegmentType.bezier,values:[{x:r,y:r},{x:r,y:r},{x:l,y:r},{x:l,y:l}]},{type:p.SegmentType.bezier,values:[{x:l,y:l},{x:l,y:r},{x:r,y:m},{x:r,y:m}]},{type:p.SegmentType.bezier,values:[{x:r,y:m},{x:r,y:m},{x:x.empty,y:m},{x:x.empty,y:m}]}]},v={[s.U.hearts]:g,[s.U.diamonds]:b,[s.U.clubs]:d,[s.U.spades]:h}}}]);
@@ -1 +1 @@
1
- /*! tsParticles Cards Shape v4.0.0-alpha.4 by Matteo Bruni */
1
+ /*! tsParticles Cards Shape v4.0.0-alpha.8 by Matteo Bruni */
package/657.min.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 657.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[657],{413(e,s,x){function y(e,s){if(!s.segments.length||!s.segments[0].values.length)return;const{context:x,radius:y}=e;x.moveTo(s.segments[0].values[0].x*y,s.segments[0].values[0].y*y);for(const e of s.segments)x.bezierCurveTo(e.values[1].x*y,e.values[1].y*y,e.values[2].x*y,e.values[2].y*y,e.values[3].x*y,e.values[3].y*y);for(let e=s.segments.length-1;e>=0;e--){const a=s.segments[e];x.bezierCurveTo(-a.values[2].x*y,a.values[2].y*y,-a.values[1].x*y,a.values[1].y*y,-a.values[0].x*y,a.values[0].y*y)}}x.d(s,{f:()=>u,k:()=>y});const a=.5,u={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}]}]}}},657(e,s,x){x.d(s,{HeartDrawer:()=>a});var y=x(413);class a{constructor(){this.validTypes=["heart","hearts"]}draw(e){(0,y.k)(e,y.f.heart)}}}}]);
2
+ (this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[657],{355(e,y,t){var p;t.d(y,{U:()=>p}),function(e){e.hearts="hearts",e.diamonds="diamonds",e.clubs="clubs",e.spades="spades"}(p||(p={}))},657(e,y,t){t.d(y,{HeartDrawer:()=>s});var p=t(580),x=t(792);class s{constructor(){this.validTypes=["heart","hearts"]}draw(e){const{context:y,radius:t}=e;(0,p.drawPath)(y,t,x.f0.hearts)}}},792(e,y,t){t.d(y,{f0:()=>d});var p=t(580),x=t(303),s=t(355);const a=x.quarter*x.half,m=x.half,r=m*x.half,n=-m,l=-r,i=m*a,u=m*x.threeQuarter,h={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:n},{x:x.empty,y:n},{x:r,y:n},{x:r,y:l}]},{type:p.SegmentType.bezier,values:[{x:r,y:l},{x:r,y:l},{x:m,y:l},{x:m,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:m,y:x.empty},{x:m,y:x.empty},{x:m,y:r},{x:r,y:r}]},{type:p.SegmentType.bezier,values:[{x:r,y:r},{x:r,y:r},{x:i,y:r},{x:i,y:i}]},{type:p.SegmentType.bezier,values:[{x:i,y:i},{x:i,y:r},{x:r,y:m},{x:r,y:m}]},{type:p.SegmentType.bezier,values:[{x:r,y:m},{x:r,y:m},{x:x.empty,y:m},{x:x.empty,y:m}]}]},b={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:m},{x:x.empty,y:m},{x:u,y:x.empty},{x:u,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:u,y:x.empty},{x:u,y:x.empty},{x:x.empty,y:n},{x:x.empty,y:n}]}]},g={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:m},{x:x.empty,y:m},{x:m,y:x.empty},{x:m,y:l}]},{type:p.SegmentType.bezier,values:[{x:m,y:l},{x:m,y:l},{x:m,y:n},{x:r,y:n}]},{type:p.SegmentType.bezier,values:[{x:r,y:n},{x:r,y:n},{x:x.empty,y:n},{x:x.empty,y:l}]}]},v={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:n},{x:x.empty,y:n},{x:m,y:l},{x:m,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:m,y:x.empty},{x:m,y:x.empty},{x:m,y:r},{x:r,y:r}]},{type:p.SegmentType.bezier,values:[{x:r,y:r},{x:r,y:r},{x:i,y:r},{x:i,y:i}]},{type:p.SegmentType.bezier,values:[{x:i,y:i},{x:i,y:r},{x:r,y:m},{x:r,y:m}]},{type:p.SegmentType.bezier,values:[{x:r,y:m},{x:r,y:m},{x:x.empty,y:m},{x:x.empty,y:m}]}]},d={[s.U.hearts]:g,[s.U.diamonds]:b,[s.U.clubs]:h,[s.U.spades]:v}}}]);
@@ -1 +1 @@
1
- /*! tsParticles Cards Shape v4.0.0-alpha.4 by Matteo Bruni */
1
+ /*! tsParticles Cards Shape v4.0.0-alpha.8 by Matteo Bruni */
package/741.min.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 741.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[741],{413(e,s,x){function y(e,s){if(!s.segments.length||!s.segments[0].values.length)return;const{context:x,radius:y}=e;x.moveTo(s.segments[0].values[0].x*y,s.segments[0].values[0].y*y);for(const e of s.segments)x.bezierCurveTo(e.values[1].x*y,e.values[1].y*y,e.values[2].x*y,e.values[2].y*y,e.values[3].x*y,e.values[3].y*y);for(let e=s.segments.length-1;e>=0;e--){const a=s.segments[e];x.bezierCurveTo(-a.values[2].x*y,a.values[2].y*y,-a.values[1].x*y,a.values[1].y*y,-a.values[0].x*y,a.values[0].y*y)}}x.d(s,{f:()=>u,k:()=>y});const a=.5,u={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}]}]}}},741(e,s,x){x.d(s,{ClubDrawer:()=>a});var y=x(413);class a{constructor(){this.validTypes=["club","clubs"]}draw(e){(0,y.k)(e,y.f.club)}}}}]);
2
+ (this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[741],{355(e,y,t){var p;t.d(y,{U:()=>p}),function(e){e.hearts="hearts",e.diamonds="diamonds",e.clubs="clubs",e.spades="spades"}(p||(p={}))},741(e,y,t){t.d(y,{ClubDrawer:()=>s});var p=t(580),x=t(792);class s{constructor(){this.validTypes=["club","clubs"]}draw(e){const{context:y,radius:t}=e;(0,p.drawPath)(y,t,x.f0.clubs)}}},792(e,y,t){t.d(y,{f0:()=>c});var p=t(580),x=t(303),s=t(355);const a=x.quarter*x.half,m=x.half,r=m*x.half,l=-m,n=-r,u=m*a,i=m*x.threeQuarter,b={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:l},{x:x.empty,y:l},{x:r,y:l},{x:r,y:n}]},{type:p.SegmentType.bezier,values:[{x:r,y:n},{x:r,y:n},{x:m,y:n},{x:m,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:m,y:x.empty},{x:m,y:x.empty},{x:m,y:r},{x:r,y:r}]},{type:p.SegmentType.bezier,values:[{x:r,y:r},{x:r,y:r},{x:u,y:r},{x:u,y:u}]},{type:p.SegmentType.bezier,values:[{x:u,y:u},{x:u,y:r},{x:r,y:m},{x:r,y:m}]},{type:p.SegmentType.bezier,values:[{x:r,y:m},{x:r,y:m},{x:x.empty,y:m},{x:x.empty,y:m}]}]},g={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:m},{x:x.empty,y:m},{x:i,y:x.empty},{x:i,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:i,y:x.empty},{x:i,y:x.empty},{x:x.empty,y:l},{x:x.empty,y:l}]}]},h={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:m},{x:x.empty,y:m},{x:m,y:x.empty},{x:m,y:n}]},{type:p.SegmentType.bezier,values:[{x:m,y:n},{x:m,y:n},{x:m,y:l},{x:r,y:l}]},{type:p.SegmentType.bezier,values:[{x:r,y:l},{x:r,y:l},{x:x.empty,y:l},{x:x.empty,y:n}]}]},v={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:l},{x:x.empty,y:l},{x:m,y:n},{x:m,y:x.empty}]},{type:p.SegmentType.bezier,values:[{x:m,y:x.empty},{x:m,y:x.empty},{x:m,y:r},{x:r,y:r}]},{type:p.SegmentType.bezier,values:[{x:r,y:r},{x:r,y:r},{x:u,y:r},{x:u,y:u}]},{type:p.SegmentType.bezier,values:[{x:u,y:u},{x:u,y:r},{x:r,y:m},{x:r,y:m}]},{type:p.SegmentType.bezier,values:[{x:r,y:m},{x:r,y:m},{x:x.empty,y:m},{x:x.empty,y:m}]}]},c={[s.U.hearts]:h,[s.U.diamonds]:g,[s.U.clubs]:b,[s.U.spades]:v}}}]);
@@ -1 +1 @@
1
- /*! tsParticles Cards Shape v4.0.0-alpha.4 by Matteo Bruni */
1
+ /*! tsParticles Cards Shape v4.0.0-alpha.8 by Matteo Bruni */
package/README.md CHANGED
@@ -26,7 +26,7 @@ Once the scripts are loaded you can set up `tsParticles` and the shape like this
26
26
 
27
27
  ```javascript
28
28
  (async () => {
29
- await loadCardsShape(tsParticles);
29
+ await loadFullCardsShape(tsParticles);
30
30
 
31
31
  await tsParticles.load({
32
32
  id: "tsparticles",
@@ -0,0 +1,16 @@
1
+ export var CardValue;
2
+ (function (CardValue) {
3
+ CardValue["ace"] = "A";
4
+ CardValue["two"] = "2";
5
+ CardValue["three"] = "3";
6
+ CardValue["four"] = "4";
7
+ CardValue["five"] = "5";
8
+ CardValue["six"] = "6";
9
+ CardValue["seven"] = "7";
10
+ CardValue["eight"] = "8";
11
+ CardValue["nine"] = "9";
12
+ CardValue["ten"] = "10";
13
+ CardValue["jack"] = "J";
14
+ CardValue["queen"] = "Q";
15
+ CardValue["king"] = "K";
16
+ })(CardValue || (CardValue = {}));
@@ -0,0 +1,7 @@
1
+ export var SuitType;
2
+ (function (SuitType) {
3
+ SuitType["hearts"] = "hearts";
4
+ SuitType["diamonds"] = "diamonds";
5
+ SuitType["clubs"] = "clubs";
6
+ SuitType["spades"] = "spades";
7
+ })(SuitType || (SuitType = {}));
@@ -0,0 +1,21 @@
1
+ import { deepExtend } from "@tsparticles/engine";
2
+ import { drawRoundedCard } from "../utils.js";
3
+ export class CardDrawer {
4
+ constructor() {
5
+ this.validTypes = ["card"];
6
+ }
7
+ draw(data) {
8
+ const { context, particle, radius } = data;
9
+ if (!particle.cardData) {
10
+ return;
11
+ }
12
+ drawRoundedCard(context, radius, particle.cardData, particle.container.hdr, particle.isShowingBack());
13
+ }
14
+ particleInit(_container, particle) {
15
+ const shape = particle.shapeData;
16
+ if (!shape) {
17
+ return;
18
+ }
19
+ particle.cardData = deepExtend({}, shape);
20
+ }
21
+ }
@@ -0,0 +1,7 @@
1
+ export async function loadFullCardsShape(engine) {
2
+ engine.checkVersion("4.0.0-alpha.8");
3
+ await engine.register(async (e) => {
4
+ const { CardDrawer } = await import("./CardDrawer.js");
5
+ e.addShape(new CardDrawer());
6
+ });
7
+ }
@@ -1,9 +1,11 @@
1
- import { drawPath, paths } from "../Utils.js";
1
+ import { drawPath } from "@tsparticles/path-utils";
2
+ import { paths } from "../paths.js";
2
3
  export class ClubDrawer {
3
4
  constructor() {
4
5
  this.validTypes = ["club", "clubs"];
5
6
  }
6
7
  draw(data) {
7
- drawPath(data, paths.club);
8
+ const { context, radius } = data;
9
+ drawPath(context, radius, paths.clubs);
8
10
  }
9
11
  }
@@ -1,6 +1,6 @@
1
- export function loadClubsCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.4");
3
- engine.register(async (e) => {
1
+ export async function loadClubsSuitShape(engine) {
2
+ engine.checkVersion("4.0.0-alpha.8");
3
+ await engine.register(async (e) => {
4
4
  const { ClubDrawer } = await import("./ClubDrawer.js");
5
5
  e.addShape(new ClubDrawer());
6
6
  });
@@ -1,9 +1,11 @@
1
- import { drawPath, paths } from "../Utils.js";
1
+ import { drawPath } from "@tsparticles/path-utils";
2
+ import { paths } from "../paths.js";
2
3
  export class DiamondDrawer {
3
4
  constructor() {
4
5
  this.validTypes = ["diamond", "diamonds"];
5
6
  }
6
7
  draw(data) {
7
- drawPath(data, paths.diamond);
8
+ const { context, radius } = data;
9
+ drawPath(context, radius, paths.diamonds);
8
10
  }
9
11
  }
@@ -1,6 +1,6 @@
1
- export function loadDiamondsCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.4");
3
- engine.register(async (e) => {
1
+ export async function loadDiamondsSuitShape(engine) {
2
+ engine.checkVersion("4.0.0-alpha.8");
3
+ await engine.register(async (e) => {
4
4
  const { DiamondDrawer } = await import("./DiamondDrawer.js");
5
5
  e.addShape(new DiamondDrawer());
6
6
  });
@@ -1,9 +1,11 @@
1
- import { drawPath, paths } from "../Utils.js";
1
+ import { drawPath } from "@tsparticles/path-utils";
2
+ import { paths } from "../paths.js";
2
3
  export class HeartDrawer {
3
4
  constructor() {
4
5
  this.validTypes = ["heart", "hearts"];
5
6
  }
6
7
  draw(data) {
7
- drawPath(data, paths.heart);
8
+ const { context, radius } = data;
9
+ drawPath(context, radius, paths.hearts);
8
10
  }
9
11
  }
@@ -1,6 +1,6 @@
1
- export function loadHeartsCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.4");
3
- engine.register(async (e) => {
1
+ export async function loadHeartsSuitShape(engine) {
2
+ engine.checkVersion("4.0.0-alpha.8");
3
+ await engine.register(async (e) => {
4
4
  const { HeartDrawer } = await import("./HeartDrawer.js");
5
5
  e.addShape(new HeartDrawer());
6
6
  });
package/browser/index.js CHANGED
@@ -1,13 +1,22 @@
1
- export function loadCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.4");
3
- engine.register(async (e) => {
4
- const { loadClubsCardsShape } = await import("./clubs/index.js"), { loadDiamondsCardsShape } = await import("./diamonds/index.js"), { loadHeartsCardsShape } = await import("./hearts/index.js"), { loadSpadesCardsShape } = await import("./spades/index.js");
5
- loadClubsCardsShape(e);
6
- loadDiamondsCardsShape(e);
7
- loadHeartsCardsShape(e);
8
- loadSpadesCardsShape(e);
1
+ export async function loadCardSuitsShape(engine) {
2
+ engine.checkVersion("4.0.0-alpha.8");
3
+ await engine.register(async (e) => {
4
+ const { loadClubsSuitShape } = await import("./clubs/index.js"), { loadDiamondsSuitShape } = await import("./diamonds/index.js"), { loadHeartsSuitShape } = await import("./hearts/index.js"), { loadSpadesSuitShape } = await import("./spades/index.js");
5
+ await loadClubsSuitShape(e);
6
+ await loadDiamondsSuitShape(e);
7
+ await loadHeartsSuitShape(e);
8
+ await loadSpadesSuitShape(e);
9
9
  });
10
10
  }
11
+ export async function loadCardsShape(engine) {
12
+ engine.checkVersion("4.0.0-alpha.8");
13
+ await engine.register(async (e) => {
14
+ const { loadFullCardsShape } = await import("./cards/index.js");
15
+ await loadFullCardsShape(e);
16
+ await loadCardSuitsShape(e);
17
+ });
18
+ }
19
+ export * from "./cards/index.js";
11
20
  export * from "./clubs/index.js";
12
21
  export * from "./diamonds/index.js";
13
22
  export * from "./hearts/index.js";
@@ -0,0 +1,174 @@
1
+ import { SegmentType } from "@tsparticles/path-utils";
2
+ import { empty, half, quarter, threeQuarter } from "@tsparticles/engine";
3
+ import { SuitType } from "./SuitType.js";
4
+ const eighth = quarter * half, n = half, halfN = n * half, oppositeN = -n, oppositeHalfN = -halfN, eighthN = n * eighth, threeQuarterN = n * threeQuarter;
5
+ export const club = {
6
+ half: true,
7
+ segments: [
8
+ {
9
+ type: SegmentType.bezier,
10
+ values: [
11
+ { x: empty, y: oppositeN },
12
+ { x: empty, y: oppositeN },
13
+ { x: halfN, y: oppositeN },
14
+ { x: halfN, y: oppositeHalfN },
15
+ ],
16
+ },
17
+ {
18
+ type: SegmentType.bezier,
19
+ values: [
20
+ { x: halfN, y: oppositeHalfN },
21
+ { x: halfN, y: oppositeHalfN },
22
+ { x: n, y: oppositeHalfN },
23
+ { x: n, y: empty },
24
+ ],
25
+ },
26
+ {
27
+ type: SegmentType.bezier,
28
+ values: [
29
+ { x: n, y: empty },
30
+ { x: n, y: empty },
31
+ { x: n, y: halfN },
32
+ { x: halfN, y: halfN },
33
+ ],
34
+ },
35
+ {
36
+ type: SegmentType.bezier,
37
+ values: [
38
+ { x: halfN, y: halfN },
39
+ { x: halfN, y: halfN },
40
+ { x: eighthN, y: halfN },
41
+ { x: eighthN, y: eighthN },
42
+ ],
43
+ },
44
+ {
45
+ type: SegmentType.bezier,
46
+ values: [
47
+ { x: eighthN, y: eighthN },
48
+ { x: eighthN, y: halfN },
49
+ { x: halfN, y: n },
50
+ { x: halfN, y: n },
51
+ ],
52
+ },
53
+ {
54
+ type: SegmentType.bezier,
55
+ values: [
56
+ { x: halfN, y: n },
57
+ { x: halfN, y: n },
58
+ { x: empty, y: n },
59
+ { x: empty, y: n },
60
+ ],
61
+ },
62
+ ],
63
+ };
64
+ export const diamond = {
65
+ half: true,
66
+ segments: [
67
+ {
68
+ type: SegmentType.bezier,
69
+ values: [
70
+ { x: empty, y: n },
71
+ { x: empty, y: n },
72
+ { x: threeQuarterN, y: empty },
73
+ { x: threeQuarterN, y: empty },
74
+ ],
75
+ },
76
+ {
77
+ type: SegmentType.bezier,
78
+ values: [
79
+ { x: threeQuarterN, y: empty },
80
+ { x: threeQuarterN, y: empty },
81
+ { x: empty, y: oppositeN },
82
+ { x: empty, y: oppositeN },
83
+ ],
84
+ },
85
+ ],
86
+ };
87
+ export const heart = {
88
+ half: true,
89
+ segments: [
90
+ {
91
+ type: SegmentType.bezier,
92
+ values: [
93
+ { x: empty, y: n },
94
+ { x: empty, y: n },
95
+ { x: n, y: empty },
96
+ { x: n, y: oppositeHalfN },
97
+ ],
98
+ },
99
+ {
100
+ type: SegmentType.bezier,
101
+ values: [
102
+ { x: n, y: oppositeHalfN },
103
+ { x: n, y: oppositeHalfN },
104
+ { x: n, y: oppositeN },
105
+ { x: halfN, y: oppositeN },
106
+ ],
107
+ },
108
+ {
109
+ type: SegmentType.bezier,
110
+ values: [
111
+ { x: halfN, y: oppositeN },
112
+ { x: halfN, y: oppositeN },
113
+ { x: empty, y: oppositeN },
114
+ { x: empty, y: oppositeHalfN },
115
+ ],
116
+ },
117
+ ],
118
+ };
119
+ export const spade = {
120
+ half: true,
121
+ segments: [
122
+ {
123
+ type: SegmentType.bezier,
124
+ values: [
125
+ { x: empty, y: oppositeN },
126
+ { x: empty, y: oppositeN },
127
+ { x: n, y: oppositeHalfN },
128
+ { x: n, y: empty },
129
+ ],
130
+ },
131
+ {
132
+ type: SegmentType.bezier,
133
+ values: [
134
+ { x: n, y: empty },
135
+ { x: n, y: empty },
136
+ { x: n, y: halfN },
137
+ { x: halfN, y: halfN },
138
+ ],
139
+ },
140
+ {
141
+ type: SegmentType.bezier,
142
+ values: [
143
+ { x: halfN, y: halfN },
144
+ { x: halfN, y: halfN },
145
+ { x: eighthN, y: halfN },
146
+ { x: eighthN, y: eighthN },
147
+ ],
148
+ },
149
+ {
150
+ type: SegmentType.bezier,
151
+ values: [
152
+ { x: eighthN, y: eighthN },
153
+ { x: eighthN, y: halfN },
154
+ { x: halfN, y: n },
155
+ { x: halfN, y: n },
156
+ ],
157
+ },
158
+ {
159
+ type: SegmentType.bezier,
160
+ values: [
161
+ { x: halfN, y: n },
162
+ { x: halfN, y: n },
163
+ { x: empty, y: n },
164
+ { x: empty, y: n },
165
+ ],
166
+ },
167
+ ],
168
+ };
169
+ export const paths = {
170
+ [SuitType.hearts]: heart,
171
+ [SuitType.diamonds]: diamond,
172
+ [SuitType.clubs]: club,
173
+ [SuitType.spades]: spade,
174
+ };
@@ -1,9 +1,11 @@
1
- import { drawPath, paths } from "../Utils.js";
1
+ import { drawPath } from "@tsparticles/path-utils";
2
+ import { paths } from "../paths.js";
2
3
  export class SpadeDrawer {
3
4
  constructor() {
4
5
  this.validTypes = ["spade", "spades"];
5
6
  }
6
7
  draw(data) {
7
- drawPath(data, paths.spade);
8
+ const { context, radius } = data;
9
+ drawPath(context, radius, paths.spades);
8
10
  }
9
11
  }
@@ -1,6 +1,6 @@
1
- export function loadSpadesCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.4");
3
- engine.register(async (e) => {
1
+ export async function loadSpadesSuitShape(engine) {
2
+ engine.checkVersion("4.0.0-alpha.8");
3
+ await engine.register(async (e) => {
4
4
  const { SpadeDrawer } = await import("./SpadeDrawer.js");
5
5
  e.addShape(new SpadeDrawer());
6
6
  });
@@ -0,0 +1,90 @@
1
+ import { double, doublePI, getStyleFromRgb, half, originPoint, triple } from "@tsparticles/engine";
2
+ import { SuitType } from "./SuitType.js";
3
+ import { drawPath } from "@tsparticles/path-utils";
4
+ import { paths } from "./paths.js";
5
+ const cardWidthRatio = (double * double) / triple, cardHeightRatio = double, cornerRadiusRatio = 0.2, cornerFontRatio = 0.4, cornerSuitRatio = 0.3, centerSuitRatio = 0.9, cornerPaddingRatio = 0.2, textHorizontalOffsetRatio = 0.25, minRadius = 0, minAngle = 0, suitEdgeBufferFactor = 0.1, fixedCacheKey = 2, cardsCache = new Map();
6
+ export function drawRoundedCard(ctx, radius, cardData, hdr, flipped) {
7
+ if (flipped) {
8
+ drawRoundedCardBack(ctx, radius);
9
+ }
10
+ else {
11
+ const cacheKey = getCacheKey(radius, cardData), cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * half, halfHeight = cardHeight * half;
12
+ if (!cardsCache.has(cacheKey)) {
13
+ const canvas = new OffscreenCanvas(cardWidth, cardHeight), offCtx = canvas.getContext("2d");
14
+ if (offCtx) {
15
+ offCtx.translate(halfWidth, halfHeight);
16
+ drawRoundedCardFront(offCtx, radius, cardData, hdr);
17
+ cardsCache.set(cacheKey, canvas);
18
+ }
19
+ }
20
+ const cachedCanvas = cardsCache.get(cacheKey);
21
+ if (cachedCanvas) {
22
+ ctx.drawImage(cachedCanvas, -halfWidth, -halfHeight, cardWidth, cardHeight);
23
+ }
24
+ else {
25
+ drawRoundedCardFront(ctx, radius, cardData, hdr);
26
+ }
27
+ }
28
+ }
29
+ function getCacheKey(radius, cardData) {
30
+ return `${radius.toFixed(fixedCacheKey)}-${cardData.suit}-${cardData.value}`;
31
+ }
32
+ function drawRoundedCardBack(ctx, radius) {
33
+ drawCardBody(ctx, radius);
34
+ }
35
+ function drawRoundedCardFront(ctx, radius, cardData, hdr) {
36
+ const { suit, value } = cardData, cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * half, halfHeight = cardHeight * half, cornerPadding = radius * cornerPaddingRatio, cornerFontSize = radius * cornerFontRatio, cornerSuitSize = radius * cornerSuitRatio, centerSuitSize = radius * centerSuitRatio, textOffset = radius * textHorizontalOffsetRatio, suitEdgeBuffer = radius * suitEdgeBufferFactor, isRed = suit === SuitType.hearts || suit === SuitType.diamonds, color = isRed ? getStyleFromRgb({ r: 255, g: 0, b: 0 }, hdr) : getStyleFromRgb({ r: 0, g: 0, b: 0 }, hdr);
37
+ ctx.save();
38
+ drawCardBody(ctx, radius);
39
+ ctx.fillStyle = getStyleFromRgb({ r: 255, g: 255, b: 255 }, hdr);
40
+ ctx.fill();
41
+ ctx.strokeStyle = getStyleFromRgb({ r: 0, g: 0, b: 0 }, hdr);
42
+ ctx.stroke();
43
+ ctx.fillStyle = color;
44
+ ctx.font = `bold ${cornerFontSize.toString()}px Arial, serif`;
45
+ ctx.textAlign = "left";
46
+ ctx.textBaseline = "middle";
47
+ const topLeftX = -halfWidth + cornerPadding + suitEdgeBuffer;
48
+ const topLeftY = -halfHeight + cornerPadding + cornerFontSize * half;
49
+ ctx.save();
50
+ ctx.translate(topLeftX, topLeftY);
51
+ ctx.beginPath();
52
+ drawPath(ctx, cornerSuitSize, paths[suit]);
53
+ ctx.fill();
54
+ ctx.restore();
55
+ ctx.fillText(value, topLeftX + textOffset, topLeftY);
56
+ ctx.save();
57
+ ctx.translate(halfWidth - cornerPadding - suitEdgeBuffer, halfHeight - cornerPadding - cornerFontSize * half);
58
+ ctx.rotate(Math.PI);
59
+ ctx.save();
60
+ ctx.beginPath();
61
+ drawPath(ctx, cornerSuitSize, paths[suit]);
62
+ ctx.fill();
63
+ ctx.restore();
64
+ ctx.fillText(value, originPoint.x + textOffset, originPoint.y);
65
+ ctx.restore();
66
+ ctx.save();
67
+ ctx.beginPath();
68
+ drawPath(ctx, centerSuitSize, paths[suit]);
69
+ ctx.fillStyle = color;
70
+ ctx.fill();
71
+ ctx.restore();
72
+ ctx.beginPath();
73
+ ctx.arc(originPoint.x, originPoint.y, minRadius, minAngle, doublePI, false);
74
+ ctx.closePath();
75
+ ctx.restore();
76
+ }
77
+ function drawCardBody(ctx, radius) {
78
+ const cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * half, halfHeight = cardHeight * half, cornerRadius = radius * cornerRadiusRatio;
79
+ ctx.beginPath();
80
+ ctx.moveTo(-halfWidth + cornerRadius, -halfHeight);
81
+ ctx.lineTo(halfWidth - cornerRadius, -halfHeight);
82
+ ctx.quadraticCurveTo(halfWidth, -halfHeight, halfWidth, -halfHeight + cornerRadius);
83
+ ctx.lineTo(halfWidth, halfHeight - cornerRadius);
84
+ ctx.quadraticCurveTo(halfWidth, halfHeight, halfWidth - cornerRadius, halfHeight);
85
+ ctx.lineTo(-halfWidth + cornerRadius, halfHeight);
86
+ ctx.quadraticCurveTo(-halfWidth, halfHeight, -halfWidth, halfHeight - cornerRadius);
87
+ ctx.lineTo(-halfWidth, -halfHeight + cornerRadius);
88
+ ctx.quadraticCurveTo(-halfWidth, -halfHeight, -halfWidth + cornerRadius, -halfHeight);
89
+ ctx.closePath();
90
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ export var CardValue;
2
+ (function (CardValue) {
3
+ CardValue["ace"] = "A";
4
+ CardValue["two"] = "2";
5
+ CardValue["three"] = "3";
6
+ CardValue["four"] = "4";
7
+ CardValue["five"] = "5";
8
+ CardValue["six"] = "6";
9
+ CardValue["seven"] = "7";
10
+ CardValue["eight"] = "8";
11
+ CardValue["nine"] = "9";
12
+ CardValue["ten"] = "10";
13
+ CardValue["jack"] = "J";
14
+ CardValue["queen"] = "Q";
15
+ CardValue["king"] = "K";
16
+ })(CardValue || (CardValue = {}));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export var SuitType;
2
+ (function (SuitType) {
3
+ SuitType["hearts"] = "hearts";
4
+ SuitType["diamonds"] = "diamonds";
5
+ SuitType["clubs"] = "clubs";
6
+ SuitType["spades"] = "spades";
7
+ })(SuitType || (SuitType = {}));