textmode.js 0.4.0 → 0.6.0-beta.1

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 (105) hide show
  1. package/dist/textmode.esm.js +2868 -2164
  2. package/dist/textmode.esm.min.js +2863 -2159
  3. package/dist/textmode.umd.js +11 -8
  4. package/dist/textmode.umd.min.js +11 -8
  5. package/dist/types/Textmode.d.ts +13 -22
  6. package/dist/types/index.d.ts +8 -6
  7. package/dist/types/rendering/index.d.ts +3 -3
  8. package/dist/types/rendering/webgl/batching/DrawQueue.d.ts +89 -0
  9. package/dist/types/rendering/webgl/{VAOManager.d.ts → batching/GeometryAttributeCache.d.ts} +4 -4
  10. package/dist/types/rendering/webgl/batching/InstanceAttributeBinder.d.ts +87 -0
  11. package/dist/types/rendering/webgl/{InstanceBatch.d.ts → batching/InstanceBatch.d.ts} +25 -34
  12. package/dist/types/rendering/webgl/batching/InstanceBuffer.d.ts +78 -0
  13. package/dist/types/rendering/webgl/{InstanceData.d.ts → batching/InstanceData.d.ts} +11 -18
  14. package/dist/types/rendering/webgl/batching/InstanceWriter.d.ts +70 -0
  15. package/dist/types/rendering/webgl/{Framebuffer.d.ts → core/Framebuffer.d.ts} +37 -39
  16. package/dist/types/rendering/webgl/core/Renderer.d.ts +64 -0
  17. package/dist/types/rendering/webgl/{Shader.d.ts → core/Shader.d.ts} +2 -23
  18. package/dist/types/rendering/webgl/core/interfaces/IFramebuffer.d.ts +103 -0
  19. package/dist/types/rendering/webgl/core/interfaces/IRenderer.d.ts +210 -0
  20. package/dist/types/rendering/webgl/geometries/{Arc.d.ts → 2d/Arc.d.ts} +5 -4
  21. package/dist/types/rendering/webgl/geometries/{BezierCurve.d.ts → 2d/BezierCurve.d.ts} +5 -4
  22. package/dist/types/rendering/webgl/geometries/{Ellipse.d.ts → 2d/Ellipse.d.ts} +6 -5
  23. package/dist/types/rendering/webgl/geometries/{Line.d.ts → 2d/Line.d.ts} +5 -4
  24. package/dist/types/rendering/webgl/geometries/{Rectangle.d.ts → 2d/Rectangle.d.ts} +5 -4
  25. package/dist/types/rendering/webgl/geometries/{Triangle.d.ts → 2d/Triangle.d.ts} +5 -4
  26. package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +30 -26
  27. package/dist/types/rendering/webgl/geometries/immediate/ImmediateQuad.d.ts +33 -0
  28. package/dist/types/rendering/webgl/geometries/index.d.ts +6 -6
  29. package/dist/types/rendering/webgl/geometries/utils/GeometryDescriptors.d.ts +31 -0
  30. package/dist/types/rendering/webgl/geometries/utils/GeometryGenerator.d.ts +16 -0
  31. package/dist/types/rendering/webgl/index.d.ts +15 -14
  32. package/dist/types/rendering/webgl/materials/Material.d.ts +26 -0
  33. package/dist/types/rendering/webgl/materials/MaterialManager.d.ts +63 -0
  34. package/dist/types/rendering/webgl/materials/index.d.ts +2 -0
  35. package/dist/types/rendering/webgl/pipeline/MaterialBatchPipeline.d.ts +63 -0
  36. package/dist/types/rendering/webgl/pipeline/index.d.ts +7 -0
  37. package/dist/types/rendering/webgl/state/RenderState.d.ts +143 -0
  38. package/dist/types/rendering/webgl/types/DrawCommand.d.ts +5 -3
  39. package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +10 -10
  40. package/dist/types/rendering/webgl/types/RenderTypes.d.ts +1 -1
  41. package/dist/types/rendering/webgl/utils/GLUtils.d.ts +45 -0
  42. package/dist/types/rendering/webgl/utils/hash.d.ts +118 -0
  43. package/dist/types/textmode/AnimationController.d.ts +11 -21
  44. package/dist/types/textmode/Canvas.d.ts +10 -2
  45. package/dist/types/textmode/Grid.d.ts +2 -0
  46. package/dist/types/textmode/TextmodeColor.d.ts +57 -0
  47. package/dist/types/textmode/Textmodifier.d.ts +40 -212
  48. package/dist/types/textmode/interfaces/ITextmodifier.d.ts +272 -0
  49. package/dist/types/textmode/interfaces/index.d.ts +1 -0
  50. package/dist/types/textmode/loadables/TextmodeImage.d.ts +21 -0
  51. package/dist/types/textmode/loadables/TextmodeSource.d.ts +130 -0
  52. package/dist/types/textmode/loadables/TextmodeVideo.d.ts +237 -0
  53. package/dist/types/textmode/{font → loadables/font}/CharacterColorMapper.d.ts +1 -1
  54. package/dist/types/textmode/{font → loadables/font}/CharacterExtractor.d.ts +0 -10
  55. package/dist/types/textmode/{font → loadables/font}/TextmodeFont.d.ts +6 -3
  56. package/dist/types/textmode/{font → loadables/font}/TextureAtlas.d.ts +4 -11
  57. package/dist/types/textmode/{font → loadables/font}/typr/types.d.ts +0 -6
  58. package/dist/types/textmode/loadables/index.d.ts +5 -0
  59. package/dist/types/textmode/loading/LoadingPhaseTracker.d.ts +20 -0
  60. package/dist/types/textmode/loading/LoadingScreenManager.d.ts +170 -0
  61. package/dist/types/textmode/loading/LoadingScreenState.d.ts +22 -0
  62. package/dist/types/textmode/loading/LoadingScreenTheme.d.ts +26 -0
  63. package/dist/types/textmode/loading/LoadingScreenTransition.d.ts +17 -0
  64. package/dist/types/textmode/loading/index.d.ts +6 -0
  65. package/dist/types/textmode/loading/templates/SpinnerTemplate.d.ts +2 -0
  66. package/dist/types/textmode/loading/templates/index.d.ts +1 -0
  67. package/dist/types/textmode/loading/types.d.ts +251 -0
  68. package/dist/types/textmode/managers/KeyboardManager.d.ts +2 -3
  69. package/dist/types/textmode/managers/MouseManager.d.ts +1 -1
  70. package/dist/types/textmode/{plugins → managers}/PluginManager.d.ts +12 -15
  71. package/dist/types/textmode/managers/TouchManager.d.ts +0 -2
  72. package/dist/types/textmode/mixins/AnimationMixin.d.ts +2 -122
  73. package/dist/types/textmode/mixins/FontMixin.d.ts +2 -77
  74. package/dist/types/textmode/mixins/KeyboardMixin.d.ts +3 -85
  75. package/dist/types/textmode/mixins/MouseMixin.d.ts +3 -130
  76. package/dist/types/textmode/mixins/RenderingMixin.d.ts +2 -749
  77. package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +2 -44
  78. package/dist/types/textmode/mixins/TouchMixin.d.ts +2 -187
  79. package/dist/types/textmode/mixins/index.d.ts +8 -8
  80. package/dist/types/textmode/mixins/interfaces/IAnimationMixin.d.ts +167 -0
  81. package/dist/types/textmode/mixins/interfaces/IFontMixin.d.ts +46 -0
  82. package/dist/types/textmode/mixins/interfaces/IKeyboardMixin.d.ts +235 -0
  83. package/dist/types/textmode/mixins/interfaces/IMouseMixin.d.ts +457 -0
  84. package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +1085 -0
  85. package/dist/types/textmode/mixins/interfaces/ITouchMixin.d.ts +186 -0
  86. package/dist/types/textmode/types.d.ts +49 -0
  87. package/dist/types/textmode/utils/cssColor.d.ts +8 -0
  88. package/dist/types/utils/array.d.ts +34 -0
  89. package/dist/types/utils/math.d.ts +69 -0
  90. package/package.json +1 -1
  91. package/dist/types/rendering/webgl/DrawQueue.d.ts +0 -30
  92. package/dist/types/rendering/webgl/RenderPipeline.d.ts +0 -30
  93. package/dist/types/rendering/webgl/RenderState.d.ts +0 -73
  94. package/dist/types/rendering/webgl/Renderer.d.ts +0 -158
  95. package/dist/types/rendering/webgl/ShaderManager.d.ts +0 -66
  96. package/dist/types/rendering/webgl/geometries/NoiseGrid.d.ts +0 -1
  97. package/dist/types/textmode/TextmodeImage.d.ts +0 -161
  98. package/dist/types/textmode/mixins/ShaderMixin.d.ts +0 -1
  99. /package/dist/types/rendering/webgl/{StateCache.d.ts → utils/ViewportCache.d.ts} +0 -0
  100. /package/dist/types/textmode/{font → loadables/font}/MetricsCalculator.d.ts +0 -0
  101. /package/dist/types/textmode/{font → loadables/font}/index.d.ts +0 -0
  102. /package/dist/types/textmode/{font → loadables/font}/types.d.ts +0 -0
  103. /package/dist/types/textmode/{font → loadables/font}/typr/Typr.d.ts +0 -0
  104. /package/dist/types/textmode/{font → loadables/font}/utils/FontTableReader.d.ts +0 -0
  105. /package/dist/types/textmode/{font → loadables/font}/utils/index.d.ts +0 -0
@@ -1,15 +1,7 @@
1
1
  /**
2
2
  * Base types and utilities for the mixin system
3
3
  */
4
- import type { GLRenderer } from '../../rendering/webgl/Renderer';
5
- import type { TextmodeFont } from '../font';
6
- import type { TextmodeCanvas } from '../Canvas';
7
- import type { TextmodeGrid } from '../Grid';
8
- import type { AnimationController } from '../AnimationController';
9
- import type { GLFramebuffer, Shader } from '../../rendering';
10
- import type { MouseManager } from '../managers/MouseManager';
11
- import type { KeyboardManager } from '../managers/KeyboardManager';
12
- import type { TouchManager } from '../managers/TouchManager';
4
+ import type { ITextmodifier } from '../interfaces';
13
5
  /**
14
6
  * Constructor type for mixin pattern
15
7
  */
@@ -17,41 +9,7 @@ export type Constructor<T = {}> = new (...args: any[]) => T;
17
9
  /**
18
10
  * Mixin function type that takes a base class and returns an extended class
19
11
  */
20
- export type Mixin<T> = <TBase extends Constructor<TextmodifierContext>>(Base: TBase) => TBase & Constructor<T>;
21
- /**
22
- * Essential properties that all mixins can access.
23
- * This defines the contract for what mixins can expect to be available.
24
- */
25
- export interface TextmodifierContext {
26
- /** Core WebGL renderer @ignore */
27
- readonly _renderer: GLRenderer;
28
- /** Font management @ignore */
29
- readonly _font: TextmodeFont;
30
- /** Canvas management @ignore */
31
- readonly _canvas: TextmodeCanvas;
32
- /** Grid management @ignore */
33
- readonly _grid: TextmodeGrid;
34
- /** Animation controller for managing rendering loop @ignore */
35
- readonly _animationController: AnimationController;
36
- /** Mouse interaction manager @ignore */
37
- readonly _mouseManager: MouseManager;
38
- /** Touch interaction manager @ignore */
39
- readonly _touchManager: TouchManager;
40
- /** Keyboard interaction manager @ignore */
41
- readonly _keyboardManager: KeyboardManager;
42
- /** Draw shader that contains content drawn by the user @ignore */
43
- readonly _textmodeDrawShader: Shader;
44
- /** Framebuffer used for offscreen rendering @ignore */
45
- readonly _textmodeDrawFramebuffer: GLFramebuffer;
46
- /** Shader used for converting pixels to textmode grid format @ignore */
47
- readonly _textmodeConversionShader: Shader;
48
- /** Framebuffer used for textmode conversion @ignore */
49
- readonly _asciiColorFramebuffer: GLFramebuffer;
50
- /** Shader used for final presentation to the screen @ignore */
51
- readonly _presentShader: Shader;
52
- /** Main render method @ignore */
53
- $render(): void;
54
- }
12
+ export type Mixin<T> = <TBase extends Constructor<ITextmodifier>>(Base: TBase) => TBase & Constructor<T>;
55
13
  /**
56
14
  * Simple utility function to apply multiple mixins to a base class
57
15
  * @param Base The base class to extend
@@ -1,191 +1,6 @@
1
1
  import type { Mixin } from './TextmodifierMixin';
2
- import type { TouchEventHandler, TouchLongPressHandler, TouchPinchHandler, TouchPosition, TouchRotateHandler, TouchSwipeHandler, TouchTapHandler } from '../managers/TouchManager';
3
- /**
4
- * Capabilities exposed by the TouchMixin for handling touch interaction and gestures.
5
- */
6
- export interface TouchCapabilities {
7
- /**
8
- * Set a callback function that will be called when a touch point begins.
9
- *
10
- * The callback receives {@link TouchEventData} containing the touch that triggered the event,
11
- * all active touches, and the original DOM event. Use this to react when the user places one or
12
- * more fingers on the canvas.
13
- *
14
- * @param callback The function to call when a touch starts.
15
- *
16
- * @example
17
- * ```javascript
18
- * t.touchStarted((data) => {
19
- * console.log(`Touch ${data.touch.id} began at ${data.touch.x}, ${data.touch.y}`);
20
- * });
21
- * ```
22
- */
23
- touchStarted(callback: TouchEventHandler): void;
24
- /**
25
- * Set a callback function that will be called when a touch point moves across the canvas.
26
- *
27
- * The provided callback is invoked continuously while the browser reports move events. Use the
28
- * `previousTouch` and `deltaTime` fields to derive velocity or gesture behaviour.
29
- *
30
- * @param callback The function to call when a touch moves.
31
- *
32
- * @example
33
- * ```javascript
34
- * t.touchMoved((data) => {
35
- * const { touch, previousTouch } = data;
36
- * if (previousTouch) {
37
- * console.log(`Touch moved by ${touch.x - previousTouch.x}, ${touch.y - previousTouch.y}`);
38
- * }
39
- * });
40
- * ```
41
- */
42
- touchMoved(callback: TouchEventHandler): void;
43
- /**
44
- * Set a callback function that will be called when a touch ends normally.
45
- *
46
- * This fires after the finger leaves the canvas surface and the browser raises a `touchend`
47
- * event. Use it to finalise state such as drawing strokes or completing gestures.
48
- *
49
- * @param callback The function to call when a touch ends.
50
- *
51
- * @example
52
- * ```javascript
53
- * t.touchEnded((data) => {
54
- * console.log(`Touch ${data.touch.id} finished at ${data.touch.x}, ${data.touch.y}`);
55
- * });
56
- * ```
57
- */
58
- touchEnded(callback: TouchEventHandler): void;
59
- /**
60
- * Set a callback function that will be called when a touch is cancelled by the browser.
61
- *
62
- * Cancellation can occur when the browser takes ownership for scrolling or if the gesture
63
- * leaves the window. Treat this as an aborted touch and clean up any in-progress state.
64
- *
65
- * @param callback The function to call when a touch is cancelled.
66
- *
67
- * @example
68
- * ```javascript
69
- * t.touchCancelled((data) => {
70
- * console.warn(`Touch ${data.touch.id} cancelled by the browser`);
71
- * });
72
- * ```
73
- */
74
- touchCancelled(callback: TouchEventHandler): void;
75
- /**
76
- * Register a callback for tap gestures.
77
- *
78
- * A tap is fired when the user quickly touches and releases the canvas without travelling far.
79
- * Use {@link TouchTapEventData.taps} to determine whether the gesture is a single or multi tap.
80
- *
81
- * @param callback The function to call when a tap gesture is detected.
82
- *
83
- * @example
84
- * ```javascript
85
- * t.tap((data) => {
86
- * console.log(`Tapped at ${data.touch.x}, ${data.touch.y}`);
87
- * });
88
- * ```
89
- */
90
- tap(callback: TouchTapHandler): void;
91
- /**
92
- * Register a callback for double tap gestures.
93
- *
94
- * Double taps reuse the same {@link TouchTapEventData} as taps with `taps` set to `2`. This
95
- * helper lets you supply a dedicated handler when you want to treat double taps differently.
96
- *
97
- * @param callback The function to call when a double tap is detected.
98
- *
99
- * @example
100
- * ```javascript
101
- * t.doubleTap((data) => {
102
- * console.log('Double tap detected', data.touch);
103
- * });
104
- * ```
105
- */
106
- doubleTap(callback: TouchTapHandler): void;
107
- /**
108
- * Register a callback for long press gestures.
109
- *
110
- * A long press is emitted when the user keeps a finger on the canvas without moving beyond the
111
- * configured tolerance. The event includes the press duration in milliseconds.
112
- *
113
- * @param callback The function to call when a long press gesture is detected.
114
- *
115
- * @example
116
- * ```javascript
117
- * t.longPress((data) => {
118
- * console.log(`Long press for ${Math.round(data.duration)}ms`);
119
- * });
120
- * ```
121
- */
122
- longPress(callback: TouchLongPressHandler): void;
123
- /**
124
- * Register a callback for swipe gestures.
125
- *
126
- * Swipes provide the dominant direction (`up`, `down`, `left`, `right`), travelled distance, and
127
- * velocity in CSS pixels per millisecond. Useful for panning, flicks, or quick shortcuts.
128
- *
129
- * @param callback The function to call when a swipe gesture is detected.
130
- *
131
- * @example
132
- * ```javascript
133
- * t.swipe((data) => {
134
- * console.log(`Swipe ${data.direction} with distance ${data.distance}`);
135
- * });
136
- * ```
137
- */
138
- swipe(callback: TouchSwipeHandler): void;
139
- /**
140
- * Register a callback for pinch gestures, receiving scale deltas.
141
- *
142
- * Pinch gestures involve two touch points. The callback receives the current scale relative to
143
- * the initial distance and the change since the previous update, enabling zoom interactions.
144
- *
145
- * @param callback The function to call when a pinch gesture is detected.
146
- *
147
- * @example
148
- * ```javascript
149
- * t.pinch((data) => {
150
- * console.log(`Pinch scale: ${data.scale.toFixed(2)}`);
151
- * });
152
- * ```
153
- */
154
- pinch(callback: TouchPinchHandler): void;
155
- /**
156
- * Register a callback for rotate gestures, receiving rotation deltas in degrees.
157
- *
158
- * Rotation callbacks provide the cumulative rotation and delta rotation since the last update,
159
- * along with the gesture centre in grid coordinates. Ideal for dial-like interactions.
160
- *
161
- * @param callback The function to call when a rotation gesture is detected.
162
- *
163
- * @example
164
- * ```javascript
165
- * t.rotateGesture((data) => {
166
- * console.log(`Rotated ${data.deltaRotation.toFixed(1)}°`);
167
- * });
168
- * ```
169
- */
170
- rotateGesture(callback: TouchRotateHandler): void;
171
- /**
172
- * Get the currently active touches in grid coordinates.
173
- *
174
- * Returns a copy of each touch, including grid position, client coordinates, and pressure when
175
- * available. Use this inside a draw loop to react to active multi-touch scenarios.
176
- *
177
- * @example
178
- * ```javascript
179
- * t.draw(() => {
180
- * for (const touch of t.touches) {
181
- * t.point(touch.x, touch.y);
182
- * }
183
- * });
184
- * ```
185
- */
186
- get touches(): TouchPosition[];
187
- }
2
+ import type { ITouchMixin } from './interfaces/ITouchMixin';
188
3
  /**
189
4
  * Mixin that wires the public touch API to the underlying TouchManager implementation.
190
5
  */
191
- export declare const TouchMixin: Mixin<TouchCapabilities>;
6
+ export declare const TouchMixin: Mixin<ITouchMixin>;
@@ -1,10 +1,10 @@
1
- export { type Constructor, type Mixin, type TextmodifierContext, $applyMixins } from './TextmodifierMixin';
2
- export { RenderingMixin, type RenderingCapabilities } from './RenderingMixin';
3
- export { FontMixin, type FontCapabilities } from './FontMixin';
4
- export { AnimationMixin, type AnimationCapabilities } from './AnimationMixin';
5
- export { MouseMixin, type MouseCapabilities } from './MouseMixin';
6
- export { TouchMixin, type TouchCapabilities } from './TouchMixin';
7
- export { KeyboardMixin, type KeyboardCapabilities } from './KeyboardMixin';
1
+ export { type Constructor, type Mixin, $applyMixins } from './TextmodifierMixin';
2
+ export { RenderingMixin } from './RenderingMixin';
3
+ export { FontMixin } from './FontMixin';
4
+ export { AnimationMixin } from './AnimationMixin';
5
+ export { MouseMixin } from './MouseMixin';
6
+ export { TouchMixin } from './TouchMixin';
7
+ export { KeyboardMixin } from './KeyboardMixin';
8
8
  export type { MousePosition, MouseEventData, MouseEventHandler } from '../managers/MouseManager';
9
- export type { TouchEventData, TouchLongPressEventData, TouchPinchEventData, TouchPosition, TouchRotateEventData, TouchSwipeEventData, TouchTapEventData } from '../managers/TouchManager';
10
9
  export type { KeyboardEventData, KeyboardEventHandler, KeyState } from '../managers/KeyboardManager';
10
+ export type { TouchEventData, TouchLongPressEventData, TouchPinchEventData, TouchPosition, TouchRotateEventData, TouchSwipeEventData, TouchTapEventData } from '../managers/TouchManager';
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Interface for animation capabilities that will be mixed into Textmodifier
3
+ */
4
+ export interface IAnimationMixin {
5
+ /**
6
+ * Set the maximum frame rate. If called without arguments, returns the current measured frame rate.
7
+ * @param fps The maximum frames per second for rendering.
8
+ *
9
+ * @example
10
+ * ```javascript
11
+ * // Create a Textmodifier instance
12
+ * const textmodifier = textmode.create();
13
+ *
14
+ * // Set the maximum frame rate to 30 FPS
15
+ * textmodifier.frameRate(30);
16
+ *
17
+ * // Draw something at the set frame rate
18
+ * t.draw(() => {
19
+ * t.background(0);
20
+ * t.char('A');
21
+ * t.rect(5, 5);
22
+ * });
23
+ * ```
24
+ */
25
+ frameRate(fps?: number): number | void;
26
+ /**
27
+ * Stop the automatic rendering loop.
28
+ *
29
+ * This method pauses the render loop without, allowing
30
+ * it to be resumed later with {@link loop}. This is useful for temporarily pausing
31
+ * animation while maintaining the ability to continue it.
32
+ *
33
+ * @example
34
+ * ```javascript
35
+ * const t = textmode.create({ width: 800, height: 600 });
36
+ *
37
+ * // Toggle loop on SPACE
38
+ * t.keyPressed((data) => {
39
+ * if (data.key === ' ') {
40
+ * if (t.isLooping()) {
41
+ * t.noLoop();
42
+ * } else {
43
+ * t.loop();
44
+ * }
45
+ * }
46
+ * });
47
+ *
48
+ * t.draw(() => {
49
+ * t.background(0);
50
+ * t.char('A');
51
+ * t.charColor(255, 255, 255);
52
+ * t.rotateZ(t.frameCount * 2);
53
+ * t.rect(16, 16);
54
+ * });
55
+ * ```
56
+ */
57
+ noLoop(): void;
58
+ /**
59
+ * Resume the rendering loop if it was stopped by {@link noLoop}.
60
+ *
61
+ * @example
62
+ * ```javascript
63
+ * const t = textmode.create({ width: 800, height: 600 });
64
+ *
65
+ * // Toggle loop on SPACE
66
+ * t.keyPressed((data) => {
67
+ * if (data.key === ' ') {
68
+ * if (t.isLooping()) {
69
+ * t.noLoop();
70
+ * } else {
71
+ * t.loop();
72
+ * }
73
+ * }
74
+ * });
75
+ *
76
+ * t.draw(() => {
77
+ * t.background(0);
78
+ * t.char('A');
79
+ * t.charColor(255, 255, 255);
80
+ * t.rotateZ(t.frameCount * 2);
81
+ * t.rect(16, 16);
82
+ * });
83
+ * ```
84
+ */
85
+ loop(): void;
86
+ /**
87
+ * Execute the render function a specified number of times.
88
+ *
89
+ * This method is useful when the render loop has been stopped with {@link noLoop},
90
+ * allowing you to trigger rendering on demand.
91
+ *
92
+ * @param n The number of times to execute the render function. Defaults to 1.
93
+ *
94
+ * @example
95
+ * ```javascript
96
+ * // Press SPACE to manually trigger single frames while loop is paused.
97
+ *
98
+ * const t = textmode.create({ width: 800, height: 600 });
99
+ *
100
+ * let rotation = 0;
101
+ *
102
+ * t.keyPressed((data) => {
103
+ * if (data.key === ' ') {
104
+ * rotation += 15; // Increment rotation
105
+ * t.redraw(); // Manually trigger one frame
106
+ * }
107
+ * });
108
+ *
109
+ * t.draw(() => {
110
+ * if(t.frameCount === 1) {
111
+ * t.noLoop();
112
+ * }
113
+ *
114
+ * t.background(0);
115
+ *
116
+ * t.push();
117
+ * t.char('A');
118
+ * t.charColor(100, 200, 255);
119
+ * t.rotateZ(rotation);
120
+ * t.rect(13, 13);
121
+ * t.pop();
122
+ *
123
+ * // Show instruction text
124
+ * t.push();
125
+ * t.translate(-5, -10);
126
+ * t.charColor(150);
127
+ * const msg = 'PRESS SPACE';
128
+ * [...msg].forEach((char, i) => {
129
+ * t.push();
130
+ * t.translate(i, 0);
131
+ * t.char(char);
132
+ * t.point();
133
+ * t.pop();
134
+ * });
135
+ * t.pop();
136
+ * });
137
+ * ```
138
+ */
139
+ redraw(n?: number): void;
140
+ /**
141
+ * Check whether the textmodifier is currently running the automatic render loop.
142
+ * @returns True if the render loop is currently active, false otherwise.
143
+ *
144
+ * @example
145
+ * ```javascript
146
+ * const textmodifier = textmode.create(canvas);
147
+ *
148
+ * // Check loop status in different states
149
+ * console.log(textmodifier.isLooping()); // true (looping)
150
+ *
151
+ * textmodifier.noLoop();
152
+ * console.log(textmodifier.isLooping()); // false (not looping)
153
+ *
154
+ * textmodifier.loop();
155
+ * console.log(textmodifier.isLooping()); // true (looping)
156
+ * ```
157
+ */
158
+ isLooping(): boolean;
159
+ /**
160
+ * Get the current frame count.
161
+ */
162
+ get frameCount(): number;
163
+ /**
164
+ * Set the current frame count.
165
+ */
166
+ set frameCount(value: number);
167
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Interface for font capabilities that will be mixed into Textmodifier
3
+ */
4
+ export interface IFontMixin {
5
+ /**
6
+ * Update the font used for rendering.
7
+ * @param fontSource The URL of the font to load.
8
+ *
9
+ * @example
10
+ * ```javascript
11
+ * // Create a Textmodifier instance
12
+ * const t = textmode.create();
13
+ *
14
+ * t.setup(async () => {
15
+ * // Load a custom font from a URL
16
+ * await t.loadFont('https://example.com/fonts/myfont.ttf');
17
+ *
18
+ * // Local font example
19
+ * // await t.loadFont('./fonts/myfont.ttf');
20
+ * });
21
+ * ```
22
+ */
23
+ loadFont(fontSource: string): Promise<void>;
24
+ /**
25
+ * Set the font size used for rendering.
26
+ * @param size The font size to set.
27
+ *
28
+ * @example
29
+ * ```javascript
30
+ * // Create a Textmodifier instance
31
+ * const t = textmode.create();
32
+ *
33
+ * t.setup(() => {
34
+ * // Set the font size to 32
35
+ * t.fontSize(32);
36
+ * });
37
+ *
38
+ * t.draw(() => {
39
+ * t.background(0);
40
+ * t.char('A');
41
+ * t.rect(5, 5);
42
+ * });
43
+ * ```
44
+ */
45
+ fontSize(size: number): void;
46
+ }