@tsparticles/shape-cards 3.0.0-alpha.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/LICENSE +21 -0
- package/README.md +72 -0
- package/browser/CardsSuitsDrawers.js +21 -0
- package/browser/ICardsPath.js +1 -0
- package/browser/Utils.js +161 -0
- package/browser/index.js +7 -0
- package/cjs/CardsSuitsDrawers.js +28 -0
- package/cjs/ICardsPath.js +2 -0
- package/cjs/Utils.js +165 -0
- package/cjs/index.js +22 -0
- package/esm/CardsSuitsDrawers.js +21 -0
- package/esm/ICardsPath.js +1 -0
- package/esm/Utils.js +161 -0
- package/esm/index.js +7 -0
- package/package.json +91 -0
- package/report.html +39 -0
- package/tsparticles.shape.cards.js +350 -0
- package/tsparticles.shape.cards.min.js +2 -0
- package/tsparticles.shape.cards.min.js.LICENSE.txt +8 -0
- package/types/CardsSuitsDrawers.d.ts +13 -0
- package/types/ICardsPath.d.ts +13 -0
- package/types/Utils.d.ts +3 -0
- package/types/index.d.ts +2 -0
- package/umd/CardsSuitsDrawers.js +38 -0
- package/umd/ICardsPath.js +12 -0
- package/umd/Utils.js +175 -0
- package/umd/index.js +21 -0
|
@@ -0,0 +1,350 @@
|
|
|
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
|
+
* v3.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
11
|
+
module.exports = factory();
|
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
|
13
|
+
define([], factory);
|
|
14
|
+
else {
|
|
15
|
+
var a = factory();
|
|
16
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
|
+
}
|
|
18
|
+
})(this, () => {
|
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
|
20
|
+
/******/ "use strict";
|
|
21
|
+
/******/ // The require scope
|
|
22
|
+
/******/ var __webpack_require__ = {};
|
|
23
|
+
/******/
|
|
24
|
+
/************************************************************************/
|
|
25
|
+
/******/ /* webpack/runtime/define property getters */
|
|
26
|
+
/******/ (() => {
|
|
27
|
+
/******/ // define getter functions for harmony exports
|
|
28
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
29
|
+
/******/ for(var key in definition) {
|
|
30
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
31
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
32
|
+
/******/ }
|
|
33
|
+
/******/ }
|
|
34
|
+
/******/ };
|
|
35
|
+
/******/ })();
|
|
36
|
+
/******/
|
|
37
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
38
|
+
/******/ (() => {
|
|
39
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
40
|
+
/******/ })();
|
|
41
|
+
/******/
|
|
42
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
43
|
+
/******/ (() => {
|
|
44
|
+
/******/ // define __esModule on exports
|
|
45
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
46
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
+
/******/ }
|
|
49
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
/******/ };
|
|
51
|
+
/******/ })();
|
|
52
|
+
/******/
|
|
53
|
+
/************************************************************************/
|
|
54
|
+
var __webpack_exports__ = {};
|
|
55
|
+
// ESM COMPAT FLAG
|
|
56
|
+
__webpack_require__.r(__webpack_exports__);
|
|
57
|
+
|
|
58
|
+
// EXPORTS
|
|
59
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
60
|
+
"loadCardsShape": () => (/* binding */ loadCardsShape)
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
64
|
+
function drawPath(ctx, radius, path) {
|
|
65
|
+
if (!path.segments.length || !path.segments[0].values.length) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
ctx.moveTo(path.segments[0].values[0].x * radius, path.segments[0].values[0].y * radius);
|
|
69
|
+
for (let i = 0; i < path.segments.length; i++) {
|
|
70
|
+
const segment = path.segments[i];
|
|
71
|
+
ctx.bezierCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius, segment.values[3].x * radius, segment.values[3].y * radius);
|
|
72
|
+
}
|
|
73
|
+
for (let i = path.segments.length - 1; i >= 0; i--) {
|
|
74
|
+
const segment = path.segments[i];
|
|
75
|
+
ctx.bezierCurveTo(-segment.values[2].x * radius, segment.values[2].y * radius, -segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[0].x * radius, segment.values[0].y * radius);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const n = 1.0 / 2;
|
|
79
|
+
const paths = {
|
|
80
|
+
heart: {
|
|
81
|
+
segments: [{
|
|
82
|
+
values: [{
|
|
83
|
+
x: 0,
|
|
84
|
+
y: n
|
|
85
|
+
}, {
|
|
86
|
+
x: 0,
|
|
87
|
+
y: n
|
|
88
|
+
}, {
|
|
89
|
+
x: n,
|
|
90
|
+
y: 0
|
|
91
|
+
}, {
|
|
92
|
+
x: n,
|
|
93
|
+
y: -n / 2
|
|
94
|
+
}]
|
|
95
|
+
}, {
|
|
96
|
+
values: [{
|
|
97
|
+
x: n,
|
|
98
|
+
y: -n / 2
|
|
99
|
+
}, {
|
|
100
|
+
x: n,
|
|
101
|
+
y: -n / 2
|
|
102
|
+
}, {
|
|
103
|
+
x: n,
|
|
104
|
+
y: -n
|
|
105
|
+
}, {
|
|
106
|
+
x: n / 2,
|
|
107
|
+
y: -n
|
|
108
|
+
}]
|
|
109
|
+
}, {
|
|
110
|
+
values: [{
|
|
111
|
+
x: n / 2,
|
|
112
|
+
y: -n
|
|
113
|
+
}, {
|
|
114
|
+
x: n / 2,
|
|
115
|
+
y: -n
|
|
116
|
+
}, {
|
|
117
|
+
x: 0,
|
|
118
|
+
y: -n
|
|
119
|
+
}, {
|
|
120
|
+
x: 0,
|
|
121
|
+
y: -n / 2
|
|
122
|
+
}]
|
|
123
|
+
}]
|
|
124
|
+
},
|
|
125
|
+
diamond: {
|
|
126
|
+
segments: [{
|
|
127
|
+
values: [{
|
|
128
|
+
x: 0,
|
|
129
|
+
y: n
|
|
130
|
+
}, {
|
|
131
|
+
x: 0,
|
|
132
|
+
y: n
|
|
133
|
+
}, {
|
|
134
|
+
x: 3 * n / 4,
|
|
135
|
+
y: 0
|
|
136
|
+
}, {
|
|
137
|
+
x: 3 * n / 4,
|
|
138
|
+
y: 0
|
|
139
|
+
}]
|
|
140
|
+
}, {
|
|
141
|
+
values: [{
|
|
142
|
+
x: 3 * n / 4,
|
|
143
|
+
y: 0
|
|
144
|
+
}, {
|
|
145
|
+
x: 3 * n / 4,
|
|
146
|
+
y: 0
|
|
147
|
+
}, {
|
|
148
|
+
x: 0,
|
|
149
|
+
y: -n
|
|
150
|
+
}, {
|
|
151
|
+
x: 0,
|
|
152
|
+
y: -n
|
|
153
|
+
}]
|
|
154
|
+
}]
|
|
155
|
+
},
|
|
156
|
+
club: {
|
|
157
|
+
segments: [{
|
|
158
|
+
values: [{
|
|
159
|
+
x: 0,
|
|
160
|
+
y: -n
|
|
161
|
+
}, {
|
|
162
|
+
x: 0,
|
|
163
|
+
y: -n
|
|
164
|
+
}, {
|
|
165
|
+
x: n / 2,
|
|
166
|
+
y: -n
|
|
167
|
+
}, {
|
|
168
|
+
x: n / 2,
|
|
169
|
+
y: -n / 2
|
|
170
|
+
}]
|
|
171
|
+
}, {
|
|
172
|
+
values: [{
|
|
173
|
+
x: n / 2,
|
|
174
|
+
y: -n / 2
|
|
175
|
+
}, {
|
|
176
|
+
x: n / 2,
|
|
177
|
+
y: -n / 2
|
|
178
|
+
}, {
|
|
179
|
+
x: n,
|
|
180
|
+
y: -n / 2
|
|
181
|
+
}, {
|
|
182
|
+
x: n,
|
|
183
|
+
y: 0
|
|
184
|
+
}]
|
|
185
|
+
}, {
|
|
186
|
+
values: [{
|
|
187
|
+
x: n,
|
|
188
|
+
y: 0
|
|
189
|
+
}, {
|
|
190
|
+
x: n,
|
|
191
|
+
y: 0
|
|
192
|
+
}, {
|
|
193
|
+
x: n,
|
|
194
|
+
y: n / 2
|
|
195
|
+
}, {
|
|
196
|
+
x: n / 2,
|
|
197
|
+
y: n / 2
|
|
198
|
+
}]
|
|
199
|
+
}, {
|
|
200
|
+
values: [{
|
|
201
|
+
x: n / 2,
|
|
202
|
+
y: n / 2
|
|
203
|
+
}, {
|
|
204
|
+
x: n / 2,
|
|
205
|
+
y: n / 2
|
|
206
|
+
}, {
|
|
207
|
+
x: n / 8,
|
|
208
|
+
y: n / 2
|
|
209
|
+
}, {
|
|
210
|
+
x: n / 8,
|
|
211
|
+
y: n / 8
|
|
212
|
+
}]
|
|
213
|
+
}, {
|
|
214
|
+
values: [{
|
|
215
|
+
x: n / 8,
|
|
216
|
+
y: n / 8
|
|
217
|
+
}, {
|
|
218
|
+
x: n / 8,
|
|
219
|
+
y: n / 2
|
|
220
|
+
}, {
|
|
221
|
+
x: n / 2,
|
|
222
|
+
y: n
|
|
223
|
+
}, {
|
|
224
|
+
x: n / 2,
|
|
225
|
+
y: n
|
|
226
|
+
}]
|
|
227
|
+
}, {
|
|
228
|
+
values: [{
|
|
229
|
+
x: n / 2,
|
|
230
|
+
y: n
|
|
231
|
+
}, {
|
|
232
|
+
x: n / 2,
|
|
233
|
+
y: n
|
|
234
|
+
}, {
|
|
235
|
+
x: 0,
|
|
236
|
+
y: n
|
|
237
|
+
}, {
|
|
238
|
+
x: 0,
|
|
239
|
+
y: n
|
|
240
|
+
}]
|
|
241
|
+
}]
|
|
242
|
+
},
|
|
243
|
+
spade: {
|
|
244
|
+
segments: [{
|
|
245
|
+
values: [{
|
|
246
|
+
x: 0,
|
|
247
|
+
y: -n
|
|
248
|
+
}, {
|
|
249
|
+
x: 0,
|
|
250
|
+
y: -n
|
|
251
|
+
}, {
|
|
252
|
+
x: n,
|
|
253
|
+
y: -n / 2
|
|
254
|
+
}, {
|
|
255
|
+
x: n,
|
|
256
|
+
y: 0
|
|
257
|
+
}]
|
|
258
|
+
}, {
|
|
259
|
+
values: [{
|
|
260
|
+
x: n,
|
|
261
|
+
y: 0
|
|
262
|
+
}, {
|
|
263
|
+
x: n,
|
|
264
|
+
y: 0
|
|
265
|
+
}, {
|
|
266
|
+
x: n,
|
|
267
|
+
y: n / 2
|
|
268
|
+
}, {
|
|
269
|
+
x: n / 2,
|
|
270
|
+
y: n / 2
|
|
271
|
+
}]
|
|
272
|
+
}, {
|
|
273
|
+
values: [{
|
|
274
|
+
x: n / 2,
|
|
275
|
+
y: n / 2
|
|
276
|
+
}, {
|
|
277
|
+
x: n / 2,
|
|
278
|
+
y: n / 2
|
|
279
|
+
}, {
|
|
280
|
+
x: n / 8,
|
|
281
|
+
y: n / 2
|
|
282
|
+
}, {
|
|
283
|
+
x: n / 8,
|
|
284
|
+
y: n / 8
|
|
285
|
+
}]
|
|
286
|
+
}, {
|
|
287
|
+
values: [{
|
|
288
|
+
x: n / 8,
|
|
289
|
+
y: n / 8
|
|
290
|
+
}, {
|
|
291
|
+
x: n / 8,
|
|
292
|
+
y: n / 2
|
|
293
|
+
}, {
|
|
294
|
+
x: n / 2,
|
|
295
|
+
y: n
|
|
296
|
+
}, {
|
|
297
|
+
x: n / 2,
|
|
298
|
+
y: n
|
|
299
|
+
}]
|
|
300
|
+
}, {
|
|
301
|
+
values: [{
|
|
302
|
+
x: n / 2,
|
|
303
|
+
y: n
|
|
304
|
+
}, {
|
|
305
|
+
x: n / 2,
|
|
306
|
+
y: n
|
|
307
|
+
}, {
|
|
308
|
+
x: 0,
|
|
309
|
+
y: n
|
|
310
|
+
}, {
|
|
311
|
+
x: 0,
|
|
312
|
+
y: n
|
|
313
|
+
}]
|
|
314
|
+
}]
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
;// CONCATENATED MODULE: ./dist/browser/CardsSuitsDrawers.js
|
|
318
|
+
|
|
319
|
+
class SpadeDrawer {
|
|
320
|
+
draw(context, particle, radius) {
|
|
321
|
+
drawPath(context, radius, paths.spade);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
class HeartDrawer {
|
|
325
|
+
draw(context, particle, radius) {
|
|
326
|
+
drawPath(context, radius, paths.heart);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
class DiamondDrawer {
|
|
330
|
+
draw(context, particle, radius) {
|
|
331
|
+
drawPath(context, radius, paths.diamond);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
class ClubDrawer {
|
|
335
|
+
draw(context, particle, radius) {
|
|
336
|
+
drawPath(context, radius, paths.club);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
340
|
+
|
|
341
|
+
async function loadCardsShape(engine) {
|
|
342
|
+
await engine.addShape(["spade", "spades"], new SpadeDrawer());
|
|
343
|
+
await engine.addShape(["heart", "hearts"], new HeartDrawer());
|
|
344
|
+
await engine.addShape(["diamond", "diamonds"], new DiamondDrawer());
|
|
345
|
+
await engine.addShape(["club", "clubs"], new ClubDrawer());
|
|
346
|
+
}
|
|
347
|
+
/******/ return __webpack_exports__;
|
|
348
|
+
/******/ })()
|
|
349
|
+
;
|
|
350
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.shape.cards.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,s){if("object"==typeof exports&&"object"==typeof module)module.exports=s();else if("function"==typeof define&&define.amd)define([],s);else{var y=s();for(var a in y)("object"==typeof exports?exports:e)[a]=y[a]}}(this,(()=>(()=>{"use strict";var e={d:(s,y)=>{for(var a in y)e.o(y,a)&&!e.o(s,a)&&Object.defineProperty(s,a,{enumerable:!0,get:y[a]})},o:(e,s)=>Object.prototype.hasOwnProperty.call(e,s),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},s={};function y(e,s,y){if(y.segments.length&&y.segments[0].values.length){e.moveTo(y.segments[0].values[0].x*s,y.segments[0].values[0].y*s);for(let a=0;a<y.segments.length;a++){const x=y.segments[a];e.bezierCurveTo(x.values[1].x*s,x.values[1].y*s,x.values[2].x*s,x.values[2].y*s,x.values[3].x*s,x.values[3].y*s)}for(let a=y.segments.length-1;a>=0;a--){const x=y.segments[a];e.bezierCurveTo(-x.values[2].x*s,x.values[2].y*s,-x.values[1].x*s,x.values[1].y*s,-x.values[0].x*s,x.values[0].y*s)}}}e.r(s),e.d(s,{loadCardsShape:()=>o});const a=.5,x={heart:{segments:[{values:[{x:0,y:a},{x:0,y:a},{x:a,y:0},{x:a,y:-a/2}]},{values:[{x:a,y:-a/2},{x:a,y:-a/2},{x:a,y:-a},{x:a/2,y:-a}]},{values:[{x:a/2,y:-a},{x:a/2,y:-a},{x:0,y:-a},{x:0,y:-a/2}]}]},diamond:{segments:[{values:[{x:0,y:a},{x:0,y:a},{x:.375,y:0},{x:.375,y:0}]},{values:[{x:.375,y:0},{x:.375,y:0},{x:0,y:-a},{x:0,y:-a}]}]},club:{segments:[{values:[{x:0,y:-a},{x:0,y:-a},{x:a/2,y:-a},{x:a/2,y:-a/2}]},{values:[{x:a/2,y:-a/2},{x:a/2,y:-a/2},{x:a,y:-a/2},{x:a,y:0}]},{values:[{x:a,y:0},{x:a,y:0},{x:a,y:a/2},{x:a/2,y:a/2}]},{values:[{x:a/2,y:a/2},{x:a/2,y:a/2},{x:a/8,y:a/2},{x:a/8,y:a/8}]},{values:[{x:a/8,y:a/8},{x:a/8,y:a/2},{x:a/2,y:a},{x:a/2,y:a}]},{values:[{x:a/2,y:a},{x:a/2,y:a},{x:0,y:a},{x:0,y:a}]}]},spade:{segments:[{values:[{x:0,y:-a},{x:0,y:-a},{x:a,y:-a/2},{x:a,y:0}]},{values:[{x:a,y:0},{x:a,y:0},{x:a,y:a/2},{x:a/2,y:a/2}]},{values:[{x:a/2,y:a/2},{x:a/2,y:a/2},{x:a/8,y:a/2},{x:a/8,y:a/8}]},{values:[{x:a/8,y:a/8},{x:a/8,y:a/2},{x:a/2,y:a},{x:a/2,y:a}]},{values:[{x:a/2,y:a},{x:a/2,y:a},{x:0,y:a},{x:0,y:a}]}]}};class t{draw(e,s,a){y(e,a,x.spade)}}class l{draw(e,s,a){y(e,a,x.heart)}}class n{draw(e,s,a){y(e,a,x.diamond)}}class u{draw(e,s,a){y(e,a,x.club)}}async function o(e){await e.addShape(["spade","spades"],new t),await e.addShape(["heart","hearts"],new l),await e.addShape(["diamond","diamonds"],new n),await e.addShape(["club","clubs"],new u)}return s})()));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IParticle, IShapeDrawer } from "@tsparticles/engine";
|
|
2
|
+
export declare class SpadeDrawer implements IShapeDrawer {
|
|
3
|
+
draw(context: CanvasRenderingContext2D, particle: IParticle, radius: number): void;
|
|
4
|
+
}
|
|
5
|
+
export declare class HeartDrawer implements IShapeDrawer {
|
|
6
|
+
draw(context: CanvasRenderingContext2D, particle: IParticle, radius: number): void;
|
|
7
|
+
}
|
|
8
|
+
export declare class DiamondDrawer implements IShapeDrawer {
|
|
9
|
+
draw(context: CanvasRenderingContext2D, particle: IParticle, radius: number): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class ClubDrawer implements IShapeDrawer {
|
|
12
|
+
draw(context: CanvasRenderingContext2D, particle: IParticle, radius: number): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ICoordinates } from "@tsparticles/engine";
|
|
2
|
+
export interface IPathSegment {
|
|
3
|
+
values: ICoordinates[];
|
|
4
|
+
}
|
|
5
|
+
export interface IPath {
|
|
6
|
+
segments: IPathSegment[];
|
|
7
|
+
}
|
|
8
|
+
export interface ICardsPath {
|
|
9
|
+
readonly club: IPath;
|
|
10
|
+
readonly diamond: IPath;
|
|
11
|
+
readonly heart: IPath;
|
|
12
|
+
readonly spade: IPath;
|
|
13
|
+
}
|
package/types/Utils.d.ts
ADDED
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./Utils"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ClubDrawer = exports.DiamondDrawer = exports.HeartDrawer = exports.SpadeDrawer = void 0;
|
|
13
|
+
const Utils_1 = require("./Utils");
|
|
14
|
+
class SpadeDrawer {
|
|
15
|
+
draw(context, particle, radius) {
|
|
16
|
+
(0, Utils_1.drawPath)(context, radius, Utils_1.paths.spade);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.SpadeDrawer = SpadeDrawer;
|
|
20
|
+
class HeartDrawer {
|
|
21
|
+
draw(context, particle, radius) {
|
|
22
|
+
(0, Utils_1.drawPath)(context, radius, Utils_1.paths.heart);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.HeartDrawer = HeartDrawer;
|
|
26
|
+
class DiamondDrawer {
|
|
27
|
+
draw(context, particle, radius) {
|
|
28
|
+
(0, Utils_1.drawPath)(context, radius, Utils_1.paths.diamond);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.DiamondDrawer = DiamondDrawer;
|
|
32
|
+
class ClubDrawer {
|
|
33
|
+
draw(context, particle, radius) {
|
|
34
|
+
(0, Utils_1.drawPath)(context, radius, Utils_1.paths.club);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ClubDrawer = ClubDrawer;
|
|
38
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
package/umd/Utils.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.paths = exports.drawPath = void 0;
|
|
13
|
+
function drawPath(ctx, radius, path) {
|
|
14
|
+
if (!path.segments.length || !path.segments[0].values.length) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
ctx.moveTo(path.segments[0].values[0].x * radius, path.segments[0].values[0].y * radius);
|
|
18
|
+
for (let i = 0; i < path.segments.length; i++) {
|
|
19
|
+
const segment = path.segments[i];
|
|
20
|
+
ctx.bezierCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius, segment.values[3].x * radius, segment.values[3].y * radius);
|
|
21
|
+
}
|
|
22
|
+
for (let i = path.segments.length - 1; i >= 0; i--) {
|
|
23
|
+
const segment = path.segments[i];
|
|
24
|
+
ctx.bezierCurveTo(-segment.values[2].x * radius, segment.values[2].y * radius, -segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[0].x * radius, segment.values[0].y * radius);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.drawPath = drawPath;
|
|
28
|
+
const n = 1.0 / 2;
|
|
29
|
+
exports.paths = {
|
|
30
|
+
heart: {
|
|
31
|
+
segments: [
|
|
32
|
+
{
|
|
33
|
+
values: [
|
|
34
|
+
{ x: 0, y: n },
|
|
35
|
+
{ x: 0, y: n },
|
|
36
|
+
{ x: n, y: 0 },
|
|
37
|
+
{ x: n, y: -n / 2 },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
values: [
|
|
42
|
+
{ x: n, y: -n / 2 },
|
|
43
|
+
{ x: n, y: -n / 2 },
|
|
44
|
+
{ x: n, y: -n },
|
|
45
|
+
{ x: n / 2, y: -n },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
values: [
|
|
50
|
+
{ x: n / 2, y: -n },
|
|
51
|
+
{ x: n / 2, y: -n },
|
|
52
|
+
{ x: 0, y: -n },
|
|
53
|
+
{ x: 0, y: -n / 2 },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
diamond: {
|
|
59
|
+
segments: [
|
|
60
|
+
{
|
|
61
|
+
values: [
|
|
62
|
+
{ x: 0, y: n },
|
|
63
|
+
{ x: 0, y: n },
|
|
64
|
+
{ x: (3 * n) / 4, y: 0 },
|
|
65
|
+
{ x: (3 * n) / 4, y: 0 },
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
values: [
|
|
70
|
+
{ x: (3 * n) / 4, y: 0 },
|
|
71
|
+
{ x: (3 * n) / 4, y: 0 },
|
|
72
|
+
{ x: 0, y: -n },
|
|
73
|
+
{ x: 0, y: -n },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
club: {
|
|
79
|
+
segments: [
|
|
80
|
+
{
|
|
81
|
+
values: [
|
|
82
|
+
{ x: 0, y: -n },
|
|
83
|
+
{ x: 0, y: -n },
|
|
84
|
+
{ x: n / 2, y: -n },
|
|
85
|
+
{ x: n / 2, y: -n / 2 },
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
values: [
|
|
90
|
+
{ x: n / 2, y: -n / 2 },
|
|
91
|
+
{ x: n / 2, y: -n / 2 },
|
|
92
|
+
{ x: n, y: -n / 2 },
|
|
93
|
+
{ x: n, y: 0 },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
values: [
|
|
98
|
+
{ x: n, y: 0 },
|
|
99
|
+
{ x: n, y: 0 },
|
|
100
|
+
{ x: n, y: n / 2 },
|
|
101
|
+
{ x: n / 2, y: n / 2 },
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
values: [
|
|
106
|
+
{ x: n / 2, y: n / 2 },
|
|
107
|
+
{ x: n / 2, y: n / 2 },
|
|
108
|
+
{ x: n / 8, y: n / 2 },
|
|
109
|
+
{ x: n / 8, y: n / 8 },
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
values: [
|
|
114
|
+
{ x: n / 8, y: n / 8 },
|
|
115
|
+
{ x: n / 8, y: n / 2 },
|
|
116
|
+
{ x: n / 2, y: n },
|
|
117
|
+
{ x: n / 2, y: n },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
values: [
|
|
122
|
+
{ x: n / 2, y: n },
|
|
123
|
+
{ x: n / 2, y: n },
|
|
124
|
+
{ x: 0, y: n },
|
|
125
|
+
{ x: 0, y: n },
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
spade: {
|
|
131
|
+
segments: [
|
|
132
|
+
{
|
|
133
|
+
values: [
|
|
134
|
+
{ x: 0, y: -n },
|
|
135
|
+
{ x: 0, y: -n },
|
|
136
|
+
{ x: n, y: -n / 2 },
|
|
137
|
+
{ x: n, y: 0 },
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
values: [
|
|
142
|
+
{ x: n, y: 0 },
|
|
143
|
+
{ x: n, y: 0 },
|
|
144
|
+
{ x: n, y: n / 2 },
|
|
145
|
+
{ x: n / 2, y: n / 2 },
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
values: [
|
|
150
|
+
{ x: n / 2, y: n / 2 },
|
|
151
|
+
{ x: n / 2, y: n / 2 },
|
|
152
|
+
{ x: n / 8, y: n / 2 },
|
|
153
|
+
{ x: n / 8, y: n / 8 },
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
values: [
|
|
158
|
+
{ x: n / 8, y: n / 8 },
|
|
159
|
+
{ x: n / 8, y: n / 2 },
|
|
160
|
+
{ x: n / 2, y: n },
|
|
161
|
+
{ x: n / 2, y: n },
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
values: [
|
|
166
|
+
{ x: n / 2, y: n },
|
|
167
|
+
{ x: n / 2, y: n },
|
|
168
|
+
{ x: 0, y: n },
|
|
169
|
+
{ x: 0, y: n },
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./CardsSuitsDrawers"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadCardsShape = void 0;
|
|
13
|
+
const CardsSuitsDrawers_1 = require("./CardsSuitsDrawers");
|
|
14
|
+
async function loadCardsShape(engine) {
|
|
15
|
+
await engine.addShape(["spade", "spades"], new CardsSuitsDrawers_1.SpadeDrawer());
|
|
16
|
+
await engine.addShape(["heart", "hearts"], new CardsSuitsDrawers_1.HeartDrawer());
|
|
17
|
+
await engine.addShape(["diamond", "diamonds"], new CardsSuitsDrawers_1.DiamondDrawer());
|
|
18
|
+
await engine.addShape(["club", "clubs"], new CardsSuitsDrawers_1.ClubDrawer());
|
|
19
|
+
}
|
|
20
|
+
exports.loadCardsShape = loadCardsShape;
|
|
21
|
+
});
|