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
@@ -3,7 +3,6 @@
3
3
  * Provides precise frame rate limiting and smooth animation timing.
4
4
  */
5
5
  export declare class AnimationController {
6
- private _frameRateLimit;
7
6
  private _frameInterval;
8
7
  private _animationFrameId;
9
8
  private _lastFrameTime;
@@ -22,60 +21,51 @@ export declare class AnimationController {
22
21
  * Start the animation loop with the provided render callback.
23
22
  * @param renderCallback Function to call for each frame render
24
23
  */
25
- start(renderCallback: () => void): void;
24
+ $start(renderCallback: () => void): void;
26
25
  /**
27
26
  * Stop the animation loop.
28
27
  */
29
- stop(): void;
28
+ $stop(): void;
30
29
  /**
31
30
  * Pause the animation loop without stopping it completely.
32
31
  */
33
- pause(): void;
32
+ $pause(): void;
34
33
  /**
35
34
  * Resume the animation loop if it was paused.
36
35
  * @param renderCallback Function to call for each frame render
37
36
  */
38
- resume(renderCallback: () => void): void;
37
+ $resume(renderCallback: () => void): void;
39
38
  /**
40
39
  * Set or get the frame rate limit.
41
40
  * @param fps Optional new frame rate limit. If not provided, returns current measured frame rate.
42
41
  * @param renderCallback Required when setting new frame rate and animation is running
43
42
  * @returns Current measured frame rate when getting, void when setting
44
43
  */
45
- frameRate(fps?: number, renderCallback?: () => void): number | void;
44
+ $frameRate(fps?: number, renderCallback?: () => void): number | void;
46
45
  /**
47
46
  * Update frame rate measurement. Should be called on each render.
48
47
  * Uses a rolling average for smoother frame rate reporting.
49
48
  */
50
- measureFrameRate(): void;
49
+ $measureFrameRate(): void;
51
50
  /**
52
51
  * Check if the animation loop is currently active.
53
52
  */
54
- get isLooping(): boolean;
55
- /**
56
- * Get the current frame rate limit.
57
- */
58
- get frameRateLimit(): number;
53
+ get $isLooping(): boolean;
59
54
  /**
60
55
  * Get the current measured frame rate.
61
56
  */
62
- get currentFrameRate(): number;
57
+ get $currentFrameRate(): number;
63
58
  /**
64
59
  * Get the current frame count.
65
60
  */
66
- get frameCount(): number;
61
+ get $frameCount(): number;
67
62
  /**
68
63
  * Set the current frame count.
69
64
  */
70
- set frameCount(value: number);
65
+ set $frameCount(value: number);
71
66
  /**
72
67
  * Increment the frame count by one.
73
68
  * Should be called on each render to track total frames rendered.
74
69
  */
75
- incrementFrame(): void;
76
- /**
77
- * Reset the frame count to zero.
78
- * Useful when restarting animations or resetting state.
79
- */
80
- resetFrameCount(): void;
70
+ $incrementFrame(): void;
81
71
  }
@@ -1,4 +1,5 @@
1
- import type { TextmodeOptions } from "./Textmodifier";
1
+ import type { TextmodeOptions } from "./types";
2
+ import { type RGBA } from "./utils/cssColor";
2
3
  /**
3
4
  * Manages a `HTMLCanvasElement` for textmode rendering.
4
5
  * @ignore
@@ -7,7 +8,6 @@ export declare class TextmodeCanvas {
7
8
  private _canvas;
8
9
  private _targetCanvas;
9
10
  private _isOverlay;
10
- private _resizeObserver?;
11
11
  private _canvasCreatedByUs;
12
12
  /**
13
13
  * Creates a new TextmodeCanvas instance.
@@ -18,6 +18,13 @@ export declare class TextmodeCanvas {
18
18
  private _createCanvas;
19
19
  private _createOverlayCanvas;
20
20
  private _setupOverlayPositioning;
21
+ private _collectBackgroundSources;
22
+ /**
23
+ * Attempts to detect the background color behind the textmode canvas.
24
+ * Used internally for theming transparent UI elements like the loading screen.
25
+ * @ignore
26
+ */
27
+ $sampleBackgroundColor(): RGBA | null;
21
28
  private _positionOverlayCanvas;
22
29
  /**
23
30
  * Resize the canvas to the specified width and height.
@@ -38,6 +45,7 @@ export declare class TextmodeCanvas {
38
45
  * @ignore
39
46
  */
40
47
  $dispose(): void;
48
+ /** Getters */
41
49
  get canvas(): HTMLCanvasElement;
42
50
  get targetCanvas(): HTMLCanvasElement | HTMLVideoElement | null;
43
51
  get width(): number;
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * Manages the grid of a {@link Textmodifier} instance.
3
+ *
4
+ * Can be accessed via {@link Textmodifier.grid}.
3
5
  */
4
6
  export declare class TextmodeGrid {
5
7
  /** The number of columns in the grid. */
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Represents a color in the `textmode.js` rendering system.
3
+ *
4
+ * Values are stored as `0-255` integers for compatibility with public APIs,
5
+ * while normalized versions are derived on demand for shader uploads.
6
+ *
7
+ * Use {@link Textmodifier.color} to create colors.
8
+ */
9
+ export declare class TextmodeColor {
10
+ private readonly _rgba;
11
+ private readonly _normalized;
12
+ private readonly _character?;
13
+ /** Red component *(0-255)* */
14
+ readonly r: number;
15
+ /** Green component *(0-255)* */
16
+ readonly g: number;
17
+ /** Blue component *(0-255)* */
18
+ readonly b: number;
19
+ /** Alpha component *(0-255)* */
20
+ readonly a: number;
21
+ private constructor();
22
+ /**
23
+ * Create a color from RGB or RGBA components (0-255 range).
24
+ * @ignore
25
+ */
26
+ static $fromRGBA(r: number, g: number, b: number, a?: number): TextmodeColor;
27
+ /**
28
+ * Create a grayscale color. Optional alpha can be provided.
29
+ * @ignore
30
+ */
31
+ static $fromGray(gray: number, alpha?: number): TextmodeColor;
32
+ /**
33
+ * Create a color from a CSS-style hex string.
34
+ * @ignore
35
+ */
36
+ static $fromHex(hex: string): TextmodeColor;
37
+ /**
38
+ * Create a color representing a textmode character encoded as RGB triplet
39
+ * (values already normalized 0-1 for shader usage).
40
+ * @ignore
41
+ */
42
+ static $fromCharacter(characterColor: [number, number, number]): TextmodeColor;
43
+ /** Returns a plain RGB array with integer components. */
44
+ get rgb(): [number, number, number];
45
+ /** Returns a plain RGBA array with integer components. */
46
+ get rgba(): [number, number, number, number];
47
+ /** Returns the normalized *(0-1)* RGBA array. */
48
+ get normalized(): [number, number, number, number];
49
+ /** Returns the character encoding *(0-1 range)* if this color was created from a glyph. */
50
+ get character(): [number, number, number] | undefined;
51
+ /**
52
+ * Runtime type guard.
53
+ * @ignore
54
+ */
55
+ static $isColor(value: unknown): value is TextmodeColor;
56
+ }
57
+ export type ColorLike = TextmodeColor | [number, number, number] | [number, number, number, number];
@@ -1,70 +1,34 @@
1
- import { GLRenderer } from '../rendering/webgl/Renderer';
2
- import { TextmodeFont } from './font';
1
+ import { GLRenderer } from '../rendering/webgl/core/Renderer';
2
+ import { TextmodeFont } from './loadables/font';
3
3
  import { TextmodeGrid } from './Grid';
4
4
  import { TextmodeCanvas } from './Canvas';
5
- import { TextmodeImage } from './TextmodeImage';
5
+ import { TextmodeImage } from './loadables/TextmodeImage';
6
6
  import { AnimationController } from './AnimationController';
7
7
  import { MouseManager } from './managers/MouseManager';
8
8
  import { KeyboardManager } from './managers/KeyboardManager';
9
9
  import { TouchManager } from './managers/TouchManager';
10
- import { type TextmodifierContext } from './mixins';
11
- import { type TextmodePlugin, type TextmodePluginContext } from './plugins/PluginManager';
12
- import type { RenderingCapabilities } from './mixins/RenderingMixin';
13
- import type { FontCapabilities } from './mixins/FontMixin';
14
- import type { AnimationCapabilities } from './mixins/AnimationMixin';
15
- import type { MouseCapabilities } from './mixins/MouseMixin';
16
- import type { TouchCapabilities } from './mixins/TouchMixin';
17
- import type { KeyboardCapabilities } from './mixins/KeyboardMixin';
10
+ import type { ITextmodifier } from './interfaces';
18
11
  import type { GLFramebuffer, Shader } from '../rendering';
19
- /**
20
- * Options for creating a {@link Textmodifier} instance.
21
- */
22
- export type TextmodeOptions = {
23
- /**
24
- * An existing [HTMLCanvasElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement) to use instead of creating a new one.
25
- *
26
- * **Note:**
27
- * If using `overlay` mode, this should be the target canvas or video element to overlay on.
28
- * `textmode.js` will create its own canvas applied on top of the target element, always matching its size and position.
29
- */
30
- canvas?: HTMLCanvasElement;
31
- /** The font size to use for text rendering. Defaults to 16. */
32
- fontSize?: number;
33
- /** Maximum frames per second for auto rendering. Defaults to 60. */
34
- frameRate?: number;
35
- /** The width of the canvas when creating a new canvas. Defaults to 800. */
36
- width?: number;
37
- /** The height of the canvas when creating a new canvas. Defaults to 600. */
38
- height?: number;
39
- /**
40
- * URL or path to a custom font file *(.otf/.ttf)*.
41
- *
42
- * Required when using minified builds that don't include a default font.
43
- *
44
- * Optional for full builds *(will override embedded font if provided)*.
45
- */
46
- fontSource?: string;
47
- /**
48
- * Use `textmode.js` in overlay mode,
49
- * which sets up the textmode `<canvas>` on top of an existing HTMLCanvasElement or HTMLVideoElement,
50
- * automatically resizing and positioning it to match the target element.
51
- *
52
- * In this mode `textmode.js` fetches the content of the target element and applies it with adjustable textmode conversion
53
- * as a first layer to the textmode canvas.
54
- *
55
- * Useful for applying textmode conversion to p5.js sketches, YouTube videos, and sooo much more.
56
- *
57
- * All functionality of `textmode.js` remains available, including drawing additional content on top of the converted source.
58
- *
59
- */
60
- overlay?: boolean;
61
- /** List of plugins to install when the Textmodifier instance is created. */
62
- plugins?: TextmodePlugin[];
12
+ import type { TextmodeOptions } from './types';
13
+ import type { IAnimationMixin } from './mixins/interfaces/IAnimationMixin';
14
+ import type { IFontMixin } from './mixins/interfaces/IFontMixin';
15
+ import type { IRenderingMixin } from './mixins/interfaces/IRenderingMixin';
16
+ import type { IKeyboardMixin } from './mixins/interfaces/IKeyboardMixin';
17
+ import type { ITouchMixin } from './mixins/interfaces/ITouchMixin';
18
+ import type { IMouseMixin } from './mixins/interfaces/IMouseMixin';
19
+ import { LoadingScreenManager } from './loading/LoadingScreenManager';
20
+ declare const Textmodifier_base: {
21
+ new (): {};
63
22
  };
64
23
  /**
65
- * Base class for mixin application.
24
+ * Manages textmode rendering on a [`HTMLCanvasElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement) and provides methods for drawing,
25
+ * font management, event handling, and animation control.
26
+ *
27
+ * If the `Textmodifier` instance is created without a canvas parameter,
28
+ * it creates a new `HTMLCanvasElement` to draw on using the `textmode.js` drawing API.
29
+ * If a canvas is provided, it will use that canvas instead.
66
30
  */
67
- declare class TextmodifierCore implements TextmodifierContext {
31
+ export declare class Textmodifier extends Textmodifier_base implements ITextmodifier {
68
32
  _renderer: GLRenderer;
69
33
  _font: TextmodeFont;
70
34
  _canvas: TextmodeCanvas;
@@ -73,27 +37,16 @@ declare class TextmodifierCore implements TextmodifierContext {
73
37
  _mouseManager: MouseManager;
74
38
  _touchManager: TouchManager;
75
39
  _keyboardManager: KeyboardManager;
76
- _textmodeDrawShader: Shader;
40
+ _loading: LoadingScreenManager;
77
41
  _textmodeDrawFramebuffer: GLFramebuffer;
78
42
  _textmodeConversionShader: Shader;
79
- _asciiColorFramebuffer: GLFramebuffer;
43
+ _textmodeFramebuffer: GLFramebuffer;
80
44
  _presentShader: Shader;
81
- $render(): void;
82
- }
83
- declare const Textmodifier_base: typeof TextmodifierCore;
84
- /**
85
- * Manages textmode rendering on a [`HTMLCanvasElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement) and provides methods for drawing,
86
- * exporting, font management, event handling, and animation control.
87
- *
88
- * If the `Textmodifier` instance is created without a canvas parameter,
89
- * it creates a new `HTMLCanvasElement` to draw on using the `textmode.js` drawing API.
90
- * If a canvas is provided, it will use that canvas instead.
91
- */
92
- export declare class Textmodifier extends Textmodifier_base {
93
45
  private _pluginManager;
94
46
  private _destroyRequested;
95
47
  private _isRenderingFrame;
96
48
  private _isDisposed;
49
+ private _setupComplete;
97
50
  private _setupCallback;
98
51
  private _drawCallback;
99
52
  private _resizedCallback;
@@ -102,168 +55,34 @@ export declare class Textmodifier extends Textmodifier_base {
102
55
  private _isOverlay;
103
56
  private _targetCanvasImage?;
104
57
  /**
105
- * Creates an instance of Textmodifier.
106
- * @param opts Optional configuration options for the Textmodifier instance.
58
+ * Create a new Textmodifier instance.
59
+ * @param opts Configuration options for the Textmodifier instance.
107
60
  * @ignore
108
61
  */
109
62
  constructor(opts?: TextmodeOptions);
110
- /**
111
- * Internal async initialization method.
112
- * @param opts Configuration options
113
- */
114
63
  private _initialize;
115
64
  /**
116
- * Provide plugins with a minimal API surface so they can interact with the renderer safely.
117
- * @ignore
118
- */
119
- $getPluginContext(): TextmodePluginContext;
120
- /**
121
- * Setup event listeners for resize handling.
65
+ * Setup event listeners for window resize and input handling.
122
66
  * @ignore
123
67
  */
124
68
  $setupEventListeners(): void;
125
- /**
126
- * Renders the current frame.
127
- * @returns void
128
- * @ignore
129
- */
130
69
  $render(): void;
131
- /**
132
- * Set a setup callback function that will be executed once when initialization is complete.
133
- *
134
- * This callback is called after font loading and grid initialization, allowing access to
135
- * properties like `textmodifier.grid.cols` for calculating layout or setup variables.
136
- *
137
- * @param callback The function to call when setup is complete
138
- *
139
- * @example
140
- * ```javascript
141
- * const textmodifier = textmode.create({
142
- * width: 800,
143
- * height: 600,
144
- * fontSize: 16
145
- * });
146
- *
147
- * // Setup callback - called once when ready
148
- * textmodifier.setup(() => {
149
- * // Now you can access grid properties
150
- * const cols = textmodifier.grid.cols;
151
- * const rows = textmodifier.grid.rows;
152
- *
153
- * // Initialize any variables that depend on grid size
154
- * cellWidth = Math.floor(cols / 3);
155
- * cellHeight = Math.floor(rows / 2);
156
- * });
157
- *
158
- * // Draw callback - called every frame
159
- * textmodifier.draw(() => {
160
- * textmodifier.background(128);
161
- * textmodifier.rect(0, 0, cellWidth, cellHeight);
162
- * });
163
- * ```
164
- */
165
- setup(callback: () => void): void;
166
- /**
167
- * Set a draw callback function that will be executed before each render.
168
- *
169
- * This callback function is where all drawing commands should be placed for textmode rendering.
170
- *
171
- * @param callback The function to call before each render
172
- *
173
- * @example
174
- * ```javascript
175
- * // Create a standalone textmodifier instance
176
- * const t = textmode.create({
177
- * width: 800,
178
- * height: 600,
179
- * });
180
- *
181
- * // Set up draw callback
182
- * t.draw(() => {
183
- * // Set background color
184
- * t.background(128);
185
- *
186
- * // Draw a textmode rectangle with default settings
187
- * t.rect(0, 0, 16, 16);
188
- * });
189
- * ```
190
- */
191
- draw(callback: () => void): void;
192
- /**
193
- * Set a callback function that will be called when the window is resized.
194
- * @param callback The function to call when the window is resized.
195
- *
196
- * @example
197
- * ```javascript
198
- * // Create a standalone textmodifier instance
199
- * const t = textmode.create({
200
- * width: window.innerWidth,
201
- * height: window.innerHeight,
202
- * });
203
- *
204
- * // Draw callback to update content
205
- * t.draw(() => {
206
- * // Set background color
207
- * t.background(128);
208
- *
209
- * t.rect(0, 0, t.grid.cols, t.grid.rows);
210
- * });
211
- *
212
- * // Set up window resize callback
213
- * t.windowResized(() => {
214
- * // Resize the canvas to match window size
215
- * t.resizeCanvas(window.innerWidth, window.innerHeight);
216
- * });
217
- *
218
- */
219
- windowResized(callback: () => void): void;
220
- /**
221
- * Resize the canvas and adjust all related components accordingly.
222
- *
223
- * @param width The new width of the canvas.
224
- * @param height The new height of the canvas.
225
- */
226
70
  resizeCanvas(width: number, height: number): void;
227
- /**
228
- * Completely destroy this Textmodifier instance and free all associated resources.
229
- *
230
- * After calling this method, the instance should not be used and will be eligible for garbage collection.
231
- *
232
- * @example
233
- * ```javascript
234
- * // Create a textmodifier instance
235
- * const textmodifier = textmode.create();
236
- *
237
- * // ...
238
- *
239
- * // When done, completely clean up
240
- * textmodifier.destroy();
241
- *
242
- * // Instance is now safely disposed and ready for garbage collection
243
- * ```
244
- */
245
71
  destroy(): void;
246
72
  private _performDestroy;
247
- /** Get the current grid object used for rendering. */
73
+ setup(callback: () => void | Promise<void>): void;
74
+ draw(callback: () => void): void;
75
+ windowResized(callback: () => void): void;
248
76
  get grid(): TextmodeGrid;
249
- /** Get the current font object used for rendering. */
250
77
  get font(): TextmodeFont;
251
- /** Get the width of the canvas. */
252
78
  get width(): number;
253
- /** Get the height of the canvas. */
254
79
  get height(): number;
255
- /** Get the textmodifier canvas containing the rendered output. */
256
80
  get canvas(): HTMLCanvasElement;
257
- /** Get the WebGL framebuffer used for drawing operations. */
258
81
  get drawFramebuffer(): GLFramebuffer;
259
- /** Check if the instance has been disposed/destroyed. */
260
82
  get isDisposed(): boolean;
261
- /**
262
- * If in overlay mode, returns the {@link TextmodeImage} instance capturing the target canvas/video content,
263
- * allowing further configuration of the conversion parameters.
264
- */
265
83
  get overlay(): TextmodeImage | undefined;
84
+ get loading(): LoadingScreenManager;
266
85
  }
267
- export interface Textmodifier extends RenderingCapabilities, FontCapabilities, AnimationCapabilities, MouseCapabilities, TouchCapabilities, KeyboardCapabilities {
86
+ export interface Textmodifier extends IRenderingMixin, IFontMixin, IAnimationMixin, IMouseMixin, ITouchMixin, IKeyboardMixin {
268
87
  }
269
88
  export {};