@tsparticles/shape-cards 4.0.0-alpha.8 → 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.
- package/111.min.js +1 -0
- package/222.min.js +1 -0
- package/499.min.js +1 -0
- package/631.min.js +1 -0
- package/841.min.js +1 -0
- package/browser/cards/CardDrawer.js +5 -5
- package/browser/cards/index.js +6 -4
- package/browser/clubs/ClubDrawer.js +0 -3
- package/browser/clubs/index.js +6 -4
- package/browser/diamonds/DiamondDrawer.js +0 -3
- package/browser/diamonds/index.js +6 -4
- package/browser/hearts/HeartDrawer.js +0 -3
- package/browser/hearts/index.js +6 -4
- package/browser/index.js +18 -9
- package/browser/spades/SpadeDrawer.js +0 -3
- package/browser/spades/index.js +6 -4
- package/browser/utils.js +28 -18
- package/cjs/cards/CardDrawer.js +5 -5
- package/cjs/cards/index.js +6 -4
- package/cjs/clubs/ClubDrawer.js +0 -3
- package/cjs/clubs/index.js +6 -4
- package/cjs/diamonds/DiamondDrawer.js +0 -3
- package/cjs/diamonds/index.js +6 -4
- package/cjs/hearts/HeartDrawer.js +0 -3
- package/cjs/hearts/index.js +6 -4
- package/cjs/index.js +18 -9
- package/cjs/spades/SpadeDrawer.js +0 -3
- package/cjs/spades/index.js +6 -4
- package/cjs/utils.js +28 -18
- package/dist_browser_cards_CardDrawer_js.js +5 -5
- package/dist_browser_clubs_ClubDrawer_js.js +4 -4
- package/dist_browser_diamonds_DiamondDrawer_js.js +4 -4
- package/dist_browser_hearts_HeartDrawer_js.js +4 -4
- package/dist_browser_spades_SpadeDrawer_js.js +4 -4
- package/esm/cards/CardDrawer.js +5 -5
- package/esm/cards/index.js +6 -4
- package/esm/clubs/ClubDrawer.js +0 -3
- package/esm/clubs/index.js +6 -4
- package/esm/diamonds/DiamondDrawer.js +0 -3
- package/esm/diamonds/index.js +6 -4
- package/esm/hearts/HeartDrawer.js +0 -3
- package/esm/hearts/index.js +6 -4
- package/esm/index.js +18 -9
- package/esm/spades/SpadeDrawer.js +0 -3
- package/esm/spades/index.js +6 -4
- package/esm/utils.js +28 -18
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.shape.cards.js +47 -35
- package/tsparticles.shape.cards.min.js +2 -2
- package/types/cards/CardDrawer.d.ts +0 -1
- package/types/clubs/ClubDrawer.d.ts +0 -1
- package/types/diamonds/DiamondDrawer.d.ts +0 -1
- package/types/hearts/HeartDrawer.d.ts +0 -1
- package/types/spades/SpadeDrawer.d.ts +0 -1
- package/types/utils.d.ts +1 -1
- package/umd/cards/CardDrawer.js +5 -5
- package/umd/cards/index.js +6 -4
- package/umd/clubs/ClubDrawer.js +0 -3
- package/umd/clubs/index.js +6 -4
- package/umd/diamonds/DiamondDrawer.js +0 -3
- package/umd/diamonds/index.js +6 -4
- package/umd/hearts/HeartDrawer.js +0 -3
- package/umd/hearts/index.js +6 -4
- package/umd/index.js +18 -9
- package/umd/spades/SpadeDrawer.js +0 -3
- package/umd/spades/index.js +6 -4
- package/umd/utils.js +27 -17
- package/35.min.js +0 -2
- package/35.min.js.LICENSE.txt +0 -1
- package/475.min.js +0 -2
- package/475.min.js.LICENSE.txt +0 -1
- package/505.min.js +0 -2
- package/505.min.js.LICENSE.txt +0 -1
- package/657.min.js +0 -2
- package/657.min.js.LICENSE.txt +0 -1
- package/741.min.js +0 -2
- package/741.min.js.LICENSE.txt +0 -1
- package/tsparticles.shape.cards.min.js.LICENSE.txt +0 -1
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)}}}}]);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { deepExtend } from "@tsparticles/engine";
|
|
2
2
|
import { drawRoundedCard } from "../utils.js";
|
|
3
3
|
export class CardDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["card"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
|
-
const { context, particle, radius } = data;
|
|
5
|
+
const { context, particle, opacity, radius } = data;
|
|
9
6
|
if (!particle.cardData) {
|
|
10
7
|
return;
|
|
11
8
|
}
|
|
12
|
-
|
|
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
13
|
}
|
|
14
14
|
particleInit(_container, particle) {
|
|
15
15
|
const shape = particle.shapeData;
|
package/browser/cards/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadFullCardsShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
});
|
|
6
8
|
});
|
|
7
9
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { drawPath } from "@tsparticles/path-utils";
|
|
2
2
|
import { paths } from "../paths.js";
|
|
3
3
|
export class ClubDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["club", "clubs"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
5
|
const { context, radius } = data;
|
|
9
6
|
drawPath(context, radius, paths.clubs);
|
package/browser/clubs/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadClubsSuitShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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,6 @@
|
|
|
1
1
|
import { drawPath } from "@tsparticles/path-utils";
|
|
2
2
|
import { paths } from "../paths.js";
|
|
3
3
|
export class DiamondDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["diamond", "diamonds"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
5
|
const { context, radius } = data;
|
|
9
6
|
drawPath(context, radius, paths.diamonds);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadDiamondsSuitShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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,6 @@
|
|
|
1
1
|
import { drawPath } from "@tsparticles/path-utils";
|
|
2
2
|
import { paths } from "../paths.js";
|
|
3
3
|
export class HeartDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["heart", "hearts"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
5
|
const { context, radius } = data;
|
|
9
6
|
drawPath(context, radius, paths.hearts);
|
package/browser/hearts/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadHeartsSuitShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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,19 +1,28 @@
|
|
|
1
1
|
export async function loadCardSuitsShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const { loadClubsSuitShape }
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
]);
|
|
9
16
|
});
|
|
10
17
|
}
|
|
11
18
|
export async function loadCardsShape(engine) {
|
|
12
|
-
engine.checkVersion("4.0.0-
|
|
19
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
13
20
|
await engine.register(async (e) => {
|
|
14
21
|
const { loadFullCardsShape } = await import("./cards/index.js");
|
|
15
|
-
await
|
|
16
|
-
|
|
22
|
+
await Promise.all([
|
|
23
|
+
loadFullCardsShape(e),
|
|
24
|
+
loadCardSuitsShape(e),
|
|
25
|
+
]);
|
|
17
26
|
});
|
|
18
27
|
}
|
|
19
28
|
export * from "./cards/index.js";
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { drawPath } from "@tsparticles/path-utils";
|
|
2
2
|
import { paths } from "../paths.js";
|
|
3
3
|
export class SpadeDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["spade", "spades"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
5
|
const { context, radius } = data;
|
|
9
6
|
drawPath(context, radius, paths.spades);
|
package/browser/spades/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadSpadesSuitShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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
|
}
|
package/browser/utils.js
CHANGED
|
@@ -1,39 +1,50 @@
|
|
|
1
|
-
import { double, doublePI, getStyleFromRgb, half, originPoint, triple } from "@tsparticles/engine";
|
|
1
|
+
import { double, doublePI, getStyleFromRgb, half, originPoint, safeDocument, triple, } from "@tsparticles/engine";
|
|
2
2
|
import { SuitType } from "./SuitType.js";
|
|
3
3
|
import { drawPath } from "@tsparticles/path-utils";
|
|
4
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.
|
|
6
|
-
export function drawRoundedCard(ctx, radius, cardData, hdr, flipped) {
|
|
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
7
|
if (flipped) {
|
|
8
8
|
drawRoundedCardBack(ctx, radius);
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
|
-
const cacheKey = getCacheKey(radius, cardData), cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * half, halfHeight = cardHeight * half;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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);
|
|
18
30
|
}
|
|
19
31
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ctx.drawImage(cachedCanvas, -halfWidth, -halfHeight, cardWidth, cardHeight);
|
|
32
|
+
if (cachedData) {
|
|
33
|
+
ctx.drawImage(cachedData, -halfWidth, -halfHeight, cardWidth, cardHeight);
|
|
23
34
|
}
|
|
24
35
|
else {
|
|
25
36
|
drawRoundedCardFront(ctx, radius, cardData, hdr);
|
|
26
37
|
}
|
|
27
38
|
}
|
|
28
39
|
}
|
|
29
|
-
function getCacheKey(radius, cardData) {
|
|
30
|
-
return `${radius.toFixed(fixedCacheKey)}-${cardData.suit}-${cardData.value}`;
|
|
40
|
+
function getCacheKey(radius, hdr, cardData) {
|
|
41
|
+
return `${radius.toFixed(fixedCacheKey)}-${hdr ? "hdr" : "sdr"}-${cardData.suit}-${cardData.value}`;
|
|
31
42
|
}
|
|
32
43
|
function drawRoundedCardBack(ctx, radius) {
|
|
33
44
|
drawCardBody(ctx, radius);
|
|
34
45
|
}
|
|
35
46
|
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(
|
|
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);
|
|
37
48
|
ctx.save();
|
|
38
49
|
drawCardBody(ctx, radius);
|
|
39
50
|
ctx.fillStyle = getStyleFromRgb({ r: 255, g: 255, b: 255 }, hdr);
|
|
@@ -44,8 +55,7 @@ function drawRoundedCardFront(ctx, radius, cardData, hdr) {
|
|
|
44
55
|
ctx.font = `bold ${cornerFontSize.toString()}px Arial, serif`;
|
|
45
56
|
ctx.textAlign = "left";
|
|
46
57
|
ctx.textBaseline = "middle";
|
|
47
|
-
const topLeftX = -halfWidth + cornerPadding + suitEdgeBuffer;
|
|
48
|
-
const topLeftY = -halfHeight + cornerPadding + cornerFontSize * half;
|
|
58
|
+
const topLeftX = -halfWidth + cornerPadding + suitEdgeBuffer, topLeftY = -halfHeight + cornerPadding + cornerFontSize * half;
|
|
49
59
|
ctx.save();
|
|
50
60
|
ctx.translate(topLeftX, topLeftY);
|
|
51
61
|
ctx.beginPath();
|
package/cjs/cards/CardDrawer.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { deepExtend } from "@tsparticles/engine";
|
|
2
2
|
import { drawRoundedCard } from "../utils.js";
|
|
3
3
|
export class CardDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["card"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
|
-
const { context, particle, radius } = data;
|
|
5
|
+
const { context, particle, opacity, radius } = data;
|
|
9
6
|
if (!particle.cardData) {
|
|
10
7
|
return;
|
|
11
8
|
}
|
|
12
|
-
|
|
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
13
|
}
|
|
14
14
|
particleInit(_container, particle) {
|
|
15
15
|
const shape = particle.shapeData;
|
package/cjs/cards/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadFullCardsShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
});
|
|
6
8
|
});
|
|
7
9
|
}
|
package/cjs/clubs/ClubDrawer.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { drawPath } from "@tsparticles/path-utils";
|
|
2
2
|
import { paths } from "../paths.js";
|
|
3
3
|
export class ClubDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["club", "clubs"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
5
|
const { context, radius } = data;
|
|
9
6
|
drawPath(context, radius, paths.clubs);
|
package/cjs/clubs/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadClubsSuitShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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,6 @@
|
|
|
1
1
|
import { drawPath } from "@tsparticles/path-utils";
|
|
2
2
|
import { paths } from "../paths.js";
|
|
3
3
|
export class DiamondDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["diamond", "diamonds"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
5
|
const { context, radius } = data;
|
|
9
6
|
drawPath(context, radius, paths.diamonds);
|
package/cjs/diamonds/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadDiamondsSuitShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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,6 @@
|
|
|
1
1
|
import { drawPath } from "@tsparticles/path-utils";
|
|
2
2
|
import { paths } from "../paths.js";
|
|
3
3
|
export class HeartDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["heart", "hearts"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
5
|
const { context, radius } = data;
|
|
9
6
|
drawPath(context, radius, paths.hearts);
|
package/cjs/hearts/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadHeartsSuitShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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/cjs/index.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
export async function loadCardSuitsShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const { loadClubsSuitShape }
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
]);
|
|
9
16
|
});
|
|
10
17
|
}
|
|
11
18
|
export async function loadCardsShape(engine) {
|
|
12
|
-
engine.checkVersion("4.0.0-
|
|
19
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
13
20
|
await engine.register(async (e) => {
|
|
14
21
|
const { loadFullCardsShape } = await import("./cards/index.js");
|
|
15
|
-
await
|
|
16
|
-
|
|
22
|
+
await Promise.all([
|
|
23
|
+
loadFullCardsShape(e),
|
|
24
|
+
loadCardSuitsShape(e),
|
|
25
|
+
]);
|
|
17
26
|
});
|
|
18
27
|
}
|
|
19
28
|
export * from "./cards/index.js";
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { drawPath } from "@tsparticles/path-utils";
|
|
2
2
|
import { paths } from "../paths.js";
|
|
3
3
|
export class SpadeDrawer {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.validTypes = ["spade", "spades"];
|
|
6
|
-
}
|
|
7
4
|
draw(data) {
|
|
8
5
|
const { context, radius } = data;
|
|
9
6
|
drawPath(context, radius, paths.spades);
|
package/cjs/spades/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export async function loadSpadesSuitShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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
|
}
|
package/cjs/utils.js
CHANGED
|
@@ -1,39 +1,50 @@
|
|
|
1
|
-
import { double, doublePI, getStyleFromRgb, half, originPoint, triple } from "@tsparticles/engine";
|
|
1
|
+
import { double, doublePI, getStyleFromRgb, half, originPoint, safeDocument, triple, } from "@tsparticles/engine";
|
|
2
2
|
import { SuitType } from "./SuitType.js";
|
|
3
3
|
import { drawPath } from "@tsparticles/path-utils";
|
|
4
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.
|
|
6
|
-
export function drawRoundedCard(ctx, radius, cardData, hdr, flipped) {
|
|
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
7
|
if (flipped) {
|
|
8
8
|
drawRoundedCardBack(ctx, radius);
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
|
-
const cacheKey = getCacheKey(radius, cardData), cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * half, halfHeight = cardHeight * half;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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);
|
|
18
30
|
}
|
|
19
31
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ctx.drawImage(cachedCanvas, -halfWidth, -halfHeight, cardWidth, cardHeight);
|
|
32
|
+
if (cachedData) {
|
|
33
|
+
ctx.drawImage(cachedData, -halfWidth, -halfHeight, cardWidth, cardHeight);
|
|
23
34
|
}
|
|
24
35
|
else {
|
|
25
36
|
drawRoundedCardFront(ctx, radius, cardData, hdr);
|
|
26
37
|
}
|
|
27
38
|
}
|
|
28
39
|
}
|
|
29
|
-
function getCacheKey(radius, cardData) {
|
|
30
|
-
return `${radius.toFixed(fixedCacheKey)}-${cardData.suit}-${cardData.value}`;
|
|
40
|
+
function getCacheKey(radius, hdr, cardData) {
|
|
41
|
+
return `${radius.toFixed(fixedCacheKey)}-${hdr ? "hdr" : "sdr"}-${cardData.suit}-${cardData.value}`;
|
|
31
42
|
}
|
|
32
43
|
function drawRoundedCardBack(ctx, radius) {
|
|
33
44
|
drawCardBody(ctx, radius);
|
|
34
45
|
}
|
|
35
46
|
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(
|
|
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);
|
|
37
48
|
ctx.save();
|
|
38
49
|
drawCardBody(ctx, radius);
|
|
39
50
|
ctx.fillStyle = getStyleFromRgb({ r: 255, g: 255, b: 255 }, hdr);
|
|
@@ -44,8 +55,7 @@ function drawRoundedCardFront(ctx, radius, cardData, hdr) {
|
|
|
44
55
|
ctx.font = `bold ${cornerFontSize.toString()}px Arial, serif`;
|
|
45
56
|
ctx.textAlign = "left";
|
|
46
57
|
ctx.textBaseline = "middle";
|
|
47
|
-
const topLeftX = -halfWidth + cornerPadding + suitEdgeBuffer;
|
|
48
|
-
const topLeftY = -halfHeight + cornerPadding + cornerFontSize * half;
|
|
58
|
+
const topLeftX = -halfWidth + cornerPadding + suitEdgeBuffer, topLeftY = -halfHeight + cornerPadding + cornerFontSize * half;
|
|
49
59
|
ctx.save();
|
|
50
60
|
ctx.translate(topLeftX, topLeftY);
|
|
51
61
|
ctx.beginPath();
|