excalibur 0.25.1 → 0.25.2

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 (254) hide show
  1. package/.nvmrc +1 -1
  2. package/CHANGELOG.md +119 -27
  3. package/README.md +0 -1
  4. package/build/dist/Actions/ActionsComponent.d.ts +1 -1
  5. package/build/dist/Actor.d.ts +46 -45
  6. package/build/dist/Camera.d.ts +10 -2
  7. package/build/dist/Class.d.ts +4 -5
  8. package/build/dist/Collision/BodyComponent.d.ts +6 -2
  9. package/build/dist/Collision/BoundingBox.d.ts +6 -0
  10. package/build/dist/Collision/ColliderComponent.d.ts +1 -4
  11. package/build/dist/Collision/Colliders/CircleCollider.d.ts +18 -2
  12. package/build/dist/Collision/Colliders/EdgeCollider.d.ts +1 -1
  13. package/build/dist/Collision/Colliders/SeparatingAxis.d.ts +2 -2
  14. package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.d.ts +4 -4
  15. package/build/dist/Collision/Detection/Pair.d.ts +5 -1
  16. package/build/dist/Collision/Group/CollisionGroup.d.ts +0 -1
  17. package/build/dist/Collision/MotionSystem.d.ts +4 -0
  18. package/build/dist/Collision/Solver/ContactConstraintPoint.d.ts +1 -1
  19. package/build/dist/Collision/Solver/Solver.d.ts +1 -1
  20. package/build/dist/Debug/Debug.d.ts +18 -1
  21. package/build/dist/Debug/DebugFlags.d.ts +16 -3
  22. package/build/dist/Engine.d.ts +66 -8
  23. package/build/dist/EntityComponentSystem/Component.d.ts +3 -3
  24. package/build/dist/EntityComponentSystem/Components/MotionComponent.d.ts +2 -2
  25. package/build/dist/EntityComponentSystem/Entity.d.ts +4 -4
  26. package/build/dist/EntityComponentSystem/System.d.ts +1 -1
  27. package/build/dist/EntityComponentSystem/SystemManager.d.ts +6 -1
  28. package/build/dist/EventDispatcher.d.ts +0 -5
  29. package/build/dist/Events/ExEvent.d.ts +6 -0
  30. package/build/dist/Events/PointerEvents.d.ts +37 -0
  31. package/build/dist/Graphics/Animation.d.ts +3 -2
  32. package/build/dist/Graphics/Circle.d.ts +2 -0
  33. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.d.ts +37 -5
  34. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.d.ts +12 -2
  35. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +29 -13
  36. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.d.ts +22 -0
  37. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.frag.glsl +53 -0
  38. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.vert.glsl +37 -0
  39. package/build/dist/Graphics/Context/image-renderer/image-renderer.d.ts +27 -0
  40. package/build/dist/Graphics/Context/image-renderer/image-renderer.frag.glsl +28 -0
  41. package/build/dist/Graphics/Context/{shaders/image-vertex.glsl → image-renderer/image-renderer.vert.glsl} +2 -7
  42. package/build/dist/Graphics/Context/{shaders → line-renderer}/line-fragment.glsl +0 -0
  43. package/build/dist/Graphics/Context/line-renderer/line-renderer.d.ts +21 -0
  44. package/build/dist/Graphics/Context/{shaders → line-renderer}/line-vertex.glsl +2 -2
  45. package/build/dist/Graphics/Context/{shaders → point-renderer}/point-fragment.glsl +6 -2
  46. package/build/dist/Graphics/Context/point-renderer/point-renderer.d.ts +21 -0
  47. package/build/dist/Graphics/Context/{shaders → point-renderer}/point-vertex.glsl +2 -2
  48. package/build/dist/Graphics/Context/quad-index-buffer.d.ts +36 -0
  49. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.d.ts +23 -0
  50. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.frag.glsl +85 -0
  51. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.vert.glsl +42 -0
  52. package/build/dist/Graphics/Context/render-source.d.ts +7 -0
  53. package/build/dist/Graphics/Context/render-target.d.ts +26 -0
  54. package/build/dist/Graphics/Context/renderer.d.ts +20 -51
  55. package/build/dist/Graphics/Context/screen-pass-painter/screen-fragment.glsl +11 -0
  56. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.d.ts +13 -0
  57. package/build/dist/Graphics/Context/screen-pass-painter/screen-vertex.glsl +11 -0
  58. package/build/dist/Graphics/Context/shader.d.ts +116 -42
  59. package/build/dist/Graphics/Context/shaders/crt-effect.glsl +64 -0
  60. package/build/dist/Graphics/Context/shaders/grayscale-fragment.glsl +13 -0
  61. package/build/dist/Graphics/Context/shaders/invert-fragment.glsl +12 -0
  62. package/build/dist/Graphics/Context/texture-loader.d.ts +8 -2
  63. package/build/dist/Graphics/Context/vertex-buffer.d.ts +49 -0
  64. package/build/dist/Graphics/Context/vertex-layout.d.ts +52 -0
  65. package/build/dist/Graphics/Context/webgl-adapter.d.ts +9 -0
  66. package/build/dist/Graphics/Context/webgl-util.d.ts +22 -0
  67. package/build/dist/Graphics/DebugGraphicsComponent.d.ts +13 -0
  68. package/build/dist/Graphics/Filtering.d.ts +15 -0
  69. package/build/dist/Graphics/Font.d.ts +61 -23
  70. package/build/dist/Graphics/FontCommon.d.ts +43 -2
  71. package/build/dist/Graphics/Graphic.d.ts +23 -9
  72. package/build/dist/Graphics/GraphicsSystem.d.ts +0 -1
  73. package/build/dist/Graphics/ImageSource.d.ts +8 -3
  74. package/build/dist/Graphics/Polygon.d.ts +2 -0
  75. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.d.ts +5 -0
  76. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.d.ts +17 -0
  77. package/build/dist/Graphics/PostProcessor/PostProcessor.d.ts +7 -0
  78. package/build/dist/Graphics/PostProcessor/ScreenShader.d.ts +16 -0
  79. package/build/dist/Graphics/PostProcessor/color-blind-fragment.glsl +62 -0
  80. package/build/dist/Graphics/Raster.d.ts +32 -5
  81. package/build/dist/Graphics/Sprite.d.ts +5 -0
  82. package/build/dist/Graphics/SpriteFont.d.ts +6 -7
  83. package/build/dist/Graphics/SpriteSheet.d.ts +1 -2
  84. package/build/dist/Graphics/Text.d.ts +18 -2
  85. package/build/dist/Graphics/index.d.ts +14 -0
  86. package/build/dist/Id.d.ts +1 -1
  87. package/build/dist/Input/EngineInput.d.ts +2 -2
  88. package/build/dist/Input/Index.d.ts +10 -3
  89. package/build/dist/Input/NativePointerButton.d.ts +10 -0
  90. package/build/dist/Input/PointerAbstraction.d.ts +33 -0
  91. package/build/dist/Input/PointerButton.d.ts +10 -0
  92. package/build/dist/Input/PointerComponent.d.ts +24 -0
  93. package/build/dist/Input/PointerEvent.d.ts +18 -0
  94. package/build/dist/Input/PointerEventReceiver.d.ts +114 -0
  95. package/build/dist/Input/PointerScope.d.ts +14 -0
  96. package/build/dist/Input/PointerSystem.d.ts +43 -0
  97. package/build/dist/Input/PointerType.d.ts +9 -0
  98. package/build/dist/Input/WheelDeltaMode.d.ts +5 -0
  99. package/build/dist/Input/WheelEvent.d.ts +18 -0
  100. package/build/dist/Interfaces/PointerEventHandlers.d.ts +17 -16
  101. package/build/dist/Label.d.ts +9 -2
  102. package/build/dist/Loader.d.ts +5 -2
  103. package/build/dist/Math/Index.d.ts +1 -0
  104. package/build/dist/Math/matrix.d.ts +19 -1
  105. package/build/dist/Math/util.d.ts +45 -0
  106. package/build/dist/Particles.d.ts +12 -0
  107. package/build/dist/Resources/Gif.d.ts +1 -1
  108. package/build/dist/Scene.d.ts +10 -1
  109. package/build/dist/Screen.d.ts +4 -3
  110. package/build/dist/TileMap.d.ts +3 -2
  111. package/build/dist/Traits/Index.d.ts +0 -1
  112. package/build/dist/Trigger.d.ts +4 -0
  113. package/build/dist/Util/Clock.d.ts +118 -0
  114. package/build/dist/Util/Fps.d.ts +40 -0
  115. package/build/dist/Util/Observable.d.ts +1 -1
  116. package/build/dist/Util/Pool.d.ts +2 -10
  117. package/build/dist/Util/Util.d.ts +23 -66
  118. package/build/dist/excalibur.js +9124 -7580
  119. package/build/dist/excalibur.js.map +1 -1
  120. package/build/dist/excalibur.min.js +1 -1
  121. package/build/dist/excalibur.min.js.LICENSE.txt +2 -2
  122. package/build/dist/excalibur.min.js.map +1 -1
  123. package/build/dist/index.d.ts +5 -2
  124. package/build/esm/Actions/ActionsComponent.d.ts +1 -1
  125. package/build/esm/Actor.d.ts +46 -45
  126. package/build/esm/Camera.d.ts +10 -2
  127. package/build/esm/Class.d.ts +4 -5
  128. package/build/esm/Collision/BodyComponent.d.ts +6 -2
  129. package/build/esm/Collision/BoundingBox.d.ts +6 -0
  130. package/build/esm/Collision/ColliderComponent.d.ts +1 -4
  131. package/build/esm/Collision/Colliders/CircleCollider.d.ts +18 -2
  132. package/build/esm/Collision/Colliders/EdgeCollider.d.ts +1 -1
  133. package/build/esm/Collision/Colliders/SeparatingAxis.d.ts +2 -2
  134. package/build/esm/Collision/Detection/DynamicTreeCollisionProcessor.d.ts +4 -4
  135. package/build/esm/Collision/Detection/Pair.d.ts +5 -1
  136. package/build/esm/Collision/Group/CollisionGroup.d.ts +0 -1
  137. package/build/esm/Collision/MotionSystem.d.ts +4 -0
  138. package/build/esm/Collision/Solver/ContactConstraintPoint.d.ts +1 -1
  139. package/build/esm/Collision/Solver/Solver.d.ts +1 -1
  140. package/build/esm/Debug/Debug.d.ts +18 -1
  141. package/build/esm/Debug/DebugFlags.d.ts +16 -3
  142. package/build/esm/Engine.d.ts +66 -8
  143. package/build/esm/EntityComponentSystem/Component.d.ts +3 -3
  144. package/build/esm/EntityComponentSystem/Components/MotionComponent.d.ts +2 -2
  145. package/build/esm/EntityComponentSystem/Entity.d.ts +4 -4
  146. package/build/esm/EntityComponentSystem/System.d.ts +1 -1
  147. package/build/esm/EntityComponentSystem/SystemManager.d.ts +6 -1
  148. package/build/esm/EventDispatcher.d.ts +0 -5
  149. package/build/esm/Events/ExEvent.d.ts +6 -0
  150. package/build/esm/Events/PointerEvents.d.ts +37 -0
  151. package/build/esm/Graphics/Animation.d.ts +3 -2
  152. package/build/esm/Graphics/Circle.d.ts +2 -0
  153. package/build/esm/Graphics/Context/ExcaliburGraphicsContext.d.ts +37 -5
  154. package/build/esm/Graphics/Context/ExcaliburGraphicsContext2DCanvas.d.ts +12 -2
  155. package/build/esm/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +29 -13
  156. package/build/esm/Graphics/Context/circle-renderer/circle-renderer.d.ts +22 -0
  157. package/build/esm/Graphics/Context/image-renderer/image-renderer.d.ts +27 -0
  158. package/build/esm/Graphics/Context/line-renderer/line-renderer.d.ts +21 -0
  159. package/build/esm/Graphics/Context/point-renderer/point-renderer.d.ts +21 -0
  160. package/build/esm/Graphics/Context/quad-index-buffer.d.ts +36 -0
  161. package/build/esm/Graphics/Context/rectangle-renderer/rectangle-renderer.d.ts +23 -0
  162. package/build/esm/Graphics/Context/render-source.d.ts +7 -0
  163. package/build/esm/Graphics/Context/render-target.d.ts +26 -0
  164. package/build/esm/Graphics/Context/renderer.d.ts +20 -51
  165. package/build/esm/Graphics/Context/screen-pass-painter/screen-pass-painter.d.ts +13 -0
  166. package/build/esm/Graphics/Context/shader.d.ts +116 -42
  167. package/build/esm/Graphics/Context/texture-loader.d.ts +8 -2
  168. package/build/esm/Graphics/Context/vertex-buffer.d.ts +49 -0
  169. package/build/esm/Graphics/Context/vertex-layout.d.ts +52 -0
  170. package/build/esm/Graphics/Context/webgl-adapter.d.ts +9 -0
  171. package/build/esm/Graphics/Context/webgl-util.d.ts +22 -0
  172. package/build/esm/Graphics/DebugGraphicsComponent.d.ts +13 -0
  173. package/build/esm/Graphics/Filtering.d.ts +15 -0
  174. package/build/esm/Graphics/Font.d.ts +61 -23
  175. package/build/esm/Graphics/FontCommon.d.ts +43 -2
  176. package/build/esm/Graphics/Graphic.d.ts +23 -9
  177. package/build/esm/Graphics/GraphicsSystem.d.ts +0 -1
  178. package/build/esm/Graphics/ImageSource.d.ts +8 -3
  179. package/build/esm/Graphics/Polygon.d.ts +2 -0
  180. package/build/esm/Graphics/PostProcessor/ColorBlindnessMode.d.ts +5 -0
  181. package/build/esm/Graphics/PostProcessor/ColorBlindnessPostProcessor.d.ts +17 -0
  182. package/build/esm/Graphics/PostProcessor/PostProcessor.d.ts +7 -0
  183. package/build/esm/Graphics/PostProcessor/ScreenShader.d.ts +16 -0
  184. package/build/esm/Graphics/Raster.d.ts +32 -5
  185. package/build/esm/Graphics/Sprite.d.ts +5 -0
  186. package/build/esm/Graphics/SpriteFont.d.ts +6 -7
  187. package/build/esm/Graphics/SpriteSheet.d.ts +1 -2
  188. package/build/esm/Graphics/Text.d.ts +18 -2
  189. package/build/esm/Graphics/index.d.ts +14 -0
  190. package/build/esm/Id.d.ts +1 -1
  191. package/build/esm/Input/EngineInput.d.ts +2 -2
  192. package/build/esm/Input/Index.d.ts +10 -3
  193. package/build/esm/Input/NativePointerButton.d.ts +10 -0
  194. package/build/esm/Input/PointerAbstraction.d.ts +33 -0
  195. package/build/esm/Input/PointerButton.d.ts +10 -0
  196. package/build/esm/Input/PointerComponent.d.ts +24 -0
  197. package/build/esm/Input/PointerEvent.d.ts +18 -0
  198. package/build/esm/Input/PointerEventReceiver.d.ts +114 -0
  199. package/build/esm/Input/PointerScope.d.ts +14 -0
  200. package/build/esm/Input/PointerSystem.d.ts +43 -0
  201. package/build/esm/Input/PointerType.d.ts +9 -0
  202. package/build/esm/Input/WheelDeltaMode.d.ts +5 -0
  203. package/build/esm/Input/WheelEvent.d.ts +18 -0
  204. package/build/esm/Interfaces/PointerEventHandlers.d.ts +17 -16
  205. package/build/esm/Label.d.ts +9 -2
  206. package/build/esm/Loader.d.ts +5 -2
  207. package/build/esm/Math/Index.d.ts +1 -0
  208. package/build/esm/Math/matrix.d.ts +19 -1
  209. package/build/esm/Math/util.d.ts +45 -0
  210. package/build/esm/Particles.d.ts +12 -0
  211. package/build/esm/Resources/Gif.d.ts +1 -1
  212. package/build/esm/Scene.d.ts +10 -1
  213. package/build/esm/Screen.d.ts +4 -3
  214. package/build/esm/TileMap.d.ts +3 -2
  215. package/build/esm/Traits/Index.d.ts +0 -1
  216. package/build/esm/Trigger.d.ts +4 -0
  217. package/build/esm/Util/Clock.d.ts +118 -0
  218. package/build/esm/Util/Fps.d.ts +40 -0
  219. package/build/esm/Util/Observable.d.ts +1 -1
  220. package/build/esm/Util/Pool.d.ts +2 -10
  221. package/build/esm/Util/Util.d.ts +23 -66
  222. package/build/esm/excalibur.js +9001 -7438
  223. package/build/esm/excalibur.js.map +1 -1
  224. package/build/esm/excalibur.min.js +1 -1
  225. package/build/esm/excalibur.min.js.LICENSE.txt +2 -2
  226. package/build/esm/excalibur.min.js.map +1 -1
  227. package/build/esm/index.d.ts +5 -2
  228. package/package.json +31 -27
  229. package/build/dist/Graphics/Context/batch.d.ts +0 -11
  230. package/build/dist/Graphics/Context/draw-image-command.d.ts +0 -47
  231. package/build/dist/Graphics/Context/image-renderer.d.ts +0 -39
  232. package/build/dist/Graphics/Context/line-renderer.d.ts +0 -22
  233. package/build/dist/Graphics/Context/point-renderer.d.ts +0 -22
  234. package/build/dist/Graphics/Context/shaders/image-fragment.glsl +0 -48
  235. package/build/dist/Input/Pointer.d.ts +0 -134
  236. package/build/dist/Input/PointerEvents.d.ts +0 -170
  237. package/build/dist/Input/Pointers.d.ts +0 -78
  238. package/build/dist/PostProcessing/ColorBlindCorrector.d.ts +0 -28
  239. package/build/dist/PostProcessing/Index.d.ts +0 -2
  240. package/build/dist/PostProcessing/PostProcessor.d.ts +0 -6
  241. package/build/dist/Traits/CapturePointer.d.ts +0 -10
  242. package/build/esm/Graphics/Context/batch.d.ts +0 -11
  243. package/build/esm/Graphics/Context/draw-image-command.d.ts +0 -47
  244. package/build/esm/Graphics/Context/image-renderer.d.ts +0 -39
  245. package/build/esm/Graphics/Context/line-renderer.d.ts +0 -22
  246. package/build/esm/Graphics/Context/point-renderer.d.ts +0 -22
  247. package/build/esm/Input/Pointer.d.ts +0 -134
  248. package/build/esm/Input/PointerEvents.d.ts +0 -170
  249. package/build/esm/Input/Pointers.d.ts +0 -78
  250. package/build/esm/PostProcessing/ColorBlindCorrector.d.ts +0 -28
  251. package/build/esm/PostProcessing/Index.d.ts +0 -2
  252. package/build/esm/PostProcessing/PostProcessor.d.ts +0 -6
  253. package/build/esm/Traits/CapturePointer.d.ts +0 -10
  254. package/wallaby.js +0 -77
@@ -0,0 +1,13 @@
1
+ import { ExcaliburGraphicsContext } from '.';
2
+ import { Component } from '../EntityComponentSystem/Component';
3
+ /**
4
+ * Provide arbitrary drawing for the purposes of debugging your game
5
+ *
6
+ * Will only show when the Engine is set to debug mode [[Engine.showDebug]] or [[Engine.toggleDebug]]
7
+ *
8
+ */
9
+ export declare class DebugGraphicsComponent extends Component<'ex.debuggraphics'> {
10
+ draw: (ctx: ExcaliburGraphicsContext) => void;
11
+ readonly type = "ex.debuggraphics";
12
+ constructor(draw: (ctx: ExcaliburGraphicsContext) => void);
13
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Describes the different image filtering modes
3
+ */
4
+ export declare enum ImageFiltering {
5
+ /**
6
+ * Pixel is useful when you do not want smoothing aka antialiasing applied to your graphics.
7
+ *
8
+ * Useful for Pixel art aesthetics.
9
+ */
10
+ Pixel = "Pixel",
11
+ /**
12
+ * Blended is useful when you have high resolution artwork and would like it blended and smoothed
13
+ */
14
+ Blended = "Blended"
15
+ }
@@ -3,19 +3,40 @@ import { BoundingBox } from '../Collision/Index';
3
3
  import { Color } from '../Color';
4
4
  import { ExcaliburGraphicsContext } from './Context/ExcaliburGraphicsContext';
5
5
  import { BaseAlign, Direction, FontOptions, FontStyle, FontUnit, TextAlign, FontRenderer } from './FontCommon';
6
- import { Raster, RasterOptions } from './Raster';
7
- export declare class Font extends Raster implements FontRenderer {
8
- constructor(options?: FontOptions & RasterOptions);
6
+ import { Graphic, GraphicOptions } from './Graphic';
7
+ import { RasterOptions } from './Raster';
8
+ import { ImageFiltering } from './Filtering';
9
+ /**
10
+ * Represents a system or web font in Excalibur
11
+ *
12
+ * If no options specified, the system sans-serif 10 pixel is used
13
+ *
14
+ * If loading a custom web font be sure to have the font loaded before you use it https://erikonarheim.com/posts/dont-test-fonts/
15
+ */
16
+ export declare class Font extends Graphic implements FontRenderer {
17
+ /**
18
+ * Set the font filtering mode, by default set to [[ImageFiltering.Blended]] regardless of the engine default smoothing
19
+ *
20
+ * If you have a pixel style font that may be a reason to switch this to [[ImageFiltering.Pixel]]
21
+ */
22
+ filtering: ImageFiltering;
23
+ constructor(options?: FontOptions & GraphicOptions & RasterOptions);
9
24
  clone(): Font;
10
25
  /**
11
- * Font quality determines the size of the underlying rastered text, higher quality means less jagged edges.
26
+ * Font quality determines the size of the underlying raster text, higher quality means less jagged edges.
12
27
  * If quality is set to 1, then just enough raster bitmap is generated to render the text.
13
28
  *
14
29
  * You can think of quality as how zoomed in to the text you can get before seeing jagged edges.
15
30
  *
16
- * (Default 4)
31
+ * (Default 2)
17
32
  */
18
33
  quality: number;
34
+ padding: number;
35
+ smoothing: boolean;
36
+ lineWidth: number;
37
+ lineDash: number[];
38
+ color: Color;
39
+ strokeColor: Color;
19
40
  family: string;
20
41
  style: FontStyle;
21
42
  bold: boolean;
@@ -30,28 +51,45 @@ export declare class Font extends Raster implements FontRenderer {
30
51
  color?: Color;
31
52
  };
32
53
  get fontString(): string;
33
- private _text;
34
- private _lines;
35
54
  private _textBounds;
36
- private _textWidth;
37
- private _textHeight;
38
- get width(): number;
39
- set width(value: number);
40
- get height(): number;
41
- set height(value: number);
42
- private get _rasterWidth();
43
- private get _rasterHeight();
44
- private get _halfRasterWidth();
45
- private get _halfRasterHeight();
46
55
  get localBounds(): BoundingBox;
47
- protected _drawImage(ex: ExcaliburGraphicsContext, x: number, y: number): void;
56
+ protected _drawImage(_ex: ExcaliburGraphicsContext, _x: number, _y: number): void;
48
57
  protected _rotate(ex: ExcaliburGraphicsContext): void;
49
58
  protected _flip(ex: ExcaliburGraphicsContext): void;
50
- updateText(text: string): void;
51
- private _updateDimensions;
52
- protected _preDraw(ex: ExcaliburGraphicsContext, x: number, y: number): void;
59
+ /**
60
+ * Returns a BoundingBox that is the total size of the text including multiple lines
61
+ *
62
+ * Does not include any padding or adjustment
63
+ * @param text
64
+ * @returns BoundingBox
65
+ */
66
+ measureText(text: string): BoundingBox;
67
+ private _setDimension;
53
68
  protected _postDraw(ex: ExcaliburGraphicsContext): void;
69
+ /**
70
+ * We need to identify bitmaps with more than just the text content
71
+ *
72
+ * Any properties that can change the rendering of the text
73
+ */
74
+ private _getRasterPropertiesHash;
75
+ protected _applyRasterProperties(ctx: CanvasRenderingContext2D, color: Color): void;
54
76
  private _applyFont;
55
- execute(ctx: CanvasRenderingContext2D): void;
56
- render(ex: ExcaliburGraphicsContext, text: string, x: number, y: number): void;
77
+ private _drawText;
78
+ private _textToBitmap;
79
+ private _bitmapUsage;
80
+ private _getTextBitmap;
81
+ render(ex: ExcaliburGraphicsContext, text: string, colorOverride: Color, x: number, y: number): void;
82
+ /**
83
+ * Get the internal cache size of the font
84
+ * This is useful when debugging memory usage, these numbers indicate the number of cached in memory text bitmaps
85
+ */
86
+ get cacheSize(): number;
87
+ /**
88
+ * Force clear all cached text bitmaps
89
+ */
90
+ clearCache(): void;
91
+ /**
92
+ * Remove any expired cached text bitmaps
93
+ */
94
+ checkAndClearCache(): void;
57
95
  }
@@ -1,3 +1,4 @@
1
+ import { BoundingBox } from '../Collision/BoundingBox';
1
2
  import { Color } from '../Color';
2
3
  import { Vector } from '../Math/vector';
3
4
  import { ExcaliburGraphicsContext } from './Context/ExcaliburGraphicsContext';
@@ -97,27 +98,67 @@ export declare enum FontStyle {
97
98
  Italic = "italic",
98
99
  Oblique = "oblique"
99
100
  }
101
+ /**
102
+ * Enum representing the text direction, useful for other languages, or writing text in reverse
103
+ */
100
104
  export declare enum Direction {
101
105
  LeftToRight = "ltr",
102
106
  RightToLeft = "rtl"
103
107
  }
108
+ /**
109
+ * Font rendering option
110
+ */
104
111
  export interface FontOptions {
112
+ /**
113
+ * Optionally the size of the font in the specified [[FontUnit]] by default 10.
114
+ */
105
115
  size?: number;
116
+ /**
117
+ * Optionally specify unit to measure fonts in, by default Pixels
118
+ */
106
119
  unit?: FontUnit;
107
- lineHeight?: number;
120
+ /**
121
+ * Optionally specify the font family, by default 'sans-serif'
122
+ */
108
123
  family?: string;
124
+ /**
125
+ * Optionally specify the font style, by default Normal
126
+ */
109
127
  style?: FontStyle;
128
+ /**
129
+ * Optionally set whether the font is bold, by default false
130
+ */
110
131
  bold?: boolean;
132
+ /**
133
+ * Optionally specify the text align, by default Left
134
+ */
111
135
  textAlign?: TextAlign;
136
+ /**
137
+ * Optionally specify the text base align, by default Alphabetic
138
+ */
112
139
  baseAlign?: BaseAlign;
140
+ /**
141
+ * Optionally specify the text direction, by default LeftToRight
142
+ */
113
143
  direction?: Direction;
144
+ /**
145
+ * Optionally specify the quality of the text bitmap, it is a multiplier on the size size, by default 2.
146
+ * Higher quality text has a higher memory impact
147
+ */
114
148
  quality?: number;
149
+ /**
150
+ * Optionally specify a text shadow, by default none is specified
151
+ */
115
152
  shadow?: {
116
153
  blur?: number;
117
154
  offset?: Vector;
118
155
  color?: Color;
119
156
  };
120
157
  }
158
+ /**
159
+ * @internal
160
+ */
121
161
  export interface FontRenderer {
122
- render(ex: ExcaliburGraphicsContext, text: string, x: number, y: number): void;
162
+ measureText(text: string): BoundingBox;
163
+ render(ex: ExcaliburGraphicsContext, text: string, color: Color, x: number, y: number): void;
123
164
  }
@@ -1,6 +1,7 @@
1
1
  import { Vector } from '../Math/vector';
2
2
  import { ExcaliburGraphicsContext } from './Context/ExcaliburGraphicsContext';
3
3
  import { BoundingBox } from '../Collision/BoundingBox';
4
+ import { Matrix } from '..';
4
5
  export interface GraphicOptions {
5
6
  /**
6
7
  * The width of the graphic
@@ -46,34 +47,47 @@ export interface GraphicOptions {
46
47
  export declare abstract class Graphic {
47
48
  private static _ID;
48
49
  readonly id: number;
50
+ transform: Matrix;
51
+ private _transformStale;
52
+ isStale(): boolean;
49
53
  /**
50
54
  * Gets or sets wether to show debug information about the graphic
51
55
  */
52
56
  showDebug: boolean;
57
+ private _flipHorizontal;
53
58
  /**
54
59
  * Gets or sets the flipHorizontal, which will flip the graphic horizontally (across the y axis)
55
60
  */
56
- flipHorizontal: boolean;
61
+ get flipHorizontal(): boolean;
62
+ set flipHorizontal(value: boolean);
63
+ private _flipVertical;
57
64
  /**
58
65
  * Gets or sets the flipVertical, which will flip the graphic vertically (across the x axis)
59
66
  */
60
- flipVertical: boolean;
67
+ get flipVertical(): boolean;
68
+ set flipVertical(value: boolean);
69
+ private _rotation;
61
70
  /**
62
71
  * Gets or sets the rotation of the graphic
63
72
  */
64
- rotation: number;
73
+ get rotation(): number;
74
+ set rotation(value: number);
65
75
  /**
66
76
  * Gets or sets the opacity of the graphic, 0 is transparent, 1 is solid (opaque).
67
77
  */
68
78
  opacity: number;
79
+ private _scale;
69
80
  /**
70
81
  * Gets or sets the scale of the graphic, this affects the width and
71
82
  */
72
- scale: Vector;
83
+ get scale(): Vector;
84
+ set scale(value: Vector);
85
+ private _origin;
73
86
  /**
74
87
  * Gets or sets the origin of the graphic, if not set the center of the graphic is the origin
75
88
  */
76
- origin: Vector | null;
89
+ get origin(): Vector | null;
90
+ set origin(value: Vector | null);
77
91
  constructor(options?: GraphicOptions);
78
92
  cloneGraphicOptions(): GraphicOptions;
79
93
  private _width;
@@ -100,7 +114,7 @@ export declare abstract class Graphic {
100
114
  */
101
115
  draw(ex: ExcaliburGraphicsContext, x: number, y: number): void;
102
116
  /**
103
- * Meant to be overriden by the graphic implementation to draw the underlying image (HTMLCanvasElement or HTMLImageElement)
117
+ * Meant to be overridden by the graphic implementation to draw the underlying image (HTMLCanvasElement or HTMLImageElement)
104
118
  * to the graphics context without transform. Transformations like position, rotation, and scale are handled by [[Graphic._preDraw]]
105
119
  * and [[Graphic._postDraw]]
106
120
  * @param ex The excalibur graphics context
@@ -115,10 +129,10 @@ export declare abstract class Graphic {
115
129
  * @param y
116
130
  */
117
131
  protected _preDraw(ex: ExcaliburGraphicsContext, x: number, y: number): void;
118
- protected _rotate(ex: ExcaliburGraphicsContext): void;
119
- protected _flip(ex: ExcaliburGraphicsContext): void;
132
+ protected _rotate(ex: ExcaliburGraphicsContext | Matrix): void;
133
+ protected _flip(ex: ExcaliburGraphicsContext | Matrix): void;
120
134
  /**
121
- * Apply any addtional work after [[Graphic._drawImage]] and restore the context state.
135
+ * Apply any additional work after [[Graphic._drawImage]] and restore the context state.
122
136
  * @param ex
123
137
  */
124
138
  protected _postDraw(ex: ExcaliburGraphicsContext): void;
@@ -14,7 +14,6 @@ export declare class GraphicsSystem extends System<TransformComponent | Graphics
14
14
  initialize(scene: Scene): void;
15
15
  sort(a: Entity, b: Entity): number;
16
16
  update(entities: Entity[], delta: number): void;
17
- private _clearScreen;
18
17
  private _isOffscreen;
19
18
  private _drawGraphicsComponent;
20
19
  /**
@@ -1,10 +1,12 @@
1
1
  import { Texture } from '../Drawing/Texture';
2
2
  import { Sprite } from './Sprite';
3
3
  import { Loadable } from '../Interfaces/Index';
4
+ import { ImageFiltering } from './Filtering';
4
5
  export declare class ImageSource implements Loadable<HTMLImageElement> {
5
6
  readonly path: string;
6
7
  private _logger;
7
8
  private _resource;
9
+ private _filtering;
8
10
  /**
9
11
  * The original size of the source image in pixels
10
12
  */
@@ -13,13 +15,14 @@ export declare class ImageSource implements Loadable<HTMLImageElement> {
13
15
  * The original height of the source image in pixels
14
16
  */
15
17
  get height(): number;
18
+ private _src;
16
19
  /**
17
20
  * Returns true if the Texture is completely loaded and is ready
18
21
  * to be drawn.
19
22
  */
20
23
  isLoaded(): boolean;
21
24
  /**
22
- * Access to the underlying html image elmeent
25
+ * Access to the underlying html image element
23
26
  */
24
27
  data: HTMLImageElement;
25
28
  get image(): HTMLImageElement;
@@ -30,9 +33,11 @@ export declare class ImageSource implements Loadable<HTMLImageElement> {
30
33
  private _loadedResolve;
31
34
  /**
32
35
  * The path to the image, can also be a data url like 'data:image/'
33
- * @param path
36
+ * @param path {string} Path to the image resource relative from the HTML document hosting the game, or absolute
37
+ * @param bustCache {boolean} Should excalibur add a cache busting querystring?
38
+ * @param filtering {ImageFiltering} Optionally override the image filtering set by [[EngineOptions.antialiasing]]
34
39
  */
35
- constructor(path: string, bustCache?: boolean);
40
+ constructor(path: string, bustCache?: boolean, filtering?: ImageFiltering);
36
41
  /**
37
42
  * Begins loading the image and returns a promise that resolves when the image is loaded
38
43
  */
@@ -5,6 +5,8 @@ export interface PolygonOptions {
5
5
  }
6
6
  /**
7
7
  * A polygon [[Graphic]] for drawing arbitrary polygons to the [[ExcaliburGraphicsContext]]
8
+ *
9
+ * Polygons default to [[ImageFiltering.Blended]]
8
10
  */
9
11
  export declare class Polygon extends Raster {
10
12
  private _points;
@@ -0,0 +1,5 @@
1
+ export declare enum ColorBlindnessMode {
2
+ Protanope = "Protanope",
3
+ Deuteranope = "Deuteranope",
4
+ Tritanope = "Tritanope"
5
+ }
@@ -0,0 +1,17 @@
1
+ import { PostProcessor } from './PostProcessor';
2
+ import { ColorBlindnessMode } from './ColorBlindnessMode';
3
+ import { Shader } from '../Context/shader';
4
+ import { VertexLayout } from '../Context/vertex-layout';
5
+ export declare class ColorBlindnessPostProcessor implements PostProcessor {
6
+ private _colorBlindnessMode;
7
+ private _shader;
8
+ private _simulate;
9
+ constructor(_colorBlindnessMode: ColorBlindnessMode, simulate?: boolean);
10
+ initialize(_gl: WebGLRenderingContext): void;
11
+ getShader(): Shader;
12
+ getLayout(): VertexLayout;
13
+ set colorBlindnessMode(colorBlindMode: ColorBlindnessMode);
14
+ get colorBlindnessMode(): ColorBlindnessMode;
15
+ set simulate(value: boolean);
16
+ get simulate(): boolean;
17
+ }
@@ -0,0 +1,7 @@
1
+ import { VertexLayout } from '..';
2
+ import { Shader } from '../Context/shader';
3
+ export interface PostProcessor {
4
+ initialize(gl: WebGLRenderingContext): void;
5
+ getShader(): Shader;
6
+ getLayout(): VertexLayout;
7
+ }
@@ -0,0 +1,16 @@
1
+ import { Shader } from '../Context/shader';
2
+ import { VertexLayout } from '../Context/vertex-layout';
3
+ /**
4
+ * Helper that defines a whole screen renderer, just provide a fragment source!
5
+ *
6
+ * Currently supports 1 varying
7
+ * - vec2 a_texcoord between 0-1 which corresponds to screen position
8
+ */
9
+ export declare class ScreenShader {
10
+ private _shader;
11
+ private _buffer;
12
+ private _layout;
13
+ constructor(fragmentSource: string);
14
+ getShader(): Shader;
15
+ getLayout(): VertexLayout;
16
+ }
@@ -0,0 +1,62 @@
1
+ precision mediump float;
2
+ // our texture
3
+ uniform sampler2D u_image;
4
+ // the texCoords passed in from the vertex shader.
5
+ varying vec2 v_texcoord;
6
+
7
+ // color blind type
8
+ uniform int u_type;
9
+
10
+ // simulation?
11
+ uniform bool u_simulate;
12
+
13
+ void main() {
14
+ vec4 o = texture2D(u_image, v_texcoord);
15
+ // RGB to LMS matrix conversion
16
+ float L = (17.8824 * o.r) + (43.5161 * o.g) + (4.11935 * o.b);
17
+ float M = (3.45565 * o.r) + (27.1554 * o.g) + (3.86714 * o.b);
18
+ float S = (0.0299566 * o.r) + (0.184309 * o.g) + (1.46709 * o.b);
19
+ // Simulate color blindness
20
+ float l;
21
+ float m;
22
+ float s;
23
+ //MODE CODE//
24
+ if (u_type == 0) {
25
+ // Protanope
26
+ l = 0.0 * L + 2.02344 * M + -2.52581 * S;
27
+ m = 0.0 * L + 1.0 * M + 0.0 * S;
28
+ s = 0.0 * L + 0.0 * M + 1.0 * S;;
29
+ } else if (u_type == 1) {
30
+ // Deuteranope
31
+ l = 1.0 * L + 0.0 * M + 0.0 * S;
32
+ m = 0.494207 * L + 0.0 * M + 1.24827 * S;
33
+ s = 0.0 * L + 0.0 * M + 1.0 * S;
34
+ } else if (u_type == 2) {
35
+ // Tritanope
36
+ l = 1.0 * L + 0.0 * M + 0.0 * S;
37
+ m = 0.0 * L + 1.0 * M + 0.0 * S;
38
+ s = -0.395913 * L + 0.801109 * M + 0.0 * S;
39
+ }
40
+
41
+ // LMS to RGB matrix conversion
42
+ vec4 error; // simulate the colors
43
+ error.r = (0.0809444479 * l) + (-0.130504409 * m) + (0.116721066 * s);
44
+ error.g = (-0.0102485335 * l) + (0.0540193266 * m) + (-0.113614708 * s);
45
+ error.b = (-0.000365296938 * l) + (-0.00412161469 * m) + (0.693511405 * s);
46
+ error.a = 1.0;
47
+ vec4 diff = o - error;
48
+ vec4 correction; // correct the colors
49
+ correction.r = 0.0;
50
+ correction.g = (diff.r * 0.7) + (diff.g * 1.0);
51
+ correction.b = (diff.r * 0.7) + (diff.b * 1.0);
52
+ correction = o + correction;
53
+ correction.a = o.a;
54
+ //SIMULATE//
55
+
56
+ // sim
57
+ if (u_simulate) {
58
+ gl_FragColor = error.rgba;
59
+ } else {
60
+ gl_FragColor = correction.rgba;
61
+ }
62
+ }
@@ -2,21 +2,48 @@ import { Graphic, GraphicOptions } from './Graphic';
2
2
  import { ExcaliburGraphicsContext } from './Context/ExcaliburGraphicsContext';
3
3
  import { Color } from '../Color';
4
4
  import { BoundingBox } from '../Collision/BoundingBox';
5
+ import { ImageFiltering } from './Filtering';
5
6
  export interface RasterOptions {
7
+ /**
8
+ * Optionally specify "smoothing" if you want antialiasing to apply to the raster's bitmap context, by default `false`
9
+ */
6
10
  smoothing?: boolean;
11
+ /**
12
+ * Optionally specify the color of the raster's bitmap context, by default [[Color.Black]]
13
+ */
7
14
  color?: Color;
15
+ /**
16
+ * Optionally specify the stroke color of the raster's bitmap context, by default undefined
17
+ */
8
18
  strokeColor?: Color;
19
+ /**
20
+ * Optionally specify the line width of the raster's bitmap, by default 1 pixel
21
+ */
9
22
  lineWidth?: number;
23
+ /**
24
+ * Optionally specify the line dash of the raster's bitmap, by default `[]` which means none
25
+ */
10
26
  lineDash?: number[];
27
+ /**
28
+ * Optionally specify the padding to apply to the bitmap
29
+ */
11
30
  padding?: number;
31
+ /**
32
+ * Optionally specify what image filtering mode should be used, [[ImageFiltering.Pixel]] for pixel art,
33
+ * [[ImageFiltering.Blended]] for hi-res art
34
+ *
35
+ * By default unset, rasters defer to the engine antialiasing setting
36
+ */
37
+ filtering?: ImageFiltering;
12
38
  }
13
39
  /**
14
40
  * A Raster is a Graphic that needs to be first painted to a HTMLCanvasElement before it can be drawn to the
15
41
  * [[ExcaliburGraphicsContext]]. This is useful for generating custom images using the 2D canvas api.
16
42
  *
17
- * Implementors must implemenet the [[Raster.execute]] method to rasterize their drawing.
43
+ * Implementors must implement the [[Raster.execute]] method to rasterize their drawing.
18
44
  */
19
45
  export declare abstract class Raster extends Graphic {
46
+ filtering: ImageFiltering;
20
47
  _bitmap: HTMLCanvasElement;
21
48
  protected _ctx: CanvasRenderingContext2D;
22
49
  private _dirty;
@@ -28,7 +55,7 @@ export declare abstract class Raster extends Graphic {
28
55
  get dirty(): boolean;
29
56
  /**
30
57
  * Flags the graphic as dirty, meaning it must be re-rasterized before draw.
31
- * This should be called any time the graphics state changes such that it affects the outputed drawing
58
+ * This should be called any time the graphics state changes such that it affects the outputted drawing
32
59
  */
33
60
  flagDirty(): void;
34
61
  private _originalWidth;
@@ -90,14 +117,14 @@ export declare abstract class Raster extends Graphic {
90
117
  get padding(): number;
91
118
  set padding(value: number);
92
119
  /**
93
- * Rasterize the graphic to a bitmap making it usuable as in excalibur. Rasterize is called automatically if
120
+ * Rasterize the graphic to a bitmap making it usable as in excalibur. Rasterize is called automatically if
94
121
  * the graphic is [[Raster.dirty]] on the next [[Graphic.draw]] call
95
122
  */
96
123
  rasterize(): void;
97
- protected _applyRasterProperites(ctx: CanvasRenderingContext2D): void;
124
+ protected _applyRasterProperties(ctx: CanvasRenderingContext2D): void;
98
125
  protected _drawImage(ex: ExcaliburGraphicsContext, x: number, y: number): void;
99
126
  /**
100
- * Executes drawing implemenation of the graphic, this is where the specific drawing code for the graphic
127
+ * Executes drawing implementation of the graphic, this is where the specific drawing code for the graphic
101
128
  * should be implemented. Once `rasterize()` the graphic can be drawn to the [[ExcaliburGraphicsContext]] via `draw(...)`
102
129
  * @param ctx Canvas to draw the graphic to
103
130
  */
@@ -38,8 +38,13 @@ export declare class Sprite extends Graphic {
38
38
  image: ImageSource;
39
39
  sourceView: SourceView;
40
40
  destSize: DestinationSize;
41
+ private _dirty;
41
42
  static from(image: ImageSource): Sprite;
42
43
  constructor(options: GraphicOptions & SpriteOptions);
44
+ get width(): number;
45
+ get height(): number;
46
+ set width(newWidth: number);
47
+ set height(newHeight: number);
43
48
  private _updateSpriteDimensions;
44
49
  protected _preDraw(ex: ExcaliburGraphicsContext, x: number, y: number): void;
45
50
  _drawImage(ex: ExcaliburGraphicsContext, x: number, y: number): void;
@@ -4,9 +4,10 @@ import { ExcaliburGraphicsContext } from './Context/ExcaliburGraphicsContext';
4
4
  import { FontRenderer } from './FontCommon';
5
5
  import { Graphic, GraphicOptions } from './Graphic';
6
6
  import { SpriteSheet } from './SpriteSheet';
7
+ import { BoundingBox, Color } from '..';
7
8
  export interface SpriteFontOptions {
8
9
  /**
9
- * Alphabet string in spritsheet order (default is row column order)
10
+ * Alphabet string in spritesheet order (default is row column order)
10
11
  * example: 'abcdefghijklmnopqrstuvwxyz'
11
12
  */
12
13
  alphabet: string;
@@ -31,7 +32,6 @@ export interface SpriteFontOptions {
31
32
  }
32
33
  export declare class SpriteFont extends Graphic implements FontRenderer {
33
34
  private _text;
34
- private _dirty;
35
35
  alphabet: string;
36
36
  spriteSheet: SpriteSheet;
37
37
  shadow: {
@@ -42,12 +42,11 @@ export declare class SpriteFont extends Graphic implements FontRenderer {
42
42
  private _logger;
43
43
  static fromLegacySpriteFont(spriteFont: LegacySpriteFont): SpriteFont;
44
44
  constructor(options: SpriteFontOptions & GraphicOptions);
45
- private _sprites;
45
+ private _alreadyWarnedAlphabet;
46
+ private _alreadyWarnedSpriteSheet;
46
47
  private _getCharacterSprites;
47
- private _updateDimensions;
48
- updateText(text: string): void;
49
- protected _preDraw(ex: ExcaliburGraphicsContext, x: number, y: number): void;
48
+ measureText(text: string): BoundingBox;
50
49
  protected _drawImage(ex: ExcaliburGraphicsContext, x: number, y: number): void;
51
- render(ex: ExcaliburGraphicsContext, text: string, x: number, y: number): void;
50
+ render(ex: ExcaliburGraphicsContext, text: string, _color: Color, x: number, y: number): void;
52
51
  clone(): SpriteFont;
53
52
  }
@@ -53,7 +53,7 @@ export interface SpriteSheetGridOptions {
53
53
  spriteHeight: number;
54
54
  };
55
55
  /**
56
- * Optionally specifiy any spacing information between sprites
56
+ * Optionally specify any spacing information between sprites
57
57
  */
58
58
  spacing?: SpriteSheetSpacingDimensions;
59
59
  }
@@ -99,7 +99,6 @@ export declare class SpriteSheet {
99
99
  /**
100
100
  * @deprecated
101
101
  * @param spriteSheet
102
- * @returns
103
102
  */
104
103
  static toLegacySpriteSheet(spriteSheet: SpriteSheet): LegacySpriteSheet;
105
104
  /**
@@ -5,23 +5,39 @@ import { Graphic, GraphicOptions } from './Graphic';
5
5
  import { Color } from '../Color';
6
6
  import { Font } from './Font';
7
7
  export interface TextOptions {
8
+ /**
9
+ * Text to draw
10
+ */
8
11
  text: string;
12
+ /**
13
+ * Optionally override the font color, currently unsupported by SpriteFont
14
+ */
9
15
  color?: Color;
16
+ /**
17
+ * Optionally specify a font, if none specified a default font is used (System sans-serif 10 pixel)
18
+ */
10
19
  font?: Font | SpriteFont;
11
20
  }
21
+ /**
22
+ * Represent Text graphics in excalibur
23
+ *
24
+ * Useful for in game labels, ui, or overlays
25
+ */
12
26
  export declare class Text extends Graphic {
27
+ color?: Color;
13
28
  constructor(options: TextOptions & GraphicOptions);
14
29
  clone(): Text;
15
30
  private _text;
16
31
  get text(): string;
17
32
  set text(value: string);
18
- get color(): Color;
19
- set color(color: Color);
20
33
  private _font;
21
34
  get font(): Font | SpriteFont;
22
35
  set font(font: Font | SpriteFont);
36
+ private _textWidth;
23
37
  get width(): number;
38
+ private _textHeight;
24
39
  get height(): number;
40
+ private _calculateDimension;
25
41
  get localBounds(): BoundingBox;
26
42
  protected _rotate(_ex: ExcaliburGraphicsContext): void;
27
43
  protected _flip(_ex: ExcaliburGraphicsContext): void;