fruta 0.0.3 → 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 -0
  2. package/README.md +367 -26
  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
package/dist/main.js DELETED
@@ -1 +0,0 @@
1
- (()=>{"use strict";function t(e,r,o){return t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return r&&n(i,r.prototype),i},t.apply(null,arguments)}function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},n(t,e)}function e(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,n){if(t){if("string"==typeof t)return r(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?r(t,n):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var o={fillStyleShape:function(t){return this.context.fillStyle=t,this},drawRectShape:function(){var t,n,r,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0,0],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[0,0,0,0];return(t=this.context).clearRect.apply(t,e(o)),(n=this.context).fillRect.apply(n,e(i)),(r=this.context).strokeRect.apply(r,e(a)),this},roundRectShape:function(t,n,e,r,o){return this.context.roundRect(t,n,e,r,o),this},startShape:function(){return this.context.beginPath(),this},strokeShape:function(){var t;return(t=this.context).stroke.apply(t,arguments),this},moveTo:function(t,n){return this.context.moveTo(t,n),this},lineTo:function(t,n){return this.context.lineTo(t,n),this},fillShape:function(){var t;return(t=this.context).fill.apply(t,arguments),this},arcShape:function(t,n,e,r,o,i){return this.context.arc(t,n,e,r,o,i),this},quadraticCurveTo:function(t,n,e,r){return this.context.quadraticCurveTo(t,n,e,r),this},bezierCurveTo:function(t,n,e,r,o,i){return this.context.bezierCurveTo(t,n,e,r,o,i),this},arcTo:function(t,n,e,r,o){return this.context.arcTo(t,n,e,r,o),this},path2DShape:function(){for(var n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return t(Path2D,e)},domMatrixShape:function(){return new DOMMatrix},addPathShape:function(t){for(var n=arguments.length,e=new Array(n>1?n-1:0),r=1;r<n;r++)e[r-1]=arguments[r];return t.addPath.apply(t,e)},ellipseShape:function(t,n,e,r,o,i,a,c){return this.context.ellipse(t,n,e,r,o,i,a,c),this},createLinearGradient:function(){var t;return(t=this.context).createLinearGradient.apply(t,arguments)},createRadialGradient:function(){var t;return(t=this.context).createRadialGradient.apply(t,arguments)},addColorStop:function(t,n){for(var e=0;e<n.length;e++){var r=n[e];t.addColorStop(e,r.color)}return this},createPattern:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return this.context.createPattern(t,n),this},lineCapShape:function(t){return this.context.lineCap=t,this},lineJoinShape:function(t){return this.context.lineJoin=t,this},lineWidthShape:function(t){return this.context.lineWidth=t,this},miterLimitShape:function(t){return this.context.miterLimit=t,this},shadowBlurOfShape:function(t){return this.context.shadowBlur=t,this},shadowColorOfShape:function(t){return this.context.shadowColor=t,this},shadowOffSetXY:function(t,n){return this.context.shadowOffsetX=t,this.context.shadowOffsetX=n,this},strokeStyle:function(t){return this.context.strokeStyle=t,this},scaleShape:function(t,n){return this.context.scale(t,n),this},rotateShape:function(t){return this.context.rotate(t),this},translateShape:function(t,n){return this.context.translate(t,n),this},transformShape:function(){var t;return(t=this.context).transform.apply(t,arguments),this},setTransformShape:function(t,n){return this.context.setTransform(t,n),this},globalAlpha:function(t){return this.context.globalAlpha(t),this},globalCompositeOperation:function(t){return this.context.globalCompositeOperation=t},clipShape:function(){return this.context.clip()},shadowColor:function(t){return this.context.shadowColor=t,this}},i={createImage:function(t){var n,r=new Image;return r.src=t.src,(n=this.context).drawImage.apply(n,[r].concat(e(t.img))),this},createImageData:function(){var t;return(t=this.context).createImageData.apply(t,arguments)},getImgData:function(){var t;return(t=this.context).getImageData.apply(t,arguments)},putImageData:function(t){for(var n,e=arguments.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];return(n=this.context).putImageData.apply(n,[t].concat(r)),this}};function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function c(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,o=function(t,n){if("object"!==a(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key),"symbol"===a(o)?o:String(o)),r)}var o}function u(t,n,e){return n&&c(t.prototype,n),e&&c(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}var f=u((function t(n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.canvas=document.getElementById(n),this.context=this.canvas.getContext("2d")}));function s(t,n,e){return s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,n,e){var r=[null];r.push.apply(r,n);var o=new(Function.bind.apply(t,r));return e&&l(o,e.prototype),o},s.apply(null,arguments)}function l(t,n){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},l(t,n)}Object.assign(f.prototype,o,i);var h={loadFont:function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];return s(FontFace,n),this},fontRenderingType:function(t){return this.context.textRendering=t,this},fontFill:function(t,n,e){return this.context.fillText(t,n,e),this},fontStrokeText:function(){var t;return(t=this.context).strokeText.apply(t,arguments),this},fontStyle:function(t){return this.context.font=t,this},fontAlign:function(t){return this.context.textAlign=t,this},fontDirection:function(t){return this.context.direction=t,this},fontBaseline:function(t){return this.context.textBaseline=t,this},fontVariantCaps:function(t){return this.context.fontVariantCaps=t,this},fontKerning:function(t){return this.context.fontKerning=t,this},fontWordSpacing:function(t){return this.context.wordSpacing=t,this},fontS:function(t){return this.context.fontStretch=t,this},fontMeasure:function(t){return this.context.measureText(t)}};function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function y(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,o=function(t,n){if("object"!==p(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key),"symbol"===p(o)?o:String(o)),r)}var o}function d(t,n,e){return n&&y(t.prototype,n),e&&y(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}var m=d((function t(n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.canvas=document.getElementById(n),this.context=this.canvas.getContext("2d")}));Object.assign(m.prototype,h)})();
package/index.html DELETED
@@ -1,9 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <title>Text - Enviroment</title>
6
- </head>
7
- <body>
8
- </body>
9
- </html>
package/settings.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "editor.codeActionsOnSave": {
3
- "source.fixAll.eslint": true
4
- },
5
- "eslint.validate": ["javascript"]
6
- }
@@ -1,11 +0,0 @@
1
- import { fontCreatorMixin } from './fontCreatorMixin'
2
-
3
- class FontCreator {
4
- constructor(id) {
5
- this.canvas = document.getElementById(id)
6
- this.context = this.canvas.getContext('2d')
7
- }
8
- }
9
-
10
- Object.assign(FontCreator.prototype, fontCreatorMixin)
11
- export default FontCreator
@@ -1,22 +0,0 @@
1
- /**
2
- * @description
3
- * This file will be in chage to save and restore state
4
- * useful when you want to make checkpoints
5
- */
6
-
7
- class SaveRestore {
8
- constructor(id) {
9
- this.canvas = document.getElementById(id)
10
- this.context = this.canvas.getContext('2d')
11
- }
12
-
13
- save() {
14
- this.context.save()
15
- }
16
-
17
- restore() {
18
- this.context.restore()
19
- }
20
- }
21
-
22
- export default SaveRestore
@@ -1,20 +0,0 @@
1
- /**
2
- * @alert
3
- * We use mixins here because JavaScript cannot perform multiple inheritance.
4
- *
5
- * @description
6
- * This class will be responsible for loading everything related to creating shapes
7
- * (including images) and also applying their styles, properties, etc.
8
- */
9
-
10
- import { shapesCreatorMixin, imageCreatorMixin } from './shapeCreatorMixin'
11
-
12
- class ShapeCreator {
13
- constructor(id) {
14
- this.canvas = document.getElementById(id)
15
- this.context = this.canvas.getContext('2d')
16
- }
17
- }
18
- Object.assign(ShapeCreator.prototype, shapesCreatorMixin, imageCreatorMixin)
19
-
20
- export default ShapeCreator
@@ -1,167 +0,0 @@
1
- /**
2
- * @alert
3
- * Render text outside of OnRender method since we are facing a issue with it.
4
- * It isn't a big issue right now but who knows.
5
- *
6
- * @description
7
- * This fill will be use to get all the necessary methods for nesting Font
8
- * configuration.
9
- *
10
- */
11
-
12
- export const fontCreatorMixin = {
13
- /**
14
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/FontFace
15
- * @description You can load, give a name and styles to the fonts using this method
16
- * it is like the main for fonts.
17
- *
18
- * @param {...any} config - see the doc for the configs
19
- *
20
- * @return parent class
21
- */
22
- loadFont(...config) {
23
- new FontFace(...config)
24
- return this
25
- },
26
- /**
27
- * @message - very important method, you should read the doc below
28
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textRendering
29
- * @param {string} config
30
- * @example - auto | optimizeSpeed | optimizeLegibility | geometricPrecision
31
- *
32
- * @return FontCreator class
33
- */
34
- fontRenderingType(config) {
35
- this.context.textRendering = config
36
- return this
37
- },
38
- /**
39
- * @param {*} message - current text that you want to show
40
- * @param {*} xPos - horizontal position of the text
41
- * @param {*} yPos - vertical position of the text
42
- *
43
- * @example - ("Hello world", 10, 10)
44
- *
45
- * @return FontCreator class
46
- */
47
- fontFill(message, xPos, yPos) {
48
- this.context.fillText(message, xPos, yPos)
49
- return this
50
- },
51
- /**
52
- * @message - you could change the maxWith, we put it in 20 just like a
53
- * default value
54
- *
55
- * @param {string} text - current text that you want to show (only stroke)
56
- * @param {number} xPos - horizontal position of the text
57
- * @param {number} yPos - vertical position of the text
58
- * @param {number} maxWidth - maxWith stroke
59
- *
60
- * @example - ("Hello",10,10,20)
61
- *
62
- * @return FontCreator class
63
- */
64
- fontStrokeText(...config) {
65
- this.context.strokeText(...config)
66
- return this
67
- },
68
- /**
69
- * @param {string} style css value for fonts (you should know a little bit of css)
70
- * @example - bold 48px serif
71
- * @return FontCreator class
72
- */
73
- fontStyle(style) {
74
- this.context.font = style
75
- return this
76
- },
77
- /**
78
- * @param {string} style
79
- * @example - left | right | center | start | end
80
-
81
- * @return FontCreator class
82
- */
83
- fontAlign(style) {
84
- this.context.textAlign = style
85
- return this
86
- },
87
- /**
88
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/direction
89
- * @description with this method you will be able to change the direction of the
90
- * font - Ex: !Hi -> Hi!
91
- * @param {string} style
92
- * @exameple - ltr | rtl | inherit
93
- *
94
- * @return FontCreator class
95
- */
96
- fontDirection(style) {
97
- this.context.direction = style
98
- return this
99
- },
100
- /**
101
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textBaseline
102
- * @description property of the Canvas 2D API specifies the current
103
- * text baseline used when drawing text
104
- * @param {string} style - top | hanging | middle | alphabetic | ideographic | bottom
105
- *
106
- * @return FontCreator class
107
- */
108
- fontBaseline(style) {
109
- this.context.textBaseline = style
110
- return this
111
- },
112
- /**
113
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fontVariantCaps
114
- * @param {string} style - normal | small-caps | all-small-caps | petite-caps | all-petite-caps
115
- * | unicase | titling-caps
116
- *
117
- * @return FontCreator class
118
- */
119
- fontVariantCaps(style) {
120
- this.context.fontVariantCaps = style
121
- return this
122
- },
123
- /**
124
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fontKerning
125
- * @param {string} style kerning property to adjust the space between characters
126
- * @example - auto | normal | none
127
- * @return FontCreator class
128
- */
129
- fontKerning(style) {
130
- this.context.fontKerning = style
131
- return this
132
- },
133
- /**
134
- * @alert the style prop should be a number by default but it is a string but number
135
- * @param {string (number)} style - spacing of between the words
136
- * @return FontCreator class
137
- */
138
- fontWordSpacing(style) {
139
- this.context.wordSpacing = style
140
- return this
141
- },
142
- /**
143
- * @warning - could no be tested
144
- * @doc https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fontStretch
145
- * @param {string} style - fontStretch property
146
- * @example - ultra-condensed | extra-condensed | condensed | semi-condensed | normal |
147
- * semi-expanded | expanded | extra-expanded | ultra-expanded
148
- *
149
- * @return FontCreator class
150
- */
151
- fontS(style) {
152
- this.context.fontStretch = style
153
- return this
154
- },
155
-
156
- /**
157
- * @doc https://www.w3schools.com/tags/canvas_measuretext.asp
158
- * @description method returns an object that contains the width of the specified text, in pixels
159
- *
160
- * @param {string} txt Text to
161
- *
162
- * @return void
163
- */
164
- fontMeasure(txt) {
165
- return this.context.measureText(txt)
166
- },
167
- }