fruta 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +368 -30
  3. package/dist/animation/anim.d.ts +13 -0
  4. package/dist/animation/animate.d.ts +101 -0
  5. package/dist/audio/audio.d.ts +29 -0
  6. package/dist/fruta.d.ts +302 -0
  7. package/dist/fruta.js +19 -0
  8. package/dist/frutaGl.d.ts +277 -0
  9. package/dist/game/behaviors.d.ts +38 -0
  10. package/dist/game/charts.d.ts +127 -0
  11. package/dist/game/play.d.ts +4 -0
  12. package/dist/game/project.d.ts +54 -0
  13. package/dist/input/gamepad.d.ts +38 -0
  14. package/dist/math/math.d.ts +37 -0
  15. package/dist/math/pathfind.d.ts +7 -0
  16. package/dist/math/physics.d.ts +38 -0
  17. package/dist/math/pool.d.ts +11 -0
  18. package/dist/math/spatial.d.ts +10 -0
  19. package/dist/render/create/FontCreator.d.ts +16 -0
  20. package/dist/render/create/SaveRestore.d.ts +5 -0
  21. package/dist/render/create/ShapeCreator.d.ts +49 -0
  22. package/dist/render/create/canvasTarget.d.ts +5 -0
  23. package/dist/render/shaders.d.ts +29 -0
  24. package/dist/render/webgl.d.ts +67 -0
  25. package/dist/renderer.d.ts +42 -0
  26. package/dist/types.d.ts +9 -0
  27. package/dist/utils/logStyle.d.ts +1 -0
  28. package/dist/world/camera.d.ts +24 -0
  29. package/dist/world/entities.d.ts +45 -0
  30. package/dist/world/particles.d.ts +42 -0
  31. package/dist/world/tilemap.d.ts +44 -0
  32. package/dist/world/timers.d.ts +11 -0
  33. package/package.json +35 -35
  34. package/DOCUMENTATION.MD +0 -874
  35. package/dist/main.js +0 -1
  36. package/index.html +0 -9
  37. package/settings.json +0 -6
  38. package/src/core/create/_fontCreator.js +0 -11
  39. package/src/core/create/_saveOrRestore.js +0 -22
  40. package/src/core/create/_shapeCreator.js +0 -20
  41. package/src/core/create/fontCreatorMixin.js +0 -167
  42. package/src/core/create/shapeCreatorMixin.js +0 -656
  43. package/src/core/fruta.js +0 -22
  44. package/src/core/game/game.js +0 -30
  45. package/src/core/game/scene.js +0 -29
  46. package/src/core/game/tick.js +0 -42
  47. package/src/core/utils/logStyle.js +0 -8
  48. package/src/core/utils/utils.js +0 -0
  49. package/src/methods/constants.js +0 -0
  50. package/src/methods/creator/_scene.js +0 -0
  51. package/src/methods/creator/creator.js +0 -0
  52. package/webpack.config.js +0 -47
@@ -1,656 +0,0 @@
1
- /**
2
- * @description - This file will be the mixin for all the shape and yeah, it includes images.
3
- * Maybe you're wonder why we are taking everything about Shapes Creation from Canvas Doc and
4
- * why no just take the doc and do it by youself.
5
- *
6
- * The main reason is because I want to create a nested shape creation and a suggar syntax
7
- * for new devs.
8
- *
9
- * But please, feel free to improve it :).
10
- */
11
-
12
- export const shapesCreatorMixin = {
13
- /**
14
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle
15
- * @description property of the Canvas 2D API specifies the color, gradient,
16
- * or pattern to use inside shapes. The default style is #000 (black
17
- *
18
- * @param {Color} style - CanvasGradient | CanvasPattern
19
- *
20
- * @example - "red" | rgb(25,25,25)
21
- *
22
- * @return ShapeCreator class
23
- */
24
- fillStyleShape(style) {
25
- this.context.fillStyle = style
26
- return this
27
- },
28
-
29
- /**
30
- * @alert
31
- * I think we should separe this methods, but I'm no pretty sure
32
- *
33
- * @param {Array<numbers>} fill - create a rectangle by x, y, width, height
34
- * @param {Array<numbers>} stroke draw a stroke rectangle x, y, width, height
35
- * @param {Array<numbers>} clear - erases the pixels in a rectangular area by setting them to transparent black. side by x, y, width, height
36
- *
37
- * @return ShapeCreator class
38
- */
39
- drawRectShape(
40
- clear = [0, 0, 0, 0],
41
- fill = [0, 0, 0, 0],
42
- stroke = [0, 0, 0, 0]
43
- ) {
44
- this.context.clearRect(...clear)
45
- this.context.fillRect(...fill)
46
- this.context.strokeRect(...stroke)
47
-
48
- return this
49
- },
50
- /**
51
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/roundRect
52
- * @description method of the Canvas 2D API adds a rounded rectangle to the current path.
53
- *
54
- * @param {*} x - x-axis coordinate of the rectangle's starting point, in pixels.
55
- * @param {*} y - y-axis coordinate of the rectangle's starting point, in pixels.
56
- * @param {*} width - rectangle's width. Positive values are to the right, and negative to the left.
57
- * @param {*} height - rectangle's height. Positive values are down, and negative are up.
58
- * @param {Array<number>} radius position by index in array Ex. top-left | top-right | bottom-right | bottom-left
59
- *
60
- * @return ShapeCreator class
61
- */
62
- roundRectShape(x, y, width, height, radius) {
63
- this.context.roundRect(x, y, width, height, radius)
64
- return this
65
- },
66
-
67
- /**
68
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/beginPath
69
- * @description method of the Canvas 2D API starts a new path by emptying the list of
70
- * sub-paths. Call this method when you want to create a new path.
71
- *
72
- * @return ShapeCreator class
73
- */
74
- startShape() {
75
- this.context.beginPath()
76
- return this
77
- },
78
- /**
79
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/stroke
80
- * @description method of the Canvas 2D API strokes (outlines) the current or given
81
- * path with the current stroke style
82
- *
83
- * @param {Path2D} path - A Path2D path to fill.
84
- *
85
- * @return ShapeCreator class
86
- */
87
- strokeShape(...path) {
88
- this.context.stroke(...path)
89
- return this
90
- },
91
- /**
92
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/moveTo
93
- * @description method of the Canvas 2D API begins a new sub-path
94
- * at the point specified by the given (x, y) coordinates
95
- *
96
- * @param {number} x - new horizontal draw position
97
- * @param {number} y - new vertical draw position
98
- *
99
- * @return ShapeCreator class
100
- */
101
- moveTo(x, y) {
102
- this.context.moveTo(x, y)
103
- return this
104
- },
105
- /**
106
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineTo
107
- * @description method lineTo(), part of the Canvas 2D API,
108
- * adds a straight line to the current sub-path by connecting
109
- * the sub-path's last point to the specified (x, y) coordinates
110
- *
111
- * @param {number} x horizontal line position
112
- * @param {number} y vertical line position
113
- *
114
- * @return ShapeCreator class
115
- */
116
- lineTo(x, y) {
117
- this.context.lineTo(x, y)
118
- return this
119
- },
120
- /**
121
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fill
122
- * @description - method of the Canvas 2D API fills the current or given path with the current
123
- *
124
- * @param {string} region algorithm by which to determine if a point is inside or outside the filling region. Possible values:
125
- * nonzero | evenodd.
126
- *
127
- * @return ShapeCreator class
128
- */
129
- fillShape(...param) {
130
- this.context.fill(...param)
131
- return this
132
- },
133
- /**
134
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/arc
135
- * @description method of the Canvas 2D API adds a circular arc to the current sub-path.
136
- *
137
- * @param {number} x - horizontal line position
138
- * @param {number} y - vertical line position
139
- * @param {number} radius - arc radius
140
- * @param {number} startAngle - starting point of the angle.
141
- * @param {number} endAngle - ending point of the angle.
142
- * @param {boolean} counterclockwise - flip draw angle
143
- *
144
- * @return ShapeCreator class
145
- */
146
- arcShape(x, y, radius, startAngle, endAngle, counterclockwise) {
147
- this.context.arc(x, y, radius, startAngle, endAngle, counterclockwise)
148
- return this
149
- },
150
- /**
151
- * @alert
152
- * This can we broke in Firefox
153
- *
154
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/quadraticCurveTo
155
- * @description method of the Canvas 2D API adds a quadratic
156
- * Bézier curve to the current sub-path. It requires two points:
157
- * the first one is a control point and the second one is the end point.
158
- * The starting point is the latest point in the current path,
159
- * which can be changed using moveTo() before creating the quadratic
160
- * Bézier curve.
161
- *
162
- * @param {number} cpx - x-axis coordinate of the control point
163
- * @param {number} cpy - y-axis coordinate of the control point
164
- * @param {number} x - x-axis coordinate of the end point
165
- * @param {number} y - y-axis coordinate of the end point
166
- *
167
- * @return ShapeCreator class
168
- */
169
- quadraticCurveTo(cpx, cpy, x, y) {
170
- this.context.quadraticCurveTo(cpx, cpy, x, y)
171
- return this
172
- },
173
- /**
174
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/bezierCurveTo
175
- * @description method of the Canvas 2D API adds a cubic Bézier
176
- * curve to the current sub-path. It requires three points: the
177
- * first two are control points and the third one is the end point.
178
- * The starting point is the latest point in the current path,
179
- * which can be changed using moveTo() before creating the Bézier curve
180
- *
181
- * @param {*} cp1x - x-axis coordinate of the first control point
182
- * @param {*} cp1y - y-axis coordinate of the first control point
183
- * @param {*} cp2x - x-axis coordinate of the second control point
184
- * @param {*} cp2y - y-axis coordinate of the second control point
185
- * @param {*} x - x-axis coordinate of the end point
186
- * @param {*} y - y-axis coordinate of the end point
187
- *
188
- * @return ShapeCreator class
189
- */
190
- bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
191
- this.context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y)
192
- return this
193
- },
194
-
195
- // All the code below need test
196
- /**
197
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/arcTo
198
- * @description method of the Canvas 2D API adds a circular arc to the current sub-path,
199
- * using the given control points and radius. The arc is automatically connected to the
200
- * path's latest point with a straight line, if necessary for the specified parameters
201
- *
202
- * @param {number} x1 x-axis coordinate of the first control point
203
- * @param {number} y1 y-axis coordinate of the first control point
204
- * @param {number} x2 x-axis coordinate of the second control point
205
- * @param {number} y2 y-axis coordinate of the second control point
206
- * @param {number} radius arc's radius. Must be non-negative
207
- *
208
- * @return ShapeCreator class
209
- */
210
- arcTo(x1, y1, x2, y2, radius) {
211
- this.context.arcTo(x1, y1, x2, y2, radius)
212
- return this
213
- },
214
-
215
- /**
216
- * @todo - I think we can improve this - we need to figure out how to
217
- *
218
- * @description The Path2D() constructor returns a newly instantiated Path2D object,
219
- * optionally with another path as an argument (creates a copy), or optionally with
220
- * a string consisting of SVG path data.
221
- *
222
- * @param {...any} args (new Path2D, domMatrix)
223
- *
224
- * @return Path2D Class
225
- */
226
- path2DShape(...args) {
227
- return new Path2D(...args)
228
- },
229
-
230
- /**
231
- * @todo - I think we can improve this - we need to figure out how to
232
- *
233
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix
234
- * @description The DOMMatrix interface represents 4×4 matrices, suitable for 2D and 3D operations
235
- * including rotation and translation. It is a mutable version of the DOMMatrixReadOnly interface.
236
- *
237
- * @return DOMMatrix Class
238
- */
239
- domMatrixShape() {
240
- return new DOMMatrix()
241
- },
242
-
243
- /**
244
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/Path2D/addPath
245
- * @description method of the Canvas 2D API adds one Path2D object to another Path2D object.
246
- *
247
- * @param {*} callerPath path used to call addPatch
248
- * @param {...any} args config Path and domMatrix
249
- *
250
- * @return Path2D class
251
- */
252
- addPathShape(callerPath, ...args) {
253
- return callerPath.addPath(...args)
254
- },
255
-
256
- /**
257
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse
258
- * @description method of the Canvas 2D API adds an elliptical arc to the current sub-path.
259
- *
260
- * @param {number} x horizontal position
261
- * @param {number} y vertical position
262
- * @param {number} radiusX ellipse's major-axis radius. Must be non-negative
263
- * @param {number} radiusY ellipse's minor-axis radius. Must be non-negative
264
- * @param {number} rotation rotation of the ellipse, expressed in radians
265
- * @param {number} startAngle eccentric angle at which the ellipse starts, measured clockwise from
266
- * the positive x-axis and expressed in radians
267
- * @param {number} endAngle same ↑
268
- * @param {number} counterclockwise An optional boolean value which, if true, draws the ellipse counterclockwise
269
- * (anticlockwise). The default value is false (clockwise)
270
- *
271
- * @example - (100, 100, 50, 75, Math.PI / 4, 0, 2 * Math.PI)
272
- *
273
- * @return ShapeCreator class
274
- */
275
- ellipseShape(
276
- x,
277
- y,
278
- radiusX,
279
- radiusY,
280
- rotation,
281
- startAngle,
282
- endAngle,
283
- counterclockwise
284
- ) {
285
- this.context.ellipse(
286
- x,
287
- y,
288
- radiusX,
289
- radiusY,
290
- rotation,
291
- startAngle,
292
- endAngle,
293
- counterclockwise
294
- )
295
-
296
- return this
297
- },
298
- /**
299
- * @message You can use addColorStop here
300
- *
301
- * @doc https://www.w3schools.com/tags/canvas_addcolorstop.asp
302
- * @description Define a gradient from black to white and use it to fill a rectangle:
303
- *
304
- * @param {...number} rgba red,green,blue,alpha colors
305
- *
306
- * @example (r,g,b,a) -> (255,255,255,1)
307
- *
308
- * @return createLinearGradient
309
- */
310
- createLinearGradient(...rgba) {
311
- return this.context.createLinearGradient(...rgba)
312
- },
313
-
314
- /**
315
- * @message You can use addColorStop here
316
- *
317
- * @doc https://www.w3schools.com/tags/canvas_createradialgradient.asp
318
- * @description Define a radial gradient
319
- *
320
- * @param {...number} position
321
- *
322
- * @example (x0, y0, r0, x1, y1, r1a) -> (75, 50, 5, 90, 60, 100)
323
- *
324
- * @return createRadialGradient
325
- */
326
- createRadialGradient(...position) {
327
- return this.context.createRadialGradient(...position)
328
- },
329
-
330
- /**
331
- * @doc https://www.w3schools.com/tags/canvas_addcolorstop.asp
332
- * @description Define a gradient from black to white and use it to fill a rectangle:
333
- *
334
- * @param {createLinearGradient} gradient
335
- * @param {Array<{color: string<color>}} stops
336
- *
337
- * @example (gradient, {color:"red"})
338
- *
339
- * @return ShapeCreator Class
340
- */
341
- addColorStop(gradient, stops) {
342
- for (let i = 0; i < stops.length; i++) {
343
- const element = stops[i]
344
- gradient.addColorStop(i, element.color)
345
- }
346
-
347
- return this
348
- },
349
-
350
- /**
351
- * @doc https://www.w3schools.com/tags/canvas_createpattern.asp
352
- * @description create a patter by an image
353
- *
354
- * @param {Image} img new Image() class
355
- * @param {*} repeatType type of repetition
356
- *
357
- * @example (new Image(), repeat | repeat-x | repeat-y | no-repeat)
358
- *
359
- * @retunr ShapeCreator Class
360
- */
361
- createPattern(img, repeatType = 'repeat') {
362
- this.context.createPattern(img, repeatType)
363
-
364
- return this
365
- },
366
-
367
- /**
368
- * @doc https://www.w3schools.com/tags/canvas_linecap.asp
369
- * @description Draw a line with rounded end caps
370
- *
371
- * @param {string} style line style
372
- *
373
- * @example butt|round|square
374
- *
375
- * @return ShapeCreator Class
376
- */
377
- lineCapShape(style) {
378
- this.context.lineCap = style
379
- return this
380
- },
381
-
382
- /**
383
- * @doc https://www.w3schools.com/tags/canvas_linejoin.asp
384
- * @description Create a rounded corner where the two lines meet
385
- *
386
- * @param {string} style line style
387
- *
388
- * @example bevel|round|miter
389
- *
390
- * @return ShapeCreator Class
391
- */
392
- lineJoinShape(style) {
393
- this.context.lineJoin = style
394
- return this
395
- },
396
- /**
397
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineWidth
398
- * @description property of the Canvas 2D API sets the thickness of lines
399
- *
400
- * @param {number} width - define the thickness of lines
401
- *
402
- * @retun ShapeCreator class
403
- */
404
- lineWidthShape(width) {
405
- this.context.lineWidth = width
406
-
407
- return this
408
- },
409
-
410
- /**
411
- * @doc https://www.w3schools.com/tags/canvas_miterlimit.asp
412
- * @description Draw lines with the maximum miter length of 5
413
- *
414
- * @param {number} limit define the limit
415
- *
416
- * @retun ShapeCreator class
417
- */
418
- miterLimitShape(limit) {
419
- this.context.miterLimit = limit
420
-
421
- return this
422
- },
423
-
424
- /**
425
- * @doc https://www.w3schools.com/tags/canvas_shadowblur.asp
426
- * @description Draw a red rectangle with a black shadow, with blur level of 20
427
- *
428
- * @param {number} size define the blur size
429
- *
430
- * @retun ShapeCreator class
431
- */
432
- shadowBlurOfShape(size) {
433
- this.context.shadowBlur = size
434
-
435
- return this
436
- },
437
-
438
- /**
439
- * @doc https://www.w3schools.com/tags/canvas_shadowcolor.asp
440
- * @description Draw a red rectangle with a black shadow:
441
- *
442
- * @param {string} style shadow color
443
- *
444
- * @return ShapeCreator class
445
- */
446
- shadowColorOfShape(style) {
447
- this.context.shadowColor = style
448
-
449
- return this
450
- },
451
-
452
- shadowOffSetXY(x, y) {
453
- this.context.shadowOffsetX = x
454
- this.context.shadowOffsetX = y
455
-
456
- return this
457
- },
458
- /**
459
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle
460
- * @description property of the Canvas 2D API specifies the color, gradient, or pattern
461
- * to use for the strokes (outlines) around shapes. The default is #000 (black)
462
- *
463
- * @param {Color | CanvasGradient | CanvasPattern} style - property to specify color,
464
- * gradient or pattern
465
- *
466
- * @return ShapeCreator class
467
- */
468
- strokeStyle(style) {
469
- this.context.strokeStyle = style
470
- return this
471
- },
472
-
473
- /**
474
- * @doc https://www.w3schools.com/tags/canvas_scale.asp
475
- * @description change the size of shape
476
- *
477
- * @param {number} x horizontal scale
478
- * @param {number} y vertical scale
479
- *
480
- * @return ShapeCreator class
481
- */
482
- scaleShape(x, y) {
483
- this.context.scale(x, y)
484
- return this
485
- },
486
-
487
- /**
488
- * @doc https://www.w3schools.com/tags/canvas_rotate.asp
489
- * @description Rotate the rectangle
490
- *
491
- * @param {number} angle the angle to rotate
492
- *
493
- * @return ShapeCreator class
494
- */
495
- rotateShape(angle) {
496
- this.context.rotate(angle)
497
- return this
498
- },
499
-
500
- /**
501
- * @doc https://www.w3schools.com/tags/canvas_translate.asp
502
- * @description change the position of shape
503
- *
504
- * @param {number} x horizontal trasnform
505
- * @param {number} y vertical trasnform
506
- *
507
- * @return ShapeCreator class
508
- */
509
- translateShape(x, y) {
510
- this.context.translate(x, y)
511
- return this
512
- },
513
-
514
- /**
515
- * @doc https://www.w3schools.com/tags/canvas_transform.asp
516
- * @description method scales, rotates, moves, and skews the context
517
- *
518
- * @param {Array<number[posA, posB, posC, posD, posE, posF]>} pos
519
- *
520
- * @return ShapeCreator class
521
- */
522
- transformShape(...dots) {
523
- this.context.transform(...dots)
524
- return this
525
- },
526
-
527
- /**
528
- * @doc https://www.w3schools.com/tags/canvas_transform.asp
529
- * @description method scales, rotates, moves, and skews the context
530
- *
531
- * @param {Array<number[posA, posB, posC, posD, posE, posF]>} pos
532
- *
533
- * @return ShapeCreator Class
534
- */
535
- setTransformShape(x, y) {
536
- this.context.setTransform(x, y)
537
- return this
538
- },
539
-
540
- /**
541
- * @doc https://www.w3schools.com/tags/canvas_globalalpha.asp
542
- * @description change the global alpha
543
- *
544
- * @param {number} alpha change the global alpha
545
- *
546
- * @return ShapeCreator Class
547
- */
548
- globalAlpha(alpha) {
549
- this.context.globalAlpha(alpha)
550
- return this
551
- },
552
-
553
- /**
554
- * @doc https://www.w3schools.com/tags/canvas_globalcompositeoperation.asp
555
- * @description property sets or returns how a source are drawn over a destination.
556
- *
557
- * @param {string} composition
558
- *
559
- * @example source-over | source-atop | source-in | source-out | destination-over |
560
- * destination-atop | destination-in | destination-out | lighter | copy | xor
561
- *
562
- * @return globalCompositeOperation() method
563
- */
564
- globalCompositeOperation(composition) {
565
- return (this.context.globalCompositeOperation = composition)
566
- },
567
-
568
- /**
569
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clip
570
- * @description method of the Canvas 2D API turns the current or given path into the
571
- * current clipping region.
572
- *
573
- * @return clip
574
- */
575
- clipShape() {
576
- return this.context.clip()
577
- },
578
-
579
- /**
580
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowColor
581
- * @description property of the Canvas 2D API specifies the color of shadows.
582
- *
583
- * @param {<Color>} color
584
- *
585
- * @return ShapeCreator Class
586
- */
587
- shadowColor(color) {
588
- this.context.shadowColor = color
589
- return this
590
- },
591
- }
592
-
593
- export const imageCreatorMixin = {
594
- /**
595
- * @param { src: string, img: [sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight] } config
596
- * Configuration could be long or short, but right now we are showing as example the long
597
- * way. You could try adding just: dx, dy, dWidth, dHeight or dx, dy (for the img property)
598
- *
599
- * @example - {src: imgPath, img: [sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight]}
600
- *
601
- * @return ShapeCreator Class
602
- */
603
- createImage(config) {
604
- const img = new Image()
605
- img.src = config.src
606
- this.context.drawImage(img, ...config.img)
607
-
608
- return this
609
- },
610
-
611
- /**
612
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createImageData
613
- * @description method of the Canvas 2D API creates a new, blank ImageData object with the
614
- * specified dimensions. All of the pixels in the new object are transparent black
615
- *
616
- * @param {object<width | height | settings | ImageData>} imgConfig
617
- *
618
- * @example width | height | settings -> object{colorSpace} or existing ImageData
619
- *
620
- * @return createImageData method
621
- */
622
- createImageData(...imgConfig) {
623
- return this.context.createImageData(...imgConfig)
624
- },
625
-
626
- /**
627
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData
628
- * @description method getImageData() of the Canvas 2D API returns an ImageData object
629
- * representing the underlying pixel data for a specified portion of the canvas.
630
- *
631
- * @param {object<sx | xy | sw | sh | setting>} imgConfig
632
- *
633
- * @example sx | sy | sw | sh or settings -> object<colorSpace>
634
- *
635
- * @return ShapeCreator Class
636
- */
637
- getImgData(...imgConfig) {
638
- return this.context.getImageData(...imgConfig)
639
- },
640
-
641
- /**
642
- * @doc https://www.w3schools.com/tags/canvas_putimagedata.asp
643
- * @description method puts the image data (from a specified ImageData object) back onto the canvas
644
- *
645
- * @param {object<imgData> } imgData The ImageData object to put on the context.
646
- * @param {...} pos xPos and yPos
647
- *
648
- * @example {imgData, x, y, dirtyX, dirtyY, dirtyWidth, dirtyHeight}
649
- * @return ShapeCreator Class
650
- */
651
- putImageData(imgData, ...pos) {
652
- this.context.putImageData(imgData, ...pos)
653
-
654
- return this
655
- },
656
- }
package/src/core/fruta.js DELETED
@@ -1,22 +0,0 @@
1
- import Game from './game/game'
2
- import ShapeCreator from './create/_shapeCreator.js'
3
- import FrontCreator from './create/_fontCreator'
4
- import SaveRestore from './create/_saveOrRestore'
5
-
6
- /**
7
- * @param {object<config>} initConfig
8
- *
9
- * @example Game | ShapeCreator | FontCreator | SaveRestore
10
- * @return Methods
11
- */
12
- const Fruta = (initConfig) => {
13
- const { id } = initConfig.scene
14
- return {
15
- Game: new Game(initConfig),
16
- ShapeCreator: new ShapeCreator(id),
17
- FontCreator: new FrontCreator(id),
18
- SaveRestore: new SaveRestore(id),
19
- }
20
- }
21
-
22
- export default Fruta
@@ -1,30 +0,0 @@
1
- /**
2
- * @description
3
- * Game State Machine, where magic happens.
4
- *
5
- * @author
6
- * Jhornan Colina (karttofer)
7
- */
8
-
9
- import Scene from './scene'
10
- import Tick from './tick'
11
-
12
- class Game {
13
- constructor(config) {
14
- this.scene = config.scene
15
- this.tick = new Tick()
16
-
17
- this.afterMount()
18
- }
19
-
20
- afterMount() {
21
- /**
22
- * @TODO
23
- * Create a callback to allow user to add functionalities
24
- * after scene is created
25
- */
26
- new Scene(this.scene).createScene()
27
- }
28
- }
29
-
30
- export default Game