@tsparticles/shape-cards 4.0.0-alpha.5 → 4.0.0-beta.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.
Files changed (120) hide show
  1. package/111.min.js +1 -0
  2. package/222.min.js +1 -0
  3. package/499.min.js +1 -0
  4. package/631.min.js +1 -0
  5. package/841.min.js +1 -0
  6. package/README.md +1 -1
  7. package/browser/CardValue.js +16 -0
  8. package/browser/SuitType.js +7 -0
  9. package/browser/cards/CardDrawer.js +21 -0
  10. package/browser/cards/index.js +9 -0
  11. package/browser/clubs/ClubDrawer.js +4 -5
  12. package/browser/clubs/index.js +7 -5
  13. package/browser/diamonds/DiamondDrawer.js +4 -5
  14. package/browser/diamonds/index.js +7 -5
  15. package/browser/hearts/HeartDrawer.js +4 -5
  16. package/browser/hearts/index.js +7 -5
  17. package/browser/index.js +24 -6
  18. package/browser/paths.js +174 -0
  19. package/browser/spades/SpadeDrawer.js +4 -5
  20. package/browser/spades/index.js +7 -5
  21. package/browser/utils.js +100 -0
  22. package/cjs/CardParticle.js +1 -0
  23. package/cjs/CardValue.js +16 -0
  24. package/cjs/ICardData.js +1 -0
  25. package/cjs/ICardSuitsPath.js +1 -0
  26. package/cjs/SuitType.js +7 -0
  27. package/cjs/cards/CardDrawer.js +21 -0
  28. package/cjs/cards/index.js +9 -0
  29. package/cjs/clubs/ClubDrawer.js +4 -5
  30. package/cjs/clubs/index.js +7 -5
  31. package/cjs/diamonds/DiamondDrawer.js +4 -5
  32. package/cjs/diamonds/index.js +7 -5
  33. package/cjs/hearts/HeartDrawer.js +4 -5
  34. package/cjs/hearts/index.js +7 -5
  35. package/cjs/index.js +24 -6
  36. package/cjs/paths.js +174 -0
  37. package/cjs/spades/SpadeDrawer.js +4 -5
  38. package/cjs/spades/index.js +7 -5
  39. package/cjs/utils.js +100 -0
  40. package/dist_browser_cards_CardDrawer_js.js +60 -0
  41. package/dist_browser_clubs_ClubDrawer_js.js +17 -7
  42. package/dist_browser_diamonds_DiamondDrawer_js.js +17 -7
  43. package/dist_browser_hearts_HeartDrawer_js.js +17 -7
  44. package/dist_browser_spades_SpadeDrawer_js.js +15 -5
  45. package/esm/CardParticle.js +1 -0
  46. package/esm/CardValue.js +16 -0
  47. package/esm/ICardData.js +1 -0
  48. package/esm/ICardSuitsPath.js +1 -0
  49. package/esm/SuitType.js +7 -0
  50. package/esm/cards/CardDrawer.js +21 -0
  51. package/esm/cards/index.js +9 -0
  52. package/esm/clubs/ClubDrawer.js +4 -5
  53. package/esm/clubs/index.js +7 -5
  54. package/esm/diamonds/DiamondDrawer.js +4 -5
  55. package/esm/diamonds/index.js +7 -5
  56. package/esm/hearts/HeartDrawer.js +4 -5
  57. package/esm/hearts/index.js +7 -5
  58. package/esm/index.js +24 -6
  59. package/esm/paths.js +174 -0
  60. package/esm/spades/SpadeDrawer.js +4 -5
  61. package/esm/spades/index.js +7 -5
  62. package/esm/utils.js +100 -0
  63. package/package.json +3 -2
  64. package/report.html +3 -3
  65. package/tsparticles.shape.cards.js +60 -18
  66. package/tsparticles.shape.cards.min.js +2 -2
  67. package/types/CardParticle.d.ts +5 -0
  68. package/types/CardValue.d.ts +15 -0
  69. package/types/ICardData.d.ts +7 -0
  70. package/types/ICardSuitsPath.d.ts +3 -0
  71. package/types/SuitType.d.ts +6 -0
  72. package/types/cards/CardDrawer.d.ts +6 -0
  73. package/types/cards/index.d.ts +2 -0
  74. package/types/clubs/ClubDrawer.d.ts +0 -1
  75. package/types/clubs/index.d.ts +1 -1
  76. package/types/diamonds/DiamondDrawer.d.ts +0 -1
  77. package/types/diamonds/index.d.ts +1 -1
  78. package/types/hearts/HeartDrawer.d.ts +0 -1
  79. package/types/hearts/index.d.ts +1 -1
  80. package/types/index.d.ts +2 -0
  81. package/types/paths.d.ts +7 -0
  82. package/types/spades/SpadeDrawer.d.ts +0 -1
  83. package/types/spades/index.d.ts +1 -1
  84. package/types/utils.d.ts +2 -0
  85. package/umd/CardValue.js +29 -0
  86. package/umd/ICardData.js +12 -0
  87. package/umd/ICardSuitsPath.js +12 -0
  88. package/umd/SuitType.js +20 -0
  89. package/umd/cards/CardDrawer.js +35 -0
  90. package/umd/cards/index.js +56 -0
  91. package/umd/clubs/ClubDrawer.js +5 -6
  92. package/umd/clubs/index.js +8 -6
  93. package/umd/diamonds/DiamondDrawer.js +5 -6
  94. package/umd/diamonds/index.js +8 -6
  95. package/umd/hearts/HeartDrawer.js +5 -6
  96. package/umd/hearts/index.js +8 -6
  97. package/umd/index.js +26 -7
  98. package/umd/paths.js +187 -0
  99. package/umd/spades/SpadeDrawer.js +5 -6
  100. package/umd/spades/index.js +8 -6
  101. package/umd/utils.js +113 -0
  102. package/475.min.js +0 -2
  103. package/475.min.js.LICENSE.txt +0 -1
  104. package/505.min.js +0 -2
  105. package/505.min.js.LICENSE.txt +0 -1
  106. package/657.min.js +0 -2
  107. package/657.min.js.LICENSE.txt +0 -1
  108. package/741.min.js +0 -2
  109. package/741.min.js.LICENSE.txt +0 -1
  110. package/browser/Utils.js +0 -161
  111. package/cjs/Utils.js +0 -161
  112. package/esm/Utils.js +0 -161
  113. package/tsparticles.shape.cards.min.js.LICENSE.txt +0 -1
  114. package/types/ICardsPath.d.ts +0 -13
  115. package/types/Utils.d.ts +0 -4
  116. package/umd/Utils.js +0 -175
  117. /package/browser/{ICardsPath.js → CardParticle.js} +0 -0
  118. /package/{cjs/ICardsPath.js → browser/ICardData.js} +0 -0
  119. /package/{esm/ICardsPath.js → browser/ICardSuitsPath.js} +0 -0
  120. /package/umd/{ICardsPath.js → CardParticle.js} +0 -0
package/111.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[111],{889(e,y,t){var p,x;t.d(y,{U:()=>p}),(x=p||(p={})).hearts="hearts",x.diamonds="diamonds",x.clubs="clubs",x.spades="spades"},111(e,y,t){t.d(y,{DiamondDrawer:()=>s});var p=t(580),x=t(674);class s{draw(e){let{context:y,radius:t}=e;(0,p.drawPath)(y,t,x.f0.diamonds)}}},674(e,y,t){t.d(y,{f0:()=>v});var p=t(580),x=t(303),s=t(889);let a=x.quarter*x.half,m=x.half,r=m*x.half,l=-m,n=-r,i=m*a,u=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: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}]}]},g={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:l},{x:x.empty,y:l}]}]},d={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}]}]},h={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: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]:d,[s.U.diamonds]:g,[s.U.clubs]:b,[s.U.spades]:h}}}]);
package/222.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[222],{889(e,t,a){var y,l;a.d(t,{U:()=>y}),(l=y||(y={})).hearts="hearts",l.diamonds="diamonds",l.clubs="clubs",l.spades="spades"},222(e,t,a){a.d(t,{CardDrawer:()=>h});var y=a(303),l=a(889),r=a(580),s=a(674);let i=y.double*y.double/y.triple,n=y.double,p=new Map,x={r:215,g:20,b:20},m={r:18,g:18,b:18};function o(e,t,a,p){let{suit:o,value:h}=a,d=t*i,f=t*n,u=d*y.half,b=f*y.half,v=.2*t,c=.4*t,T=.3*t,S=.25*t,z=.1*t,P=o===l.U.hearts||o===l.U.diamonds?(0,y.getStyleFromRgb)(x,p):(0,y.getStyleFromRgb)(m,p);e.save(),g(e,t),e.fillStyle=(0,y.getStyleFromRgb)({r:255,g:255,b:255},p),e.fill(),e.strokeStyle=(0,y.getStyleFromRgb)({r:0,g:0,b:0},p),e.stroke(),e.fillStyle=P,e.font=`bold ${c.toString()}px Arial, serif`,e.textAlign="left",e.textBaseline="middle";let w=-u+v+z,C=-b+v+c*y.half;e.save(),e.translate(w,C),e.beginPath(),(0,r.drawPath)(e,T,s.f0[o]),e.fill(),e.restore(),e.fillText(h,w+S,C),e.save(),e.translate(u-v-z,b-v-c*y.half),e.rotate(Math.PI),e.save(),e.beginPath(),(0,r.drawPath)(e,T,s.f0[o]),e.fill(),e.restore(),e.fillText(h,y.originPoint.x+S,y.originPoint.y),e.restore(),e.save(),e.beginPath(),(0,r.drawPath)(e,.7*t,s.f0[o]),e.fillStyle=P,e.fill(),e.restore(),e.beginPath(),e.arc(y.originPoint.x,y.originPoint.y,0,0,y.doublePI,!1),e.closePath(),e.restore()}function g(e,t){let a=t*i*y.half,l=t*n*y.half,r=.2*t;e.beginPath(),e.moveTo(-a+r,-l),e.lineTo(a-r,-l),e.quadraticCurveTo(a,-l,a,-l+r),e.lineTo(a,l-r),e.quadraticCurveTo(a,l,a-r,l),e.lineTo(-a+r,l),e.quadraticCurveTo(-a,l,-a,l-r),e.lineTo(-a,-l+r),e.quadraticCurveTo(-a,-l,-a+r,-l),e.closePath()}class h{draw(e){let{context:t,particle:a,opacity:l,radius:r}=e;if(!a.cardData)return;let s=t.globalAlpha;t.globalAlpha=l,function(e,t,a,l,r,s){if(r)g(e,t);else{var x,m,h;let r=(x=t,m=l,h=a,`${x.toFixed(2)}-${m?"hdr":"sdr"}-${h.suit}-${h.value}`),g=t*i,d=t*n,f=g*y.half,u=d*y.half,b=p.get(r);if(!b){let e,i;"u"<typeof OffscreenCanvas?((e=(0,y.safeDocument)().createElement("canvas")).width=g,e.height=d,i=e.getContext("2d",s)):i=(e=new OffscreenCanvas(g,d)).getContext("2d",s),i&&(i.translate(f,u),o(i,t,a,l),b=e instanceof HTMLCanvasElement?e:e.transferToImageBitmap(),p.set(r,b))}b?e.drawImage(b,-f,-u,g,d):o(e,t,a,l)}}(t,r,a.cardData,a.container.hdr,a.isShowingBack(),a.container.canvas.settings),t.globalAlpha=s}particleInit(e,t){let a=t.shapeData;a&&(t.cardData=(0,y.deepExtend)({},a))}}},674(e,t,a){a.d(t,{f0:()=>u});var y=a(580),l=a(303),r=a(889);let s=l.quarter*l.half,i=l.half,n=i*l.half,p=-i,x=-n,m=i*s,o=i*l.threeQuarter,g={half:!0,segments:[{type:y.SegmentType.bezier,values:[{x:l.empty,y:p},{x:l.empty,y:p},{x:n,y:p},{x:n,y:x}]},{type:y.SegmentType.bezier,values:[{x:n,y:x},{x:n,y:x},{x:i,y:x},{x:i,y:l.empty}]},{type:y.SegmentType.bezier,values:[{x:i,y:l.empty},{x:i,y:l.empty},{x:i,y:n},{x:n,y:n}]},{type:y.SegmentType.bezier,values:[{x:n,y:n},{x:n,y:n},{x:m,y:n},{x:m,y:m}]},{type:y.SegmentType.bezier,values:[{x:m,y:m},{x:m,y:n},{x:n,y:i},{x:n,y:i}]},{type:y.SegmentType.bezier,values:[{x:n,y:i},{x:n,y:i},{x:l.empty,y:i},{x:l.empty,y:i}]}]},h={half:!0,segments:[{type:y.SegmentType.bezier,values:[{x:l.empty,y:i},{x:l.empty,y:i},{x:o,y:l.empty},{x:o,y:l.empty}]},{type:y.SegmentType.bezier,values:[{x:o,y:l.empty},{x:o,y:l.empty},{x:l.empty,y:p},{x:l.empty,y:p}]}]},d={half:!0,segments:[{type:y.SegmentType.bezier,values:[{x:l.empty,y:i},{x:l.empty,y:i},{x:i,y:l.empty},{x:i,y:x}]},{type:y.SegmentType.bezier,values:[{x:i,y:x},{x:i,y:x},{x:i,y:p},{x:n,y:p}]},{type:y.SegmentType.bezier,values:[{x:n,y:p},{x:n,y:p},{x:l.empty,y:p},{x:l.empty,y:x}]}]},f={half:!0,segments:[{type:y.SegmentType.bezier,values:[{x:l.empty,y:p},{x:l.empty,y:p},{x:i,y:x},{x:i,y:l.empty}]},{type:y.SegmentType.bezier,values:[{x:i,y:l.empty},{x:i,y:l.empty},{x:i,y:n},{x:n,y:n}]},{type:y.SegmentType.bezier,values:[{x:n,y:n},{x:n,y:n},{x:m,y:n},{x:m,y:m}]},{type:y.SegmentType.bezier,values:[{x:m,y:m},{x:m,y:n},{x:n,y:i},{x:n,y:i}]},{type:y.SegmentType.bezier,values:[{x:n,y:i},{x:n,y:i},{x:l.empty,y:i},{x:l.empty,y:i}]}]},u={[r.U.hearts]:d,[r.U.diamonds]:h,[r.U.clubs]:g,[r.U.spades]:f}}}]);
package/499.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[499],{889(e,y,t){var p,x;t.d(y,{U:()=>p}),(x=p||(p={})).hearts="hearts",x.diamonds="diamonds",x.clubs="clubs",x.spades="spades"},499(e,y,t){t.d(y,{ClubDrawer:()=>s});var p=t(580),x=t(674);class s{draw(e){let{context:y,radius:t}=e;(0,p.drawPath)(y,t,x.f0.clubs)}}},674(e,y,t){t.d(y,{f0:()=>d});var p=t(580),x=t(303),s=t(889);let a=x.quarter*x.half,m=x.half,r=m*x.half,l=-m,u=-r,n=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:u}]},{type:p.SegmentType.bezier,values:[{x:r,y:u},{x:r,y:u},{x:m,y:u},{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:n,y:r},{x:n,y:n}]},{type:p.SegmentType.bezier,values:[{x:n,y:n},{x:n,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:u}]},{type:p.SegmentType.bezier,values:[{x:m,y:u},{x:m,y:u},{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:u}]}]},v={half:!0,segments:[{type:p.SegmentType.bezier,values:[{x:x.empty,y:l},{x:x.empty,y:l},{x:m,y:u},{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:n,y:r},{x:n,y:n}]},{type:p.SegmentType.bezier,values:[{x:n,y:n},{x:n,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]:h,[s.U.diamonds]:g,[s.U.clubs]:b,[s.U.spades]:v}}}]);
package/631.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[631],{889(e,y,t){var p,x;t.d(y,{U:()=>p}),(x=p||(p={})).hearts="hearts",x.diamonds="diamonds",x.clubs="clubs",x.spades="spades"},631(e,y,t){t.d(y,{HeartDrawer:()=>s});var p=t(580),x=t(674);class s{draw(e){let{context:y,radius:t}=e;(0,p.drawPath)(y,t,x.f0.hearts)}}},674(e,y,t){t.d(y,{f0:()=>d});var p=t(580),x=t(303),s=t(889);let 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}]}]},d={[s.U.hearts]:h,[s.U.diamonds]:g,[s.U.clubs]:b,[s.U.spades]:v}}}]);
package/841.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_shape_cards=this.webpackChunk_tsparticles_shape_cards||[]).push([[841],{889(e,y,t){var p,x;t.d(y,{U:()=>p}),(x=p||(p={})).hearts="hearts",x.diamonds="diamonds",x.clubs="clubs",x.spades="spades"},674(e,y,t){t.d(y,{f0:()=>d});var p=t(580),x=t(303),s=t(889);let 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}]}]},d={[s.U.hearts]:h,[s.U.diamonds]:g,[s.U.clubs]:b,[s.U.spades]:v}},841(e,y,t){t.d(y,{SpadeDrawer:()=>s});var p=t(580),x=t(674);class s{draw(e){let{context:y,radius:t}=e;(0,p.drawPath)(y,t,x.f0.spades)}}}}]);
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
+ draw(data) {
5
+ const { context, particle, opacity, radius } = data;
6
+ if (!particle.cardData) {
7
+ return;
8
+ }
9
+ const defaultOpacity = context.globalAlpha;
10
+ context.globalAlpha = opacity;
11
+ drawRoundedCard(context, radius, particle.cardData, particle.container.hdr, particle.isShowingBack(), particle.container.canvas.settings);
12
+ context.globalAlpha = defaultOpacity;
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,9 @@
1
+ export async function loadFullCardsShape(engine) {
2
+ engine.checkVersion("4.0.0-beta.0");
3
+ await engine.register(e => {
4
+ e.addShape(["card"], async () => {
5
+ const { CardDrawer } = await import("./CardDrawer.js");
6
+ return new CardDrawer();
7
+ });
8
+ });
9
+ }
@@ -1,9 +1,8 @@
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
- constructor() {
4
- this.validTypes = ["club", "clubs"];
5
- }
6
4
  draw(data) {
7
- drawPath(data, paths.club);
5
+ const { context, radius } = data;
6
+ drawPath(context, radius, paths.clubs);
8
7
  }
9
8
  }
@@ -1,7 +1,9 @@
1
- export async function loadClubsCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.5");
3
- await engine.register(async (e) => {
4
- const { ClubDrawer } = await import("./ClubDrawer.js");
5
- e.addShape(new ClubDrawer());
1
+ export async function loadClubsSuitShape(engine) {
2
+ engine.checkVersion("4.0.0-beta.0");
3
+ await engine.register(e => {
4
+ e.addShape(["club", "clubs"], async () => {
5
+ const { ClubDrawer } = await import("./ClubDrawer.js");
6
+ return new ClubDrawer();
7
+ });
6
8
  });
7
9
  }
@@ -1,9 +1,8 @@
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
- constructor() {
4
- this.validTypes = ["diamond", "diamonds"];
5
- }
6
4
  draw(data) {
7
- drawPath(data, paths.diamond);
5
+ const { context, radius } = data;
6
+ drawPath(context, radius, paths.diamonds);
8
7
  }
9
8
  }
@@ -1,7 +1,9 @@
1
- export async function loadDiamondsCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.5");
3
- await engine.register(async (e) => {
4
- const { DiamondDrawer } = await import("./DiamondDrawer.js");
5
- e.addShape(new DiamondDrawer());
1
+ export async function loadDiamondsSuitShape(engine) {
2
+ engine.checkVersion("4.0.0-beta.0");
3
+ await engine.register(e => {
4
+ e.addShape(["diamond", "diamonds"], async () => {
5
+ const { DiamondDrawer } = await import("./DiamondDrawer.js");
6
+ return new DiamondDrawer();
7
+ });
6
8
  });
7
9
  }
@@ -1,9 +1,8 @@
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
- constructor() {
4
- this.validTypes = ["heart", "hearts"];
5
- }
6
4
  draw(data) {
7
- drawPath(data, paths.heart);
5
+ const { context, radius } = data;
6
+ drawPath(context, radius, paths.hearts);
8
7
  }
9
8
  }
@@ -1,7 +1,9 @@
1
- export async function loadHeartsCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.5");
3
- await engine.register(async (e) => {
4
- const { HeartDrawer } = await import("./HeartDrawer.js");
5
- e.addShape(new HeartDrawer());
1
+ export async function loadHeartsSuitShape(engine) {
2
+ engine.checkVersion("4.0.0-beta.0");
3
+ await engine.register(e => {
4
+ e.addShape(["heart", "hearts"], async () => {
5
+ const { HeartDrawer } = await import("./HeartDrawer.js");
6
+ return new HeartDrawer();
7
+ });
6
8
  });
7
9
  }
package/browser/index.js CHANGED
@@ -1,13 +1,31 @@
1
+ export async function loadCardSuitsShape(engine) {
2
+ engine.checkVersion("4.0.0-beta.0");
3
+ await engine.register(async (e) => {
4
+ const [{ loadClubsSuitShape }, { loadDiamondsSuitShape }, { loadHeartsSuitShape }, { loadSpadesSuitShape },] = await Promise.all([
5
+ import("./clubs/index.js"),
6
+ import("./diamonds/index.js"),
7
+ import("./hearts/index.js"),
8
+ import("./spades/index.js"),
9
+ ]);
10
+ await Promise.all([
11
+ loadClubsSuitShape(e),
12
+ loadDiamondsSuitShape(e),
13
+ loadHeartsSuitShape(e),
14
+ loadSpadesSuitShape(e),
15
+ ]);
16
+ });
17
+ }
1
18
  export async function loadCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.5");
19
+ engine.checkVersion("4.0.0-beta.0");
3
20
  await 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
- await loadClubsCardsShape(e);
6
- await loadDiamondsCardsShape(e);
7
- await loadHeartsCardsShape(e);
8
- await loadSpadesCardsShape(e);
21
+ const { loadFullCardsShape } = await import("./cards/index.js");
22
+ await Promise.all([
23
+ loadFullCardsShape(e),
24
+ loadCardSuitsShape(e),
25
+ ]);
9
26
  });
10
27
  }
28
+ export * from "./cards/index.js";
11
29
  export * from "./clubs/index.js";
12
30
  export * from "./diamonds/index.js";
13
31
  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,8 @@
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
- constructor() {
4
- this.validTypes = ["spade", "spades"];
5
- }
6
4
  draw(data) {
7
- drawPath(data, paths.spade);
5
+ const { context, radius } = data;
6
+ drawPath(context, radius, paths.spades);
8
7
  }
9
8
  }
@@ -1,7 +1,9 @@
1
- export async function loadSpadesCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.5");
3
- await engine.register(async (e) => {
4
- const { SpadeDrawer } = await import("./SpadeDrawer.js");
5
- e.addShape(new SpadeDrawer());
1
+ export async function loadSpadesSuitShape(engine) {
2
+ engine.checkVersion("4.0.0-beta.0");
3
+ await engine.register(e => {
4
+ e.addShape(["spade", "spades"], async () => {
5
+ const { SpadeDrawer } = await import("./SpadeDrawer.js");
6
+ return new SpadeDrawer();
7
+ });
6
8
  });
7
9
  }
@@ -0,0 +1,100 @@
1
+ import { double, doublePI, getStyleFromRgb, half, originPoint, safeDocument, 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.7, cornerPaddingRatio = 0.2, textHorizontalOffsetRatio = 0.25, minRadius = 0, minAngle = 0, suitEdgeBufferFactor = 0.1, fixedCacheKey = 2, cardsCache = new Map(), redSuitColor = { r: 215, g: 20, b: 20 }, blackSuitColor = { r: 18, g: 18, b: 18 };
6
+ export function drawRoundedCard(ctx, radius, cardData, hdr, flipped, canvasSettings) {
7
+ if (flipped) {
8
+ drawRoundedCardBack(ctx, radius);
9
+ }
10
+ else {
11
+ const cacheKey = getCacheKey(radius, hdr, cardData), cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * half, halfHeight = cardHeight * half;
12
+ let cachedData = cardsCache.get(cacheKey);
13
+ if (!cachedData) {
14
+ let cacheCanvas, cacheCtx;
15
+ if (typeof OffscreenCanvas === "undefined") {
16
+ cacheCanvas = safeDocument().createElement("canvas");
17
+ cacheCanvas.width = cardWidth;
18
+ cacheCanvas.height = cardHeight;
19
+ cacheCtx = cacheCanvas.getContext("2d", canvasSettings);
20
+ }
21
+ else {
22
+ cacheCanvas = new OffscreenCanvas(cardWidth, cardHeight);
23
+ cacheCtx = cacheCanvas.getContext("2d", canvasSettings);
24
+ }
25
+ if (cacheCtx) {
26
+ cacheCtx.translate(halfWidth, halfHeight);
27
+ drawRoundedCardFront(cacheCtx, radius, cardData, hdr);
28
+ cachedData = cacheCanvas instanceof HTMLCanvasElement ? cacheCanvas : cacheCanvas.transferToImageBitmap();
29
+ cardsCache.set(cacheKey, cachedData);
30
+ }
31
+ }
32
+ if (cachedData) {
33
+ ctx.drawImage(cachedData, -halfWidth, -halfHeight, cardWidth, cardHeight);
34
+ }
35
+ else {
36
+ drawRoundedCardFront(ctx, radius, cardData, hdr);
37
+ }
38
+ }
39
+ }
40
+ function getCacheKey(radius, hdr, cardData) {
41
+ return `${radius.toFixed(fixedCacheKey)}-${hdr ? "hdr" : "sdr"}-${cardData.suit}-${cardData.value}`;
42
+ }
43
+ function drawRoundedCardBack(ctx, radius) {
44
+ drawCardBody(ctx, radius);
45
+ }
46
+ function drawRoundedCardFront(ctx, radius, cardData, hdr) {
47
+ 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(redSuitColor, hdr) : getStyleFromRgb(blackSuitColor, hdr);
48
+ ctx.save();
49
+ drawCardBody(ctx, radius);
50
+ ctx.fillStyle = getStyleFromRgb({ r: 255, g: 255, b: 255 }, hdr);
51
+ ctx.fill();
52
+ ctx.strokeStyle = getStyleFromRgb({ r: 0, g: 0, b: 0 }, hdr);
53
+ ctx.stroke();
54
+ ctx.fillStyle = color;
55
+ ctx.font = `bold ${cornerFontSize.toString()}px Arial, serif`;
56
+ ctx.textAlign = "left";
57
+ ctx.textBaseline = "middle";
58
+ const topLeftX = -halfWidth + cornerPadding + suitEdgeBuffer, topLeftY = -halfHeight + cornerPadding + cornerFontSize * half;
59
+ ctx.save();
60
+ ctx.translate(topLeftX, topLeftY);
61
+ ctx.beginPath();
62
+ drawPath(ctx, cornerSuitSize, paths[suit]);
63
+ ctx.fill();
64
+ ctx.restore();
65
+ ctx.fillText(value, topLeftX + textOffset, topLeftY);
66
+ ctx.save();
67
+ ctx.translate(halfWidth - cornerPadding - suitEdgeBuffer, halfHeight - cornerPadding - cornerFontSize * half);
68
+ ctx.rotate(Math.PI);
69
+ ctx.save();
70
+ ctx.beginPath();
71
+ drawPath(ctx, cornerSuitSize, paths[suit]);
72
+ ctx.fill();
73
+ ctx.restore();
74
+ ctx.fillText(value, originPoint.x + textOffset, originPoint.y);
75
+ ctx.restore();
76
+ ctx.save();
77
+ ctx.beginPath();
78
+ drawPath(ctx, centerSuitSize, paths[suit]);
79
+ ctx.fillStyle = color;
80
+ ctx.fill();
81
+ ctx.restore();
82
+ ctx.beginPath();
83
+ ctx.arc(originPoint.x, originPoint.y, minRadius, minAngle, doublePI, false);
84
+ ctx.closePath();
85
+ ctx.restore();
86
+ }
87
+ function drawCardBody(ctx, radius) {
88
+ const cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * half, halfHeight = cardHeight * half, cornerRadius = radius * cornerRadiusRatio;
89
+ ctx.beginPath();
90
+ ctx.moveTo(-halfWidth + cornerRadius, -halfHeight);
91
+ ctx.lineTo(halfWidth - cornerRadius, -halfHeight);
92
+ ctx.quadraticCurveTo(halfWidth, -halfHeight, halfWidth, -halfHeight + cornerRadius);
93
+ ctx.lineTo(halfWidth, halfHeight - cornerRadius);
94
+ ctx.quadraticCurveTo(halfWidth, halfHeight, halfWidth - cornerRadius, halfHeight);
95
+ ctx.lineTo(-halfWidth + cornerRadius, halfHeight);
96
+ ctx.quadraticCurveTo(-halfWidth, halfHeight, -halfWidth, halfHeight - cornerRadius);
97
+ ctx.lineTo(-halfWidth, -halfHeight + cornerRadius);
98
+ ctx.quadraticCurveTo(-halfWidth, -halfHeight, -halfWidth + cornerRadius, -halfHeight);
99
+ ctx.closePath();
100
+ }
@@ -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 = {}));
@@ -0,0 +1,21 @@
1
+ import { deepExtend } from "@tsparticles/engine";
2
+ import { drawRoundedCard } from "../utils.js";
3
+ export class CardDrawer {
4
+ draw(data) {
5
+ const { context, particle, opacity, radius } = data;
6
+ if (!particle.cardData) {
7
+ return;
8
+ }
9
+ const defaultOpacity = context.globalAlpha;
10
+ context.globalAlpha = opacity;
11
+ drawRoundedCard(context, radius, particle.cardData, particle.container.hdr, particle.isShowingBack(), particle.container.canvas.settings);
12
+ context.globalAlpha = defaultOpacity;
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,9 @@
1
+ export async function loadFullCardsShape(engine) {
2
+ engine.checkVersion("4.0.0-beta.0");
3
+ await engine.register(e => {
4
+ e.addShape(["card"], async () => {
5
+ const { CardDrawer } = await import("./CardDrawer.js");
6
+ return new CardDrawer();
7
+ });
8
+ });
9
+ }
@@ -1,9 +1,8 @@
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
- constructor() {
4
- this.validTypes = ["club", "clubs"];
5
- }
6
4
  draw(data) {
7
- drawPath(data, paths.club);
5
+ const { context, radius } = data;
6
+ drawPath(context, radius, paths.clubs);
8
7
  }
9
8
  }
@@ -1,7 +1,9 @@
1
- export async function loadClubsCardsShape(engine) {
2
- engine.checkVersion("4.0.0-alpha.5");
3
- await engine.register(async (e) => {
4
- const { ClubDrawer } = await import("./ClubDrawer.js");
5
- e.addShape(new ClubDrawer());
1
+ export async function loadClubsSuitShape(engine) {
2
+ engine.checkVersion("4.0.0-beta.0");
3
+ await engine.register(e => {
4
+ e.addShape(["club", "clubs"], async () => {
5
+ const { ClubDrawer } = await import("./ClubDrawer.js");
6
+ return new ClubDrawer();
7
+ });
6
8
  });
7
9
  }