@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.
- 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/README.md +1 -1
- package/browser/CardValue.js +16 -0
- package/browser/SuitType.js +7 -0
- package/browser/cards/CardDrawer.js +21 -0
- package/browser/cards/index.js +9 -0
- package/browser/clubs/ClubDrawer.js +4 -5
- package/browser/clubs/index.js +7 -5
- package/browser/diamonds/DiamondDrawer.js +4 -5
- package/browser/diamonds/index.js +7 -5
- package/browser/hearts/HeartDrawer.js +4 -5
- package/browser/hearts/index.js +7 -5
- package/browser/index.js +24 -6
- package/browser/paths.js +174 -0
- package/browser/spades/SpadeDrawer.js +4 -5
- package/browser/spades/index.js +7 -5
- package/browser/utils.js +100 -0
- package/cjs/CardParticle.js +1 -0
- package/cjs/CardValue.js +16 -0
- package/cjs/ICardData.js +1 -0
- package/cjs/ICardSuitsPath.js +1 -0
- package/cjs/SuitType.js +7 -0
- package/cjs/cards/CardDrawer.js +21 -0
- package/cjs/cards/index.js +9 -0
- package/cjs/clubs/ClubDrawer.js +4 -5
- package/cjs/clubs/index.js +7 -5
- package/cjs/diamonds/DiamondDrawer.js +4 -5
- package/cjs/diamonds/index.js +7 -5
- package/cjs/hearts/HeartDrawer.js +4 -5
- package/cjs/hearts/index.js +7 -5
- package/cjs/index.js +24 -6
- package/cjs/paths.js +174 -0
- package/cjs/spades/SpadeDrawer.js +4 -5
- package/cjs/spades/index.js +7 -5
- package/cjs/utils.js +100 -0
- package/dist_browser_cards_CardDrawer_js.js +60 -0
- package/dist_browser_clubs_ClubDrawer_js.js +17 -7
- package/dist_browser_diamonds_DiamondDrawer_js.js +17 -7
- package/dist_browser_hearts_HeartDrawer_js.js +17 -7
- package/dist_browser_spades_SpadeDrawer_js.js +15 -5
- package/esm/CardParticle.js +1 -0
- package/esm/CardValue.js +16 -0
- package/esm/ICardData.js +1 -0
- package/esm/ICardSuitsPath.js +1 -0
- package/esm/SuitType.js +7 -0
- package/esm/cards/CardDrawer.js +21 -0
- package/esm/cards/index.js +9 -0
- package/esm/clubs/ClubDrawer.js +4 -5
- package/esm/clubs/index.js +7 -5
- package/esm/diamonds/DiamondDrawer.js +4 -5
- package/esm/diamonds/index.js +7 -5
- package/esm/hearts/HeartDrawer.js +4 -5
- package/esm/hearts/index.js +7 -5
- package/esm/index.js +24 -6
- package/esm/paths.js +174 -0
- package/esm/spades/SpadeDrawer.js +4 -5
- package/esm/spades/index.js +7 -5
- package/esm/utils.js +100 -0
- package/package.json +3 -2
- package/report.html +3 -3
- package/tsparticles.shape.cards.js +60 -18
- package/tsparticles.shape.cards.min.js +2 -2
- package/types/CardParticle.d.ts +5 -0
- package/types/CardValue.d.ts +15 -0
- package/types/ICardData.d.ts +7 -0
- package/types/ICardSuitsPath.d.ts +3 -0
- package/types/SuitType.d.ts +6 -0
- package/types/cards/CardDrawer.d.ts +6 -0
- package/types/cards/index.d.ts +2 -0
- package/types/clubs/ClubDrawer.d.ts +0 -1
- package/types/clubs/index.d.ts +1 -1
- package/types/diamonds/DiamondDrawer.d.ts +0 -1
- package/types/diamonds/index.d.ts +1 -1
- package/types/hearts/HeartDrawer.d.ts +0 -1
- package/types/hearts/index.d.ts +1 -1
- package/types/index.d.ts +2 -0
- package/types/paths.d.ts +7 -0
- package/types/spades/SpadeDrawer.d.ts +0 -1
- package/types/spades/index.d.ts +1 -1
- package/types/utils.d.ts +2 -0
- package/umd/CardValue.js +29 -0
- package/umd/ICardData.js +12 -0
- package/umd/ICardSuitsPath.js +12 -0
- package/umd/SuitType.js +20 -0
- package/umd/cards/CardDrawer.js +35 -0
- package/umd/cards/index.js +56 -0
- package/umd/clubs/ClubDrawer.js +5 -6
- package/umd/clubs/index.js +8 -6
- package/umd/diamonds/DiamondDrawer.js +5 -6
- package/umd/diamonds/index.js +8 -6
- package/umd/hearts/HeartDrawer.js +5 -6
- package/umd/hearts/index.js +8 -6
- package/umd/index.js +26 -7
- package/umd/paths.js +187 -0
- package/umd/spades/SpadeDrawer.js +5 -6
- package/umd/spades/index.js +8 -6
- package/umd/utils.js +113 -0
- 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/browser/Utils.js +0 -161
- package/cjs/Utils.js +0 -161
- package/esm/Utils.js +0 -161
- package/tsparticles.shape.cards.min.js.LICENSE.txt +0 -1
- package/types/ICardsPath.d.ts +0 -13
- package/types/Utils.d.ts +0 -4
- package/umd/Utils.js +0 -175
- /package/browser/{ICardsPath.js → CardParticle.js} +0 -0
- /package/{cjs/ICardsPath.js → browser/ICardData.js} +0 -0
- /package/{esm/ICardsPath.js → browser/ICardSuitsPath.js} +0 -0
- /package/umd/{ICardsPath.js → CardParticle.js} +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { drawPath
|
|
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
|
-
|
|
5
|
+
const { context, radius } = data;
|
|
6
|
+
drawPath(context, radius, paths.diamonds);
|
|
8
7
|
}
|
|
9
8
|
}
|
package/cjs/diamonds/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export async function
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
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
|
-
|
|
5
|
+
const { context, radius } = data;
|
|
6
|
+
drawPath(context, radius, paths.hearts);
|
|
8
7
|
}
|
|
9
8
|
}
|
package/cjs/hearts/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export async function
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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/cjs/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-
|
|
19
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
20
|
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
await
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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";
|
package/cjs/paths.js
ADDED
|
@@ -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
|
|
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
|
-
|
|
5
|
+
const { context, radius } = data;
|
|
6
|
+
drawPath(context, radius, paths.spades);
|
|
8
7
|
}
|
|
9
8
|
}
|
package/cjs/spades/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export async function
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
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
|
}
|
package/cjs/utils.js
ADDED
|
@@ -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,60 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_shape_cards"] = this["webpackChunk_tsparticles_shape_cards"] || []).push([["dist_browser_cards_CardDrawer_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/SuitType.js"
|
|
21
|
+
/*!**********************************!*\
|
|
22
|
+
!*** ./dist/browser/SuitType.js ***!
|
|
23
|
+
\**********************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SuitType: () => (/* binding */ SuitType)\n/* harmony export */ });\nvar SuitType;\n(function(SuitType) {\n SuitType[\"hearts\"] = \"hearts\";\n SuitType[\"diamonds\"] = \"diamonds\";\n SuitType[\"clubs\"] = \"clubs\";\n SuitType[\"spades\"] = \"spades\";\n})(SuitType || (SuitType = {}));\n\n\n//# sourceURL=webpack://@tsparticles/shape-cards/./dist/browser/SuitType.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/cards/CardDrawer.js"
|
|
31
|
+
/*!******************************************!*\
|
|
32
|
+
!*** ./dist/browser/cards/CardDrawer.js ***!
|
|
33
|
+
\******************************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CardDrawer: () => (/* binding */ CardDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils.js */ \"./dist/browser/utils.js\");\n\n\nclass CardDrawer {\n draw(data) {\n const { context, particle, opacity, radius } = data;\n if (!particle.cardData) {\n return;\n }\n const defaultOpacity = context.globalAlpha;\n context.globalAlpha = opacity;\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.drawRoundedCard)(context, radius, particle.cardData, particle.container.hdr, particle.isShowingBack(), particle.container.canvas.settings);\n context.globalAlpha = defaultOpacity;\n }\n particleInit(_container, particle) {\n const shape = particle.shapeData;\n if (!shape) {\n return;\n }\n particle.cardData = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, shape);\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-cards/./dist/browser/cards/CardDrawer.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ },
|
|
39
|
+
|
|
40
|
+
/***/ "./dist/browser/paths.js"
|
|
41
|
+
/*!*******************************!*\
|
|
42
|
+
!*** ./dist/browser/paths.js ***!
|
|
43
|
+
\*******************************/
|
|
44
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
|
+
|
|
46
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ club: () => (/* binding */ club),\n/* harmony export */ diamond: () => (/* binding */ diamond),\n/* harmony export */ heart: () => (/* binding */ heart),\n/* harmony export */ paths: () => (/* binding */ paths),\n/* harmony export */ spade: () => (/* binding */ spade)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/path-utils */ \"@tsparticles/path-utils\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _SuitType_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SuitType.js */ \"./dist/browser/SuitType.js\");\n\n\n\nconst eighth = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.quarter * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.half, n = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.half, halfN = n * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.half, oppositeN = -n, oppositeHalfN = -halfN, eighthN = n * eighth, threeQuarterN = n * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.threeQuarter;\nconst club = {\n half: true,\n segments: [\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: halfN,\n y: oppositeN\n },\n {\n x: halfN,\n y: oppositeHalfN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: oppositeHalfN\n },\n {\n x: halfN,\n y: oppositeHalfN\n },\n {\n x: n,\n y: oppositeHalfN\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: halfN\n },\n {\n x: halfN,\n y: halfN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: halfN\n },\n {\n x: halfN,\n y: halfN\n },\n {\n x: eighthN,\n y: halfN\n },\n {\n x: eighthN,\n y: eighthN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: eighthN,\n y: eighthN\n },\n {\n x: eighthN,\n y: halfN\n },\n {\n x: halfN,\n y: n\n },\n {\n x: halfN,\n y: n\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: n\n },\n {\n x: halfN,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n }\n ]\n }\n ]\n};\nconst diamond = {\n half: true,\n segments: [\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: threeQuarterN,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: threeQuarterN,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: threeQuarterN,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: threeQuarterN,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n }\n ]\n }\n ]\n};\nconst heart = {\n half: true,\n segments: [\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: oppositeHalfN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: n,\n y: oppositeHalfN\n },\n {\n x: n,\n y: oppositeHalfN\n },\n {\n x: n,\n y: oppositeN\n },\n {\n x: halfN,\n y: oppositeN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: oppositeN\n },\n {\n x: halfN,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeHalfN\n }\n ]\n }\n ]\n};\nconst spade = {\n half: true,\n segments: [\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: n,\n y: oppositeHalfN\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: halfN\n },\n {\n x: halfN,\n y: halfN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: halfN\n },\n {\n x: halfN,\n y: halfN\n },\n {\n x: eighthN,\n y: halfN\n },\n {\n x: eighthN,\n y: eighthN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: eighthN,\n y: eighthN\n },\n {\n x: eighthN,\n y: halfN\n },\n {\n x: halfN,\n y: n\n },\n {\n x: halfN,\n y: n\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: n\n },\n {\n x: halfN,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n }\n ]\n }\n ]\n};\nconst paths = {\n [_SuitType_js__WEBPACK_IMPORTED_MODULE_2__.SuitType.hearts]: heart,\n [_SuitType_js__WEBPACK_IMPORTED_MODULE_2__.SuitType.diamonds]: diamond,\n [_SuitType_js__WEBPACK_IMPORTED_MODULE_2__.SuitType.clubs]: club,\n [_SuitType_js__WEBPACK_IMPORTED_MODULE_2__.SuitType.spades]: spade\n};\n\n\n//# sourceURL=webpack://@tsparticles/shape-cards/./dist/browser/paths.js?\n}");
|
|
47
|
+
|
|
48
|
+
/***/ },
|
|
49
|
+
|
|
50
|
+
/***/ "./dist/browser/utils.js"
|
|
51
|
+
/*!*******************************!*\
|
|
52
|
+
!*** ./dist/browser/utils.js ***!
|
|
53
|
+
\*******************************/
|
|
54
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
55
|
+
|
|
56
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawRoundedCard: () => (/* binding */ drawRoundedCard)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _SuitType_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SuitType.js */ \"./dist/browser/SuitType.js\");\n/* harmony import */ var _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tsparticles/path-utils */ \"@tsparticles/path-utils\");\n/* harmony import */ var _paths_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./paths.js */ \"./dist/browser/paths.js\");\n\n\n\n\nconst cardWidthRatio = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.triple, cardHeightRatio = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.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 = {\n r: 215,\n g: 20,\n b: 20\n}, blackSuitColor = {\n r: 18,\n g: 18,\n b: 18\n};\nfunction drawRoundedCard(ctx, radius, cardData, hdr, flipped, canvasSettings) {\n if (flipped) {\n drawRoundedCardBack(ctx, radius);\n } else {\n const cacheKey = getCacheKey(radius, hdr, cardData), cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half, halfHeight = cardHeight * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half;\n let cachedData = cardsCache.get(cacheKey);\n if (!cachedData) {\n let cacheCanvas, cacheCtx;\n if (typeof OffscreenCanvas === \"undefined\") {\n cacheCanvas = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)().createElement(\"canvas\");\n cacheCanvas.width = cardWidth;\n cacheCanvas.height = cardHeight;\n cacheCtx = cacheCanvas.getContext(\"2d\", canvasSettings);\n } else {\n cacheCanvas = new OffscreenCanvas(cardWidth, cardHeight);\n cacheCtx = cacheCanvas.getContext(\"2d\", canvasSettings);\n }\n if (cacheCtx) {\n cacheCtx.translate(halfWidth, halfHeight);\n drawRoundedCardFront(cacheCtx, radius, cardData, hdr);\n cachedData = cacheCanvas instanceof HTMLCanvasElement ? cacheCanvas : cacheCanvas.transferToImageBitmap();\n cardsCache.set(cacheKey, cachedData);\n }\n }\n if (cachedData) {\n ctx.drawImage(cachedData, -halfWidth, -halfHeight, cardWidth, cardHeight);\n } else {\n drawRoundedCardFront(ctx, radius, cardData, hdr);\n }\n }\n}\nfunction getCacheKey(radius, hdr, cardData) {\n return `${radius.toFixed(fixedCacheKey)}-${hdr ? \"hdr\" : \"sdr\"}-${cardData.suit}-${cardData.value}`;\n}\nfunction drawRoundedCardBack(ctx, radius) {\n drawCardBody(ctx, radius);\n}\nfunction drawRoundedCardFront(ctx, radius, cardData, hdr) {\n const { suit, value } = cardData, cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half, halfHeight = cardHeight * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half, cornerPadding = radius * cornerPaddingRatio, cornerFontSize = radius * cornerFontRatio, cornerSuitSize = radius * cornerSuitRatio, centerSuitSize = radius * centerSuitRatio, textOffset = radius * textHorizontalOffsetRatio, suitEdgeBuffer = radius * suitEdgeBufferFactor, isRed = suit === _SuitType_js__WEBPACK_IMPORTED_MODULE_1__.SuitType.hearts || suit === _SuitType_js__WEBPACK_IMPORTED_MODULE_1__.SuitType.diamonds, color = isRed ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(redSuitColor, hdr) : (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(blackSuitColor, hdr);\n ctx.save();\n drawCardBody(ctx, radius);\n ctx.fillStyle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)({\n r: 255,\n g: 255,\n b: 255\n }, hdr);\n ctx.fill();\n ctx.strokeStyle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)({\n r: 0,\n g: 0,\n b: 0\n }, hdr);\n ctx.stroke();\n ctx.fillStyle = color;\n ctx.font = `bold ${cornerFontSize.toString()}px Arial, serif`;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n const topLeftX = -halfWidth + cornerPadding + suitEdgeBuffer, topLeftY = -halfHeight + cornerPadding + cornerFontSize * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half;\n ctx.save();\n ctx.translate(topLeftX, topLeftY);\n ctx.beginPath();\n (0,_tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_2__.drawPath)(ctx, cornerSuitSize, _paths_js__WEBPACK_IMPORTED_MODULE_3__.paths[suit]);\n ctx.fill();\n ctx.restore();\n ctx.fillText(value, topLeftX + textOffset, topLeftY);\n ctx.save();\n ctx.translate(halfWidth - cornerPadding - suitEdgeBuffer, halfHeight - cornerPadding - cornerFontSize * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half);\n ctx.rotate(Math.PI);\n ctx.save();\n ctx.beginPath();\n (0,_tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_2__.drawPath)(ctx, cornerSuitSize, _paths_js__WEBPACK_IMPORTED_MODULE_3__.paths[suit]);\n ctx.fill();\n ctx.restore();\n ctx.fillText(value, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.originPoint.x + textOffset, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.originPoint.y);\n ctx.restore();\n ctx.save();\n ctx.beginPath();\n (0,_tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_2__.drawPath)(ctx, centerSuitSize, _paths_js__WEBPACK_IMPORTED_MODULE_3__.paths[suit]);\n ctx.fillStyle = color;\n ctx.fill();\n ctx.restore();\n ctx.beginPath();\n ctx.arc(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.originPoint.x, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.originPoint.y, minRadius, minAngle, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI, false);\n ctx.closePath();\n ctx.restore();\n}\nfunction drawCardBody(ctx, radius) {\n const cardWidth = radius * cardWidthRatio, cardHeight = radius * cardHeightRatio, halfWidth = cardWidth * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half, halfHeight = cardHeight * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half, cornerRadius = radius * cornerRadiusRatio;\n ctx.beginPath();\n ctx.moveTo(-halfWidth + cornerRadius, -halfHeight);\n ctx.lineTo(halfWidth - cornerRadius, -halfHeight);\n ctx.quadraticCurveTo(halfWidth, -halfHeight, halfWidth, -halfHeight + cornerRadius);\n ctx.lineTo(halfWidth, halfHeight - cornerRadius);\n ctx.quadraticCurveTo(halfWidth, halfHeight, halfWidth - cornerRadius, halfHeight);\n ctx.lineTo(-halfWidth + cornerRadius, halfHeight);\n ctx.quadraticCurveTo(-halfWidth, halfHeight, -halfWidth, halfHeight - cornerRadius);\n ctx.lineTo(-halfWidth, -halfHeight + cornerRadius);\n ctx.quadraticCurveTo(-halfWidth, -halfHeight, -halfWidth + cornerRadius, -halfHeight);\n ctx.closePath();\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-cards/./dist/browser/utils.js?\n}");
|
|
57
|
+
|
|
58
|
+
/***/ }
|
|
59
|
+
|
|
60
|
+
}]);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
*/
|
|
18
18
|
(this["webpackChunk_tsparticles_shape_cards"] = this["webpackChunk_tsparticles_shape_cards"] || []).push([["dist_browser_clubs_ClubDrawer_js"],{
|
|
19
19
|
|
|
20
|
-
/***/ "./dist/browser/
|
|
21
|
-
|
|
22
|
-
!*** ./dist/browser/
|
|
23
|
-
|
|
20
|
+
/***/ "./dist/browser/SuitType.js"
|
|
21
|
+
/*!**********************************!*\
|
|
22
|
+
!*** ./dist/browser/SuitType.js ***!
|
|
23
|
+
\**********************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SuitType: () => (/* binding */ SuitType)\n/* harmony export */ });\nvar SuitType;\n(function(SuitType) {\n SuitType[\"hearts\"] = \"hearts\";\n SuitType[\"diamonds\"] = \"diamonds\";\n SuitType[\"clubs\"] = \"clubs\";\n SuitType[\"spades\"] = \"spades\";\n})(SuitType || (SuitType = {}));\n\n\n//# sourceURL=webpack://@tsparticles/shape-cards/./dist/browser/SuitType.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -33,7 +33,17 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
33
33
|
\******************************************/
|
|
34
34
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
35
|
|
|
36
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ClubDrawer: () => (/* binding */ ClubDrawer)\n/* harmony export */ });\n/* harmony import */ var
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ClubDrawer: () => (/* binding */ ClubDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/path-utils */ \"@tsparticles/path-utils\");\n/* harmony import */ var _paths_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../paths.js */ \"./dist/browser/paths.js\");\n\n\nclass ClubDrawer {\n draw(data) {\n const { context, radius } = data;\n (0,_tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.drawPath)(context, radius, _paths_js__WEBPACK_IMPORTED_MODULE_1__.paths.clubs);\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-cards/./dist/browser/clubs/ClubDrawer.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ },
|
|
39
|
+
|
|
40
|
+
/***/ "./dist/browser/paths.js"
|
|
41
|
+
/*!*******************************!*\
|
|
42
|
+
!*** ./dist/browser/paths.js ***!
|
|
43
|
+
\*******************************/
|
|
44
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
|
+
|
|
46
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ club: () => (/* binding */ club),\n/* harmony export */ diamond: () => (/* binding */ diamond),\n/* harmony export */ heart: () => (/* binding */ heart),\n/* harmony export */ paths: () => (/* binding */ paths),\n/* harmony export */ spade: () => (/* binding */ spade)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/path-utils */ \"@tsparticles/path-utils\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _SuitType_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SuitType.js */ \"./dist/browser/SuitType.js\");\n\n\n\nconst eighth = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.quarter * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.half, n = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.half, halfN = n * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.half, oppositeN = -n, oppositeHalfN = -halfN, eighthN = n * eighth, threeQuarterN = n * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.threeQuarter;\nconst club = {\n half: true,\n segments: [\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: halfN,\n y: oppositeN\n },\n {\n x: halfN,\n y: oppositeHalfN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: oppositeHalfN\n },\n {\n x: halfN,\n y: oppositeHalfN\n },\n {\n x: n,\n y: oppositeHalfN\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: halfN\n },\n {\n x: halfN,\n y: halfN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: halfN\n },\n {\n x: halfN,\n y: halfN\n },\n {\n x: eighthN,\n y: halfN\n },\n {\n x: eighthN,\n y: eighthN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: eighthN,\n y: eighthN\n },\n {\n x: eighthN,\n y: halfN\n },\n {\n x: halfN,\n y: n\n },\n {\n x: halfN,\n y: n\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: n\n },\n {\n x: halfN,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n }\n ]\n }\n ]\n};\nconst diamond = {\n half: true,\n segments: [\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: threeQuarterN,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: threeQuarterN,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: threeQuarterN,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: threeQuarterN,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n }\n ]\n }\n ]\n};\nconst heart = {\n half: true,\n segments: [\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: oppositeHalfN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: n,\n y: oppositeHalfN\n },\n {\n x: n,\n y: oppositeHalfN\n },\n {\n x: n,\n y: oppositeN\n },\n {\n x: halfN,\n y: oppositeN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: oppositeN\n },\n {\n x: halfN,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeHalfN\n }\n ]\n }\n ]\n};\nconst spade = {\n half: true,\n segments: [\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: oppositeN\n },\n {\n x: n,\n y: oppositeHalfN\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty\n },\n {\n x: n,\n y: halfN\n },\n {\n x: halfN,\n y: halfN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: halfN\n },\n {\n x: halfN,\n y: halfN\n },\n {\n x: eighthN,\n y: halfN\n },\n {\n x: eighthN,\n y: eighthN\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: eighthN,\n y: eighthN\n },\n {\n x: eighthN,\n y: halfN\n },\n {\n x: halfN,\n y: n\n },\n {\n x: halfN,\n y: n\n }\n ]\n },\n {\n type: _tsparticles_path_utils__WEBPACK_IMPORTED_MODULE_0__.SegmentType.bezier,\n values: [\n {\n x: halfN,\n y: n\n },\n {\n x: halfN,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n },\n {\n x: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.empty,\n y: n\n }\n ]\n }\n ]\n};\nconst paths = {\n [_SuitType_js__WEBPACK_IMPORTED_MODULE_2__.SuitType.hearts]: heart,\n [_SuitType_js__WEBPACK_IMPORTED_MODULE_2__.SuitType.diamonds]: diamond,\n [_SuitType_js__WEBPACK_IMPORTED_MODULE_2__.SuitType.clubs]: club,\n [_SuitType_js__WEBPACK_IMPORTED_MODULE_2__.SuitType.spades]: spade\n};\n\n\n//# sourceURL=webpack://@tsparticles/shape-cards/./dist/browser/paths.js?\n}");
|
|
37
47
|
|
|
38
48
|
/***/ }
|
|
39
49
|
|