textmode.js 0.4.1-beta.1 → 0.6.0-beta.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 (106) hide show
  1. package/dist/textmode.esm.js +2578 -1861
  2. package/dist/textmode.esm.min.js +2578 -1861
  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/errors/ErrorHandler.d.ts +6 -1
  7. package/dist/types/index.d.ts +8 -6
  8. package/dist/types/rendering/index.d.ts +3 -3
  9. package/dist/types/rendering/webgl/batching/DrawQueue.d.ts +89 -0
  10. package/dist/types/rendering/webgl/{VAOManager.d.ts → batching/GeometryAttributeCache.d.ts} +4 -4
  11. package/dist/types/rendering/webgl/batching/InstanceAttributeBinder.d.ts +87 -0
  12. package/dist/types/rendering/webgl/{InstanceBatch.d.ts → batching/InstanceBatch.d.ts} +28 -37
  13. package/dist/types/rendering/webgl/batching/InstanceBuffer.d.ts +78 -0
  14. package/dist/types/rendering/webgl/{InstanceData.d.ts → batching/InstanceData.d.ts} +11 -18
  15. package/dist/types/rendering/webgl/batching/InstanceWriter.d.ts +70 -0
  16. package/dist/types/rendering/webgl/{Framebuffer.d.ts → core/Framebuffer.d.ts} +37 -39
  17. package/dist/types/rendering/webgl/core/Renderer.d.ts +64 -0
  18. package/dist/types/rendering/webgl/{Shader.d.ts → core/Shader.d.ts} +2 -23
  19. package/dist/types/rendering/webgl/core/interfaces/IFramebuffer.d.ts +103 -0
  20. package/dist/types/rendering/webgl/core/interfaces/IRenderer.d.ts +210 -0
  21. package/dist/types/rendering/webgl/geometries/{Arc.d.ts → 2d/Arc.d.ts} +5 -4
  22. package/dist/types/rendering/webgl/geometries/{BezierCurve.d.ts → 2d/BezierCurve.d.ts} +5 -4
  23. package/dist/types/rendering/webgl/geometries/{Ellipse.d.ts → 2d/Ellipse.d.ts} +6 -5
  24. package/dist/types/rendering/webgl/geometries/{Line.d.ts → 2d/Line.d.ts} +5 -4
  25. package/dist/types/rendering/webgl/geometries/{Rectangle.d.ts → 2d/Rectangle.d.ts} +5 -4
  26. package/dist/types/rendering/webgl/geometries/{Triangle.d.ts → 2d/Triangle.d.ts} +5 -4
  27. package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +30 -26
  28. package/dist/types/rendering/webgl/geometries/immediate/ImmediateQuad.d.ts +33 -0
  29. package/dist/types/rendering/webgl/geometries/index.d.ts +6 -6
  30. package/dist/types/rendering/webgl/geometries/utils/GeometryDescriptors.d.ts +31 -0
  31. package/dist/types/rendering/webgl/geometries/utils/GeometryGenerator.d.ts +16 -0
  32. package/dist/types/rendering/webgl/index.d.ts +15 -14
  33. package/dist/types/rendering/webgl/materials/Material.d.ts +26 -0
  34. package/dist/types/rendering/webgl/materials/MaterialManager.d.ts +63 -0
  35. package/dist/types/rendering/webgl/materials/index.d.ts +2 -0
  36. package/dist/types/rendering/webgl/pipeline/MaterialBatchPipeline.d.ts +63 -0
  37. package/dist/types/rendering/webgl/pipeline/index.d.ts +7 -0
  38. package/dist/types/rendering/webgl/state/RenderState.d.ts +143 -0
  39. package/dist/types/rendering/webgl/types/DrawCommand.d.ts +5 -3
  40. package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +10 -10
  41. package/dist/types/rendering/webgl/types/RenderTypes.d.ts +1 -1
  42. package/dist/types/rendering/webgl/utils/GLUtils.d.ts +45 -0
  43. package/dist/types/rendering/webgl/utils/hash.d.ts +118 -0
  44. package/dist/types/textmode/AnimationController.d.ts +11 -21
  45. package/dist/types/textmode/Canvas.d.ts +10 -2
  46. package/dist/types/textmode/Grid.d.ts +2 -0
  47. package/dist/types/textmode/TextmodeColor.d.ts +57 -0
  48. package/dist/types/textmode/Textmodifier.d.ts +32 -213
  49. package/dist/types/textmode/interfaces/ITextmodifier.d.ts +275 -0
  50. package/dist/types/textmode/interfaces/index.d.ts +1 -0
  51. package/dist/types/textmode/loadables/TextmodeImage.d.ts +47 -0
  52. package/dist/types/textmode/loadables/TextmodeSource.d.ts +130 -0
  53. package/dist/types/textmode/loadables/TextmodeVideo.d.ts +265 -0
  54. package/dist/types/textmode/{font → loadables/font}/CharacterColorMapper.d.ts +1 -1
  55. package/dist/types/textmode/{font → loadables/font}/CharacterExtractor.d.ts +0 -10
  56. package/dist/types/textmode/{font → loadables/font}/TextmodeFont.d.ts +9 -3
  57. package/dist/types/textmode/{font → loadables/font}/TextureAtlas.d.ts +4 -11
  58. package/dist/types/textmode/{font → loadables/font}/typr/types.d.ts +0 -6
  59. package/dist/types/textmode/loadables/index.d.ts +5 -0
  60. package/dist/types/textmode/loading/LoadingPhaseTracker.d.ts +20 -0
  61. package/dist/types/textmode/loading/LoadingScreenManager.d.ts +211 -0
  62. package/dist/types/textmode/loading/LoadingScreenState.d.ts +22 -0
  63. package/dist/types/textmode/loading/LoadingScreenTheme.d.ts +26 -0
  64. package/dist/types/textmode/loading/LoadingScreenTransition.d.ts +17 -0
  65. package/dist/types/textmode/loading/index.d.ts +6 -0
  66. package/dist/types/textmode/loading/templates/SpinnerTemplate.d.ts +2 -0
  67. package/dist/types/textmode/loading/templates/index.d.ts +1 -0
  68. package/dist/types/textmode/loading/types.d.ts +251 -0
  69. package/dist/types/textmode/managers/KeyboardManager.d.ts +2 -3
  70. package/dist/types/textmode/managers/MouseManager.d.ts +1 -1
  71. package/dist/types/textmode/{plugins → managers}/PluginManager.d.ts +18 -16
  72. package/dist/types/textmode/managers/TouchManager.d.ts +0 -2
  73. package/dist/types/textmode/mixins/AnimationMixin.d.ts +2 -122
  74. package/dist/types/textmode/mixins/FontMixin.d.ts +2 -77
  75. package/dist/types/textmode/mixins/KeyboardMixin.d.ts +3 -85
  76. package/dist/types/textmode/mixins/MouseMixin.d.ts +3 -130
  77. package/dist/types/textmode/mixins/RenderingMixin.d.ts +2 -749
  78. package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +2 -44
  79. package/dist/types/textmode/mixins/TouchMixin.d.ts +2 -187
  80. package/dist/types/textmode/mixins/index.d.ts +8 -8
  81. package/dist/types/textmode/mixins/interfaces/IAnimationMixin.d.ts +167 -0
  82. package/dist/types/textmode/mixins/interfaces/IFontMixin.d.ts +46 -0
  83. package/dist/types/textmode/mixins/interfaces/IKeyboardMixin.d.ts +235 -0
  84. package/dist/types/textmode/mixins/interfaces/IMouseMixin.d.ts +457 -0
  85. package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +1124 -0
  86. package/dist/types/textmode/mixins/interfaces/ITouchMixin.d.ts +186 -0
  87. package/dist/types/textmode/types.d.ts +49 -0
  88. package/dist/types/textmode/utils/cssColor.d.ts +8 -0
  89. package/dist/types/utils/array.d.ts +34 -0
  90. package/dist/types/utils/math.d.ts +69 -0
  91. package/package.json +1 -1
  92. package/dist/types/rendering/webgl/DrawQueue.d.ts +0 -30
  93. package/dist/types/rendering/webgl/RenderPipeline.d.ts +0 -30
  94. package/dist/types/rendering/webgl/RenderState.d.ts +0 -73
  95. package/dist/types/rendering/webgl/Renderer.d.ts +0 -158
  96. package/dist/types/rendering/webgl/ShaderManager.d.ts +0 -66
  97. package/dist/types/rendering/webgl/geometries/NoiseGrid.d.ts +0 -1
  98. package/dist/types/textmode/TextmodeImage.d.ts +0 -161
  99. package/dist/types/textmode/mixins/ShaderMixin.d.ts +0 -1
  100. /package/dist/types/rendering/webgl/{StateCache.d.ts → utils/ViewportCache.d.ts} +0 -0
  101. /package/dist/types/textmode/{font → loadables/font}/MetricsCalculator.d.ts +0 -0
  102. /package/dist/types/textmode/{font → loadables/font}/index.d.ts +0 -0
  103. /package/dist/types/textmode/{font → loadables/font}/types.d.ts +0 -0
  104. /package/dist/types/textmode/{font → loadables/font}/typr/Typr.d.ts +0 -0
  105. /package/dist/types/textmode/{font → loadables/font}/utils/FontTableReader.d.ts +0 -0
  106. /package/dist/types/textmode/{font → loadables/font}/utils/index.d.ts +0 -0
@@ -0,0 +1,6 @@
1
+ export { LoadingScreenManager } from './LoadingScreenManager';
2
+ export { LoadingPhaseTracker } from './LoadingPhaseTracker';
3
+ export { LoadingScreenStateMachine } from './LoadingScreenState';
4
+ export { LoadingScreenTransition } from './LoadingScreenTransition';
5
+ export { $resolveTheme as resolveTheme, $resolveDefaultPalette as resolveDefaultPalette, $resolveColorInputs as resolveColorInputs } from './LoadingScreenTheme';
6
+ export type { LoadingPhaseSnapshot, LoadingScreenOptions, LoadingScreenRendererContext, LoadingPhaseHandle, LoadingScreenTheme, LoadingScreenState } from './types';
@@ -0,0 +1,2 @@
1
+ import type { LoadingScreenRendererContext } from '../types';
2
+ export declare const spinnerTemplate: (context: LoadingScreenRendererContext) => void;
@@ -0,0 +1 @@
1
+ export { spinnerTemplate } from './SpinnerTemplate';
@@ -0,0 +1,251 @@
1
+ import type { TextmodeGrid } from '../Grid';
2
+ import type { Textmodifier } from '../Textmodifier';
3
+ import type { TextmodeColor } from '../TextmodeColor';
4
+ /**
5
+ * Snapshot of a loading phase's state.
6
+ */
7
+ export interface LoadingPhaseSnapshot {
8
+ /** The unique identifier of the loading phase. */
9
+ id: string;
10
+ /** The label or name of the loading phase. */
11
+ label: string;
12
+ /**
13
+ * The weight of this phase for calculating overall progress.
14
+ */
15
+ weight: number;
16
+ /** The progress of the loading phase, represented as a number between 0 and 1. */
17
+ progress: number;
18
+ /** The current status of the loading phase. */
19
+ status: 'pending' | 'running' | 'complete' | 'failed';
20
+ }
21
+ /**
22
+ * Options for configuring the loading screen.
23
+ *
24
+ * @example
25
+ * ```js
26
+ * const tm = textmode.create({
27
+ * width: 800,
28
+ * height: 600,
29
+ * loadingScreen: {
30
+ * message: 'booting...',
31
+ * }
32
+ * });
33
+ * ```
34
+ */
35
+ export interface LoadingScreenOptions {
36
+ /**
37
+ * Message to display on the loading screen. Default is `'loading...'`.
38
+ */
39
+ message?: string;
40
+ /**
41
+ * Color tone of the loading screen. Can be 'auto', 'light', or 'dark'. Default is 'auto'.
42
+ * <br/><br/>
43
+ * Based on the background color the `textmode.js` canvas is rendered on, the loading screen
44
+ * will automatically choose a light or dark theme when set to `'auto'`.
45
+ */
46
+ tone?: 'auto' | 'light' | 'dark';
47
+ /**
48
+ * Provides a custom renderer function for the loading screen,
49
+ * overriding the default loading screen. The `context` parameter is a {@link LoadingScreenRendererContext} object.
50
+ */
51
+ renderer?: (context: LoadingScreenRendererContext) => void;
52
+ /**
53
+ * Type of transition effect. Default is `'fade'`.
54
+ */
55
+ transition?: 'none' | 'fade';
56
+ /**
57
+ * Duration of the transition effect in milliseconds. Default is `500`ms.
58
+ */
59
+ transitionDuration?: number;
60
+ }
61
+ /**
62
+ * Context object passed to a loading screen renderer function.
63
+ *
64
+ * Can be used to create a custom loading screen to fit your needs.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const t = textmode.create({
69
+ * width: 800,
70
+ * height: 600,
71
+ * loadingScreen: {
72
+ * message: 'loading...',
73
+ * renderer: (ctx) => {
74
+ * const { textmodifier: tm, grid, progress, message, transitionOpacity } = ctx;
75
+ *
76
+ * // Clear the screen
77
+ * tm.background(0, 0, 0, Math.floor(transitionOpacity * 255));
78
+ *
79
+ * // Position at top-left corner
80
+ * const x = -Math.floor(grid.cols / 2) + 2;
81
+ * const y = -Math.floor(grid.rows / 2) + 2;
82
+ *
83
+ * tm.push();
84
+ * tm.translate(x, y, 0);
85
+ * tm.charColor(255, 255, 255, transitionOpacity * 255);
86
+ *
87
+ * // Display message
88
+ * if (message) {
89
+ * for (let i = 0; i < message.length; i++) {
90
+ * tm.char(message[i]);
91
+ * tm.rect(1, 1);
92
+ * tm.translateX(1);
93
+ * }
94
+ * }
95
+ *
96
+ * // Display progress bar
97
+ * tm.translate(-message.length, 2, 0);
98
+ * const barWidth = 20;
99
+ * const filled = Math.floor(progress * barWidth);
100
+ *
101
+ * for (let i = 0; i < barWidth; i++) {
102
+ * tm.char(i < filled ? '=' : '-');
103
+ * tm.rect(1, 1);
104
+ * tm.translateX(1);
105
+ * }
106
+ *
107
+ * tm.pop();
108
+ * }
109
+ * }
110
+ * });
111
+ * ```
112
+ */
113
+ export interface LoadingScreenRendererContext {
114
+ /** The Textmodifier instance for rendering text and graphics. */
115
+ textmodifier: Textmodifier;
116
+ /** The TextmodeGrid representing the screen grid. */
117
+ grid: TextmodeGrid;
118
+ /** The current loading progress (0-1). */
119
+ progress: number;
120
+ /** The elapsed time since the loading started, in milliseconds. */
121
+ elapsedMs: number;
122
+ /** The number of frames rendered since the loading started. */
123
+ frameCount: number;
124
+ /** The current loading message, if any. */
125
+ message?: string;
126
+ /** The palette of colors available for rendering based on the `theme`. */
127
+ palette: TextmodeColor[];
128
+ /** The current theme of the loading screen. */
129
+ theme: LoadingScreenTheme;
130
+ /** The phases of the loading process. */
131
+ phases: LoadingPhaseSnapshot[];
132
+ /** The opacity level for transition effects. */
133
+ transitionOpacity: number;
134
+ /** Indicates if the loading screen is in an error state. */
135
+ isError: boolean;
136
+ /** The error message to display, if any. */
137
+ errorMessage?: string;
138
+ /** Detailed error information, if any. */
139
+ errorDetails?: string;
140
+ }
141
+ /**
142
+ * A function that renders the loading screen.
143
+ */
144
+ export type LoadingScreenRenderer = (context: LoadingScreenRendererContext) => void;
145
+ /**
146
+ * Handle for managing a loading phase.
147
+ */
148
+ export interface LoadingPhaseHandle {
149
+ /**
150
+ * The unique identifier of the loading phase.
151
+ */
152
+ id: string;
153
+ /**
154
+ * The label or name of the loading phase.
155
+ */
156
+ label: string;
157
+ /**
158
+ * Update the progress of the loading phase.
159
+ * @param progress A number between 0 and 1 representing the phase's progress.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * const t = textmode.create({ width: 800, height: 600, loadingScreen: { message: 'prepping...' } });
164
+ *
165
+ * // Create a phase and report progress as work proceeds
166
+ * t.setup(async () => {
167
+ * const phase = t.loading.beginPhase('assets', 1);
168
+ * phase.report(0.25);
169
+ * // ...load assets...
170
+ * phase.report(0.75);
171
+ * phase.complete();
172
+ * });
173
+ * ```
174
+ */
175
+ report(progress: number): void;
176
+ /**
177
+ * Mark the loading phase as complete.
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * const t = textmode.create({ width: 800, height: 600, loadingScreen: { message: 'prepping...' } });
182
+ *
183
+ * t.setup(() => {
184
+ * const phase = t.loading.beginPhase('init', 1);
185
+ * // Finish phase when work is done
186
+ * phase.complete();
187
+ * });
188
+ * ```
189
+ */
190
+ complete(): void;
191
+ /**
192
+ * Mark the loading phase as failed.
193
+ * @param error An optional error object describing the failure.
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * const t = textmode.create({ width: 800, height: 600 });
198
+ *
199
+ * t.setup(async () => {
200
+ * const phase = t.loading.beginPhase('fetch', 1);
201
+ * try {
202
+ * // simulate failure
203
+ * throw new Error('network error');
204
+ * } catch (err) {
205
+ * phase.fail(err instanceof Error ? err : String(err));
206
+ * }
207
+ * });
208
+ * ```
209
+ */
210
+ fail(error?: Error): void;
211
+ /**
212
+ * Track a task within this loading phase.
213
+ * @param task A promise or function representing the task to track.
214
+ * @returns A promise that resolves with the task's result.
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * const t = textmode.create({ width: 800, height: 600, loadingScreen: { message: 'loading...' } });
219
+ *
220
+ * t.setup(async () => {
221
+ * const phase = t.loading.beginPhase('video', 2);
222
+ * await phase.track(async () => {
223
+ * // do async work and report updates
224
+ * for (let i = 0; i <= 10; i++) {
225
+ * phase.report(i / 10);
226
+ * await new Promise((r) => setTimeout(r, 30));
227
+ * }
228
+ * });
229
+ * });
230
+ * ```
231
+ */
232
+ track<T>(task: Promise<T> | (() => Promise<T> | T)): Promise<T>;
233
+ }
234
+ /**
235
+ * Theme settings for the loading screen.
236
+ */
237
+ export interface LoadingScreenTheme {
238
+ /** The color mode of the loading screen, either 'light' or 'dark'. */
239
+ mode: 'light' | 'dark';
240
+ /** The background color of the loading screen, or null for transparent. */
241
+ background: [number, number, number, number] | null;
242
+ /** The primary text color used on the loading screen. */
243
+ textColor: number | string | TextmodeColor;
244
+ /** The subtle text color used on the loading screen. */
245
+ subtleColor: number | string | TextmodeColor;
246
+ }
247
+ /**
248
+ * The state of the loading screen.
249
+ * @ignore
250
+ */
251
+ export type LoadingScreenState = 'disabled' | 'active' | 'done' | 'transitioning' | 'error';
@@ -39,7 +39,7 @@ export interface KeyState {
39
39
  * Manages all keyboard interaction for a Textmodifier instance.
40
40
  * Handles event listeners, key state tracking, and event dispatching.
41
41
  *
42
- * Provides p5.js-like keyboard functionality including:
42
+ * Provides keyboard functionality including:
43
43
  * - keyPressed() and keyReleased() callbacks
44
44
  * - Current key state tracking
45
45
  * - Special key handling (arrows, function keys, etc.)
@@ -56,7 +56,6 @@ export declare class KeyboardManager {
56
56
  private _keyPressedCallback?;
57
57
  private _keyReleasedCallback?;
58
58
  private readonly _specialKeyMap;
59
- constructor();
60
59
  /**
61
60
  * Setup keyboard event listeners.
62
61
  */
@@ -119,7 +118,7 @@ export declare class KeyboardManager {
119
118
  */
120
119
  private _handleKeyUp;
121
120
  /**
122
- * Normalize key names for consistency (map to p5.js-like constants where applicable)
121
+ * Normalize key names for consistency
123
122
  */
124
123
  private _normalizeKey;
125
124
  }
@@ -89,7 +89,7 @@ export declare class MouseManager {
89
89
  * This is useful when grid dimensions change (font size, window resize, etc.)
90
90
  * and we need to recalculate the mouse coordinates without waiting for a mouse event.
91
91
  */
92
- $updatePosition(): void;
92
+ $updatePositions(): void;
93
93
  /**
94
94
  * Set a callback function that will be called when the mouse is clicked.
95
95
  * @param callback The function to call when the mouse is clicked
@@ -1,11 +1,14 @@
1
1
  import type { Textmodifier } from '../Textmodifier';
2
- import type { GLRenderer } from '../../rendering/webgl/Renderer';
2
+ import type { GLRenderer } from '../../rendering/webgl/core/Renderer';
3
3
  import type { GLFramebuffer } from '../../rendering';
4
- import type { TextmodeFont } from '../font';
4
+ import type { TextmodeFont } from '../loadables/font';
5
5
  import type { TextmodeGrid } from '../Grid';
6
6
  import type { TextmodeCanvas } from '../Canvas';
7
7
  export type TextmodePluginHook = () => void;
8
- export interface TextmodePluginContext {
8
+ /**
9
+ * An extended API provided to plugins when they are installed on a {@link Textmodifier} instance.
10
+ */
11
+ export interface TextmodePluginAPI {
9
12
  /** The WebGL renderer used by the Textmodifier instance. */
10
13
  renderer: GLRenderer;
11
14
  /** The font used by the Textmodifier instance. */
@@ -14,23 +17,17 @@ export interface TextmodePluginContext {
14
17
  grid: TextmodeGrid;
15
18
  /** The canvas used by the Textmodifier instance. */
16
19
  canvas: TextmodeCanvas;
17
- /** The framebuffer the user draws to. */
20
+ /** The framebuffer the user draws to with 3 render targets. */
18
21
  drawFramebuffer: GLFramebuffer;
19
- /** The framebuffer containing the ASCII representation. */
22
+ /** The framebuffer containing the ASCII representation.<br/>
23
+ * This framebuffer only has a single render target. */
20
24
  asciiFramebuffer: GLFramebuffer;
21
- /** Immediately execute any pending draw commands. */
22
- flushDrawCommands(): void;
23
- }
24
- /**
25
- * An extended API provided to plugins when they are installed on a {@link Textmodifier} instance.
26
- */
27
- export interface TextmodePluginAPI extends TextmodePluginContext {
28
25
  /**
29
- * Register a callback to be invoked before each draw cycle. Happens outside of the draw framebuffer being bound.
26
+ * Register a callback to be invoked before each draw cycle. Happens just before the draw framebuffer is being bound.
30
27
  */
31
28
  registerPreDrawHook(callback: () => void): () => void;
32
29
  /**
33
- * Register a callback to be invoked after each draw cycle. Happens outside of the draw framebuffer being bound.
30
+ * Register a callback to be invoked after each draw cycle. Happens outside of the draw framebuffer being bound after the final result is drawn to the screen.
34
31
  */
35
32
  registerPostDrawHook(callback: () => void): () => void;
36
33
  }
@@ -38,6 +35,11 @@ export interface TextmodePluginAPI extends TextmodePluginContext {
38
35
  * A plugin interface for extending the functionality of a {@link Textmodifier} instance.
39
36
  *
40
37
  * Users can create plugins by implementing this interface.
38
+ *
39
+ * @note
40
+ * Plugins are currently experimental and the API may change in future releases.
41
+ * For now, it has been integrated to outsource export features to `textmode.export.js`.
42
+ * Documentation and examples will be provided as the plugin system matures.
41
43
  */
42
44
  export interface TextmodePlugin {
43
45
  /** Unique name for the plugin. */
@@ -66,8 +68,8 @@ export declare class TextmodePluginManager {
66
68
  constructor(textmodifier: Textmodifier);
67
69
  $installMany(plugins: TextmodePlugin[]): Promise<void>;
68
70
  $unuse(pluginName: string): Promise<void>;
69
- runPreDrawHooks(): void;
70
- runPostDrawHooks(): void;
71
+ $runPreDrawHooks(): void;
72
+ $runPostDrawHooks(): void;
71
73
  $disposeAll(): Promise<void>;
72
74
  private _createAPI;
73
75
  private _registerHook;
@@ -220,6 +220,4 @@ export declare class TouchManager {
220
220
  private _evaluateTapAndSwipe;
221
221
  private _detectDoubleTap;
222
222
  private _cloneTouchPosition;
223
- private _distance;
224
- private _angle;
225
223
  }
@@ -1,128 +1,8 @@
1
1
  import type { Mixin } from './TextmodifierMixin';
2
- /**
3
- * Interface for animation capabilities that will be mixed into Textmodifier
4
- */
5
- export interface AnimationCapabilities {
6
- /**
7
- * Set the maximum frame rate. If called without arguments, returns the current measured frame rate.
8
- * @param fps The maximum frames per second for rendering.
9
- *
10
- * @example
11
- * ```javascript
12
- * // Create a Textmodifier instance
13
- * const textmodifier = textmode.create();
14
- *
15
- * // Set the maximum frame rate to 30 FPS
16
- * textmodifier.frameRate(30);
17
- * ```
18
- */
19
- frameRate(fps?: number): number | void;
20
- /**
21
- * Stop the automatic rendering loop.
22
- *
23
- * This method pauses the render loop without, allowing
24
- * it to be resumed later with {@link loop}. This is useful for temporarily pausing
25
- * animation while maintaining the ability to continue it.
26
- *
27
- * @example
28
- * ```javascript
29
- * // Create a textmodifier instance in auto mode
30
- * const textmodifier = textmode.create();
31
- *
32
- * // The render loop is running by default
33
- * console.log(textmodifier.isLooping()); // true
34
- *
35
- * // Stop the automatic rendering loop
36
- * textmodifier.noLoop();
37
- * console.log(textmodifier.isLooping()); // false
38
- *
39
- * // Resume the rendering loop
40
- * textmodifier.loop();
41
- * console.log(textmodifier.isLooping()); // true
42
- * ```
43
- */
44
- noLoop(): void;
45
- /**
46
- * Resume the rendering loop if it was stopped by {@link noLoop}.
47
- *
48
- * @example
49
- * ```javascript
50
- * // Create a textmodifier instance
51
- * const textmodifier = textmode.create();
52
- *
53
- * // Stop the loop
54
- * textmodifier.noLoop();
55
- *
56
- * // Resume the loop
57
- * textmodifier.loop();
58
- *
59
- * // You can also use this pattern for conditional animation
60
- * if (someCondition) {
61
- * textmodifier.loop();
62
- * } else {
63
- * textmodifier.noLoop();
64
- * }
65
- * ```
66
- */
67
- loop(): void;
68
- /**
69
- * Execute the render function a specified number of times.
70
- *
71
- * This method is useful when the render loop has been stopped with {@link noLoop},
72
- * allowing you to trigger rendering on demand.
73
- *
74
- * @param n The number of times to execute the render function. Defaults to 1.
75
- *
76
- * @example
77
- * ```javascript
78
- * // Create a textmodifier instance
79
- * const textmodifier = textmode.create();
80
- *
81
- * // Set up drawing
82
- * textmodifier.draw(() => {
83
- * textmodifier.background(0);
84
- *
85
- * textmodifier.char("A");
86
- * textmodifier.charColor(255, 0, 0);
87
- * textmodifier.rect(10, 10, 50, 50);
88
- * });
89
- *
90
- * textmodifier.noLoop();
91
- * textmodifier.redraw(3); // Render 3 times despite loop being stopped
92
- * ```
93
- */
94
- redraw(n?: number): void;
95
- /**
96
- * Check whether the textmodifier is currently running the automatic render loop.
97
- * @returns True if the render loop is currently active, false otherwise.
98
- *
99
- * @example
100
- * ```javascript
101
- * const textmodifier = textmode.create(canvas);
102
- *
103
- * // Check loop status in different states
104
- * console.log(textmodifier.isLooping()); // true (looping)
105
- *
106
- * textmodifier.noLoop();
107
- * console.log(textmodifier.isLooping()); // false (not looping)
108
- *
109
- * textmodifier.loop();
110
- * console.log(textmodifier.isLooping()); // true (alooping)
111
- * ```
112
- */
113
- isLooping(): boolean;
114
- /**
115
- * Get the current frame count.
116
- */
117
- get frameCount(): number;
118
- /**
119
- * Set the current frame count.
120
- */
121
- set frameCount(value: number);
122
- }
2
+ import type { IAnimationMixin } from './interfaces/IAnimationMixin';
123
3
  /**
124
4
  * Mixin that adds animation capabilities to a class
125
5
  * @param Base The base class to extend
126
6
  * @returns Extended class with animation capabilities
127
7
  */
128
- export declare const AnimationMixin: Mixin<AnimationCapabilities>;
8
+ export declare const AnimationMixin: Mixin<IAnimationMixin>;
@@ -1,83 +1,8 @@
1
1
  import type { Mixin } from './TextmodifierMixin';
2
- /**
3
- * Interface for font capabilities that will be mixed into Textmodifier
4
- */
5
- export interface FontCapabilities {
6
- /**
7
- * Update the font used for rendering.
8
- * @param fontSource The URL of the font to load.
9
- *
10
- * @example
11
- * ```javascript
12
- * // Create a Textmodifier instance
13
- * const textmodifier = textmode.create();
14
- *
15
- * // Load a custom font from a URL
16
- * await textmodifier.loadFont('https://example.com/fonts/myfont.ttf');
17
- *
18
- * // Local font example
19
- * // await textmodifier.loadFont('./fonts/myfont.ttf');
20
- * ```
21
- */
22
- loadFont(fontSource: string): Promise<void>;
23
- /**
24
- * Set the font size used for rendering.
25
- * @param size The font size to set.
26
- *
27
- * @example
28
- * ```javascript
29
- * // Create a Textmodifier instance
30
- * const textmodifier = textmode.create();
31
- *
32
- * // Set the font size to 32
33
- * textmodifier.fontSize(32);
34
- * ```
35
- */
36
- fontSize(size: number): void;
37
- /**
38
- * Get the RGB shader color of a specific character in the current font.
39
- *
40
- * Useful for custom shaders to control the character to render.
41
- *
42
- * @param char The character to get the color for.
43
- * @returns An array representing the RGB color, or null if the character is not found.
44
- * @example
45
- * ```javascript
46
- * // Create a Textmodifier instance
47
- * const textmodifier = textmode.create();
48
- *
49
- * // Get the color of the character 'A'
50
- * textmodifier.setup(() => {
51
- * const color = textmodifier.glyphColor('A');
52
- * console.log(color); // e.g., [1, 0, 0] for red
53
- * });
54
- * ```
55
- */
56
- glyphColor(char: string): [number, number, number] | null;
57
- /**
58
- * Get the RGB shader colors of all characters in a string for the current font.
59
- *
60
- * Useful for custom shaders to control the characters to render.
61
- *
62
- * @param str The string to get the colors for.
63
- * @returns An array of RGB color arrays, or null if a character is not found.
64
- * @example
65
- * ```javascript
66
- * // Create a Textmodifier instance
67
- * const textmodifier = textmode.create();
68
- *
69
- * // Get the colors of the string 'Hello'
70
- * textmodifier.setup(() => {
71
- * const colors = textmodifier.glyphColors('Hello');
72
- * console.log(colors); // e.g., [[0.1, 0, 0], ...]
73
- * });
74
- * ```
75
- */
76
- glyphColors(str: string): ([number, number, number] | null)[];
77
- }
2
+ import type { IFontMixin } from './interfaces/IFontMixin';
78
3
  /**
79
4
  * Mixin that adds font capabilities to a class
80
5
  * @param Base The base class to extend
81
6
  * @returns Extended class with font capabilities
82
7
  */
83
- export declare const FontMixin: Mixin<FontCapabilities>;
8
+ export declare const FontMixin: Mixin<IFontMixin>;
@@ -1,95 +1,13 @@
1
1
  import type { Mixin } from './TextmodifierMixin';
2
- import type { KeyboardEventHandler } from '../managers/KeyboardManager';
3
- /**
4
- * Capabilities provided by the KeyboardMixin
5
- */
6
- export interface KeyboardCapabilities {
7
- /**
8
- * Check if a specific key is currently being pressed.
9
- *
10
- * @param key The key to check (e.g., 'a', 'Enter', 'ArrowLeft')
11
- * @returns true if the key is currently pressed, false otherwise
12
- *
13
- * @example
14
- * ```javascript
15
- * const t = textmode.create({ width: 800, height: 600 });
16
- *
17
- * let playerX = 0;
18
- * let playerY = 0;
19
- *
20
- * t.draw(() => {
21
- * t.background(0);
22
- *
23
- * // Check for arrow keys to move a character
24
- * if (t.isKeyPressed('ArrowUp')) {
25
- * playerY -= 1;
26
- * }
27
- * if (t.isKeyPressed('ArrowDown')) {
28
- * playerY += 1;
29
- * }
30
- * if (t.isKeyPressed('ArrowLeft')) {
31
- * playerX -= 1;
32
- * }
33
- * if (t.isKeyPressed('ArrowRight')) {
34
- * playerX += 1;
35
- * }
36
- *
37
- * // Draw player character
38
- * t.char('@');
39
- * t.charColor(255, 255, 0);
40
- * t.point(playerX, playerY);
41
- * });
42
- * ```
43
- */
44
- isKeyPressed(key: string): boolean;
45
- /**
46
- * Set a callback function that will be called when a key is pressed down.
47
- *
48
- * @param callback The function to call when a key is pressed
49
- *
50
- * @example
51
- * ```javascript
52
- * const t = textmode.create({ width: 800, height: 600 });
53
- *
54
- * t.keyPressed((data) => {
55
- * console.log(`Key pressed: ${data.key}`);
56
- * if (data.key === 'Enter') {
57
- * console.log('Enter key was pressed!');
58
- * }
59
- * if (data.ctrlKey && data.key === 's') {
60
- * console.log('Ctrl+S was pressed!');
61
- * }
62
- * });
63
- * ```
64
- */
65
- keyPressed(callback: KeyboardEventHandler): void;
66
- /**
67
- * Set a callback function that will be called when a key is released.
68
- *
69
- * @param callback The function to call when a key is released
70
- *
71
- * @example
72
- * ```javascript
73
- * const t = textmode.create({ width: 800, height: 600 });
74
- *
75
- * t.keyReleased((data) => {
76
- * console.log(`Key released: ${data.key}`);
77
- * if (data.key === ' ') {
78
- * console.log('Spacebar was released!');
79
- * }
80
- * });
81
- * ```
82
- */
83
- keyReleased(callback: KeyboardEventHandler): void;
84
- }
2
+ import type { IKeyboardMixin } from './interfaces/IKeyboardMixin';
85
3
  /**
86
4
  * Mixin that adds keyboard interaction capabilities to Textmodifier.
87
5
  *
88
6
  * This is a thin wrapper around KeyboardManager that provides the public API
89
7
  * for keyboard interaction. All the actual implementation is handled by the
90
- * KeyboardManager instance in the TextmodifierContext.
8
+ * KeyboardManager instance in the ITextmodifier.
91
9
  *
92
10
  * Provides p5.js-like keyboard functionality including key state tracking,
93
11
  * event callbacks, and special key handling.
94
12
  */
95
- export declare const KeyboardMixin: Mixin<KeyboardCapabilities>;
13
+ export declare const KeyboardMixin: Mixin<IKeyboardMixin>;