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
@@ -0,0 +1,21 @@
1
+ import type { GLRenderer } from '../../rendering/webgl/core/Renderer';
2
+ import { TextmodeSource } from './TextmodeSource';
3
+ /**
4
+ * Represents an image uploaded for textmode rendering via {@link Textmodifier.loadImage}.
5
+ *
6
+ * It can be drawn to the canvas via {@link Textmodifier.image}.
7
+ *
8
+ * An image uploaded currently runs through an adjustable brightness-converter that converts
9
+ * the original image into a textmode representation using characters.
10
+ * Those adjustable options are available via chainable methods on this class.
11
+ */
12
+ export declare class TextmodeImage extends TextmodeSource {
13
+ private constructor();
14
+ /**
15
+ * Create a TextmodeImage from an HTML image/video/canvas element.
16
+ * Texture parameters use NEAREST and CLAMP to align with grid sampling.
17
+ * @ignore
18
+ */
19
+ static $fromSource(renderer: GLRenderer, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, gridCols: number, gridRows: number, glyphResolver: (s: string) => ([number, number, number])[]): TextmodeImage;
20
+ protected $getActiveTexture(): WebGLTexture;
21
+ }
@@ -0,0 +1,130 @@
1
+ import type { GLRenderer } from '../../rendering/webgl/core/Renderer';
2
+ import type { Material } from '../../rendering/webgl/materials/Material';
3
+ import { TextmodeColor } from '../TextmodeColor';
4
+ type GlyphColor = [number, number, number];
5
+ /**
6
+ * Base class for drawable textmode sources (images, videos, canvas, etc.).
7
+ * Handles shared WebGL texture state, material creation, and color/character settings.
8
+ */
9
+ export declare abstract class TextmodeSource {
10
+ protected _gl: WebGL2RenderingContext;
11
+ protected _renderer: GLRenderer;
12
+ protected _texture: WebGLTexture;
13
+ protected _originalWidth: number;
14
+ protected _originalHeight: number;
15
+ protected _width: number;
16
+ protected _height: number;
17
+ protected _material: Material | null;
18
+ protected _invert: number;
19
+ protected _flipX: number;
20
+ protected _flipY: number;
21
+ protected _charRotation: number;
22
+ protected _charColorMode: 'sampled' | 'fixed';
23
+ protected _cellColorMode: 'sampled' | 'fixed';
24
+ protected _charColor: [number, number, number, number];
25
+ protected _cellColor: [number, number, number, number];
26
+ protected _backgroundColor: [number, number, number, number];
27
+ protected _glyphColors: GlyphColor[];
28
+ protected _glyphColorResolver: (s: string) => GlyphColor[];
29
+ private static _sharedShader;
30
+ protected constructor(gl: WebGL2RenderingContext, renderer: GLRenderer, texture: WebGLTexture, originalWidth: number, originalHeight: number, width: number, height: number);
31
+ /**
32
+ * Dispose of the underlying WebGL texture. Subclasses may extend for additional cleanup.
33
+ * @ignore
34
+ */
35
+ dispose(): void;
36
+ /**
37
+ * Set the invert flag, swapping character and cell colors when enabled.
38
+ * @param v Invert flag
39
+ * @returns This instance for chaining.
40
+ */
41
+ invert(v?: boolean | number): this;
42
+ /**
43
+ * Set horizontal flip indicator flag.
44
+ * @param v Flip flag
45
+ * @returns This instance for chaining.
46
+ */
47
+ flipX(v?: boolean | number): this;
48
+ /**
49
+ * Set vertical flip indicator flag.
50
+ * @param v Flip flag
51
+ * @returns This instance for chaining.
52
+ */
53
+ flipY(v?: boolean | number): this;
54
+ /**
55
+ * Set the character rotation in degrees (0-360).
56
+ * @param degrees Rotation in degrees
57
+ * @returns This instance for chaining.
58
+ */
59
+ charRotation(degrees: number): this;
60
+ /**
61
+ * Set character color mode: `'sampled'` *(from source)* or `'fixed'`.
62
+ * @param mode The character color mode
63
+ * @returns This instance for chaining.
64
+ */
65
+ charColorMode(mode: 'sampled' | 'fixed'): this;
66
+ /**
67
+ * Set cell color mode: `'sampled'` *(from source)* or `'fixed'`.
68
+ * @param mode The cell color mode
69
+ * @returns This instance for chaining.
70
+ */
71
+ cellColorMode(mode: 'sampled' | 'fixed'): this;
72
+ /**
73
+ * Defines the character color when {@link charColorMode} is `'fixed'`.
74
+ * @param colorOrGray A grayscale value or TextmodeColor for the character
75
+ * @param g Additional green component if using RGB
76
+ * @param b Additional blue component if using RGB
77
+ * @param a Additional alpha component if using RGBA
78
+ * @returns This instance for chaining.
79
+ */
80
+ charColor(colorOrGray: number | string | TextmodeColor, g?: number, b?: number, a?: number): this;
81
+ /**
82
+ * Defines the cell color when {@link cellColorMode} is `'fixed'`.
83
+ * @param colorOrGray A grayscale value or TextmodeColor for the cell
84
+ * @param g Additional green component if using RGB
85
+ * @param b Additional blue component if using RGB
86
+ * @param a Additional alpha component if using RGBA
87
+ * @returns This instance for chaining.
88
+ */
89
+ cellColor(colorOrGray: number | string | TextmodeColor, g?: number, b?: number, a?: number): this;
90
+ /**
91
+ * Defines the background color used for transparent pixels.
92
+ * @param colorOrGray A grayscale value or TextmodeColor for the background
93
+ * @param g Additional green component if using RGB
94
+ * @param b Additional blue component if using RGB
95
+ * @param a Additional alpha component if using RGBA
96
+ * @returns This instance for chaining.
97
+ */
98
+ background(colorOrGray: number | TextmodeColor, g?: number, b?: number, a?: number): this;
99
+ /**
100
+ * Define the characters to use for brightness mapping as a string.
101
+ * Maximum length is 64; excess characters are ignored.
102
+ * @param chars String of characters to map
103
+ * @returns This instance for chaining.
104
+ */
105
+ characters(chars: string): this;
106
+ /** Return the WebGL texture currently backing this source. */
107
+ get texture(): WebGLTexture;
108
+ /** Ideal width in grid cells. */
109
+ get width(): number;
110
+ /** Ideal height in grid cells. */
111
+ get height(): number;
112
+ /** Original pixel width. */
113
+ get originalWidth(): number;
114
+ /** Original pixel height. */
115
+ get originalHeight(): number;
116
+ /**
117
+ * Get or create the material for rendering this source.
118
+ * @ignore
119
+ */
120
+ $getMaterial(): Material;
121
+ /** Hook for subclasses to run logic before material updates (e.g., upload latest frame). */
122
+ protected $beforeMaterialUpdate(): void;
123
+ /** Subclasses must supply the active texture handle to bind as u_image. */
124
+ protected abstract $getActiveTexture(): WebGLTexture;
125
+ private _updateMaterial;
126
+ private _setColor;
127
+ private _ensureShader;
128
+ protected _createUniforms(): Record<string, any>;
129
+ }
130
+ export {};
@@ -0,0 +1,237 @@
1
+ import type { GLRenderer } from '../../rendering/webgl/core/Renderer';
2
+ import type { Material } from '../../rendering/webgl/materials/Material';
3
+ import { TextmodeSource } from './TextmodeSource';
4
+ type TextmodeVideoPreloadStrategy = 'captureStream' | 'seeking';
5
+ export interface TextmodeVideoPreloadProgress {
6
+ percent: number;
7
+ loadedFrames: number;
8
+ totalFrames: number;
9
+ strategy: TextmodeVideoPreloadStrategy;
10
+ }
11
+ export interface TextmodeVideoPreloadComplete {
12
+ totalFrames: number;
13
+ strategy: TextmodeVideoPreloadStrategy;
14
+ }
15
+ /**
16
+ * Options for preloading video frames in {@link TextmodeVideo}.
17
+ *
18
+ * When providing this options object as a second argument to {@link Textmodifier.loadVideo},
19
+ * you can choose to preload all video frames at a specified frame rate before using the video.
20
+ *
21
+ * When preloading, the video will not play live asynchronously. Instead, all frames will be captured
22
+ * upfront, allowing for frame-accurate seeking and rendering.
23
+ *
24
+ * This is especially useful for scenarios where precise frame control is needed,
25
+ * like capturing GIFs/videos from textmode.js canvas using the `textmode.export.js` add-on library without
26
+ * missing frames due to asynchronous video playback.
27
+ *
28
+ * Preloading takes time proportional to the video length and frame rate, which introduces significant delays
29
+ * before the sketch can start rendering. Therefore, it is recommended to use this feature only when intending
30
+ * to capture or export frames, rather than for real-time playback.
31
+ */
32
+ export interface TextmodeVideoOptions {
33
+ /** Frame rate to use when preloading video frames. If not specified, video will not be preloaded. */
34
+ frameRate?: number;
35
+ /** Callback invoked periodically during preloading to report progress. */
36
+ onProgress?: (progress: TextmodeVideoPreloadProgress) => void;
37
+ /** Callback invoked once preloading is complete. */
38
+ onComplete?: (summary: TextmodeVideoPreloadComplete) => void;
39
+ /** Callback invoked if an error occurs during preloading. */
40
+ onError?: (error: Error) => void;
41
+ }
42
+ /**
43
+ * Represents a video element for textmode rendering via {@link Textmodifier.loadVideo}.
44
+ *
45
+ * It can be drawn to the canvas via {@link Textmodifier.image}.
46
+ *
47
+ * A video uploaded currently runs through an adjustable brightness-converter that converts
48
+ * the video frames into a textmode representation using characters.
49
+ * Those adjustable options are available via chainable methods on this class.
50
+ */
51
+ export declare class TextmodeVideo extends TextmodeSource {
52
+ private _videoElement;
53
+ private _isPreloaded;
54
+ private _preloadedFrames;
55
+ private _frameRate;
56
+ private _totalFrames;
57
+ private _currentFrameIndex;
58
+ private _lastProgressBucket;
59
+ /**
60
+ * Create a new TextmodeVideo instance.
61
+ * @param gl WebGL2 rendering context
62
+ * @param renderer GLRenderer instance
63
+ * @param texture WebGL texture for video frames
64
+ * @param videoElement The HTML video element
65
+ * @param originalWidth Original video width in pixels
66
+ * @param originalHeight Original video height in pixels
67
+ * @param gridCols Number of columns in the grid (for auto-sizing)
68
+ * @param gridRows Number of rows in the grid (for auto-sizing)
69
+ *
70
+ * @ignore
71
+ */
72
+ constructor(gl: WebGL2RenderingContext, renderer: GLRenderer, texture: WebGLTexture, videoElement: HTMLVideoElement, originalWidth: number, originalHeight: number, gridCols: number, gridRows: number);
73
+ /**
74
+ * Dispose of GPU resources and cleanup video element.
75
+ * @ignore
76
+ */
77
+ dispose(): void;
78
+ /**
79
+ * Update the texture with the current video frame if needed.
80
+ * For preloaded videos, this returns the appropriate frame texture.
81
+ * For live videos, this updates the texture with current video data.
82
+ * @ignore
83
+ */
84
+ $updateTexture(): void;
85
+ /**
86
+ * Get the active texture for the current frame.
87
+ * For preloaded videos, returns the texture at the current frame index.
88
+ * For live videos, returns the live texture.
89
+ * @ignore
90
+ */
91
+ protected $getActiveTexture(): WebGLTexture;
92
+ /**
93
+ * Get or create the material for rendering this video.
94
+ * Always updates the material to ensure the latest video frame is used.
95
+ * @ignore
96
+ */
97
+ $getMaterial(): Material;
98
+ protected $beforeMaterialUpdate(): void;
99
+ /**
100
+ * Preload all frames of the video at the specified frame rate.
101
+ * Chooses the most optimal strategy based on browser capabilities.
102
+ * @param frameRate Frame rate to use for capturing frames
103
+ * @ignore
104
+ */
105
+ private _preloadFrames;
106
+ private _initializePreloadState;
107
+ private _finalizePreloadSuccess;
108
+ private _captureSourceToTexture;
109
+ private _reportPreloadProgress;
110
+ private _tryPreloadWithTrackProcessor;
111
+ private _preloadWithLegacySeeking;
112
+ private _waitForSeek;
113
+ /**
114
+ * For preloaded videos, set or get the current frame index.
115
+ * When called without arguments, returns this video instance for use with t.image().
116
+ * When called with an index, sets the frame and returns this instance.
117
+ *
118
+ * The frame index automatically wraps using modulo, so you can pass t.frameCount directly
119
+ * and it will loop through the video frames seamlessly.
120
+ *
121
+ * For non-preloaded videos, this method does nothing and returns the instance.
122
+ *
123
+ * @param index Optional frame index to set (0-based, automatically wraps)
124
+ * @returns This instance for chaining.
125
+ *
126
+ * @example
127
+ * ```javascript
128
+ * // Draw specific frame
129
+ * t.image(video.frame(0), x, y);
130
+ *
131
+ * // Draw frame based on frameCount (automatically wraps)
132
+ * t.image(video.frame(t.frameCount), x, y);
133
+ *
134
+ * video.frame(t.frameCount);
135
+ * t.image(video, x, y);
136
+ * ```
137
+ */
138
+ frame(index?: number): this;
139
+ /**
140
+ * Create a TextmodeVideo instance from a video source (URL or HTMLVideoElement).
141
+ * @param renderer GLRenderer instance
142
+ * @param source Video URL string or HTMLVideoElement
143
+ * @param gridCols Number of columns in the grid
144
+ * @param gridRows Number of rows in the grid
145
+ * @param glyphResolver Function to resolve character strings to glyph colors
146
+ * @param options Optional preload configuration (frameRate, onProgress, onComplete, onError).
147
+ * @returns Promise resolving to TextmodeVideo instance
148
+ * @ignore
149
+ */
150
+ static $fromSource(renderer: GLRenderer, source: string | HTMLVideoElement, gridCols: number, gridRows: number, glyphResolver: (s: string) => ([number, number, number])[], options?: TextmodeVideoOptions): Promise<TextmodeVideo>;
151
+ /**
152
+ * Play the video.
153
+ * @returns Promise that resolves when playback starts
154
+ */
155
+ play(): Promise<void>;
156
+ /**
157
+ * Pause the video.
158
+ */
159
+ pause(): void;
160
+ /**
161
+ * Stop the video and reset to beginning.
162
+ */
163
+ stop(): void;
164
+ /**
165
+ * Set the playback speed.
166
+ * @param rate Playback rate (1.0 = normal speed)
167
+ */
168
+ speed(rate: number): this;
169
+ /**
170
+ * Set whether the video should loop.
171
+ * @param shouldLoop Whether to loop (defaults to true)
172
+ */
173
+ loop(shouldLoop?: boolean): this;
174
+ /**
175
+ * Set the current time position in the video.
176
+ * @param seconds Time in seconds
177
+ */
178
+ time(seconds: number): this;
179
+ /**
180
+ * Set the volume.
181
+ * @param level Volume level (0.0-1.0)
182
+ */
183
+ volume(level: number): this;
184
+ /**
185
+ * WebGL texture handle containing the current video frame.
186
+ */
187
+ get texture(): WebGLTexture;
188
+ /**
189
+ * Ideal width to draw the video at (in grid cells), calculated to fit the grid while preserving aspect ratio.
190
+ */
191
+ get width(): number;
192
+ /**
193
+ * Ideal height to draw the video at (in grid cells), calculated to fit the grid while preserving aspect ratio.
194
+ */
195
+ get height(): number;
196
+ /**
197
+ * Original pixel width of the video.
198
+ */
199
+ get originalWidth(): number;
200
+ /**
201
+ * Original pixel height of the video.
202
+ */
203
+ get originalHeight(): number;
204
+ /**
205
+ * The underlying HTML video element.
206
+ */
207
+ get videoElement(): HTMLVideoElement;
208
+ /**
209
+ * Current playback time in seconds.
210
+ */
211
+ get currentTime(): number;
212
+ /**
213
+ * Total duration of the video in seconds.
214
+ */
215
+ get duration(): number;
216
+ /**
217
+ * Whether the video is currently playing.
218
+ */
219
+ get isPlaying(): boolean;
220
+ /**
221
+ * Whether this video has been preloaded with frames.
222
+ */
223
+ get isPreloaded(): boolean;
224
+ /**
225
+ * Total number of preloaded frames. Returns 0 for non-preloaded videos.
226
+ */
227
+ get totalFrames(): number;
228
+ /**
229
+ * The frame rate used for preloading. Returns null for non-preloaded videos.
230
+ */
231
+ get preloadFrameRate(): number | null;
232
+ /**
233
+ * Current frame index for preloaded videos. Returns 0 for non-preloaded videos.
234
+ */
235
+ get currentFrameIndex(): number;
236
+ }
237
+ export {};
@@ -17,7 +17,7 @@ export declare class CharacterColorMapper {
17
17
  /**
18
18
  * Generates a unique RGB color for a character based on its index.
19
19
  * @param index The index of the character
20
- * @returns RGB color as a tuple [r, g, b] with values from 0-1 for shader use
20
+ * @returns RGB color as a tuple [r, g, 0] with values from 0-1 for shader use
21
21
  */
22
22
  private _generateCharacterColor;
23
23
  /**
@@ -10,12 +10,6 @@ export declare class CharacterExtraction {
10
10
  * @returns Array of unique character strings
11
11
  */
12
12
  $extractCharacters(font: TyprFont): string[];
13
- /**
14
- * Filters out problematic characters that might cause rendering issues.
15
- * @param characters Array of character strings to filter
16
- * @returns Filtered array of character strings
17
- */
18
- $filterProblematicCharacters(characters: string[]): string[];
19
13
  /**
20
14
  * Extracts characters from a Format 4 cmap table (Basic Multilingual Plane).
21
15
  */
@@ -28,8 +22,4 @@ export declare class CharacterExtraction {
28
22
  * Calculates the glyph index for a character in a Format 4 cmap table.
29
23
  */
30
24
  private _calculateGlyphIndexFormat4;
31
- /**
32
- * Checks if a character is valid for rendering.
33
- */
34
- private _isValidCharacter;
35
25
  }
@@ -1,9 +1,9 @@
1
- import type { GLRenderer } from '../../rendering/webgl/Renderer.ts';
2
- import type { GLFramebuffer } from '../../rendering/webgl/Framebuffer.ts';
1
+ import type { GLRenderer } from '../../../rendering/webgl/core/Renderer.ts';
2
+ import type { GLFramebuffer } from '../../../rendering/webgl/core/Framebuffer.ts';
3
3
  import type { TextmodeCharacter } from './types.ts';
4
4
  import type { TyprFont, GlyphData } from './typr/types.ts';
5
5
  /**
6
- * Manages the font used for rendering characters.
6
+ * Manages the font used for rendering characters via {@link Textmodifier.loadFont}.
7
7
  *
8
8
  * This class coordinates font loading, character extraction, texture atlas creation,
9
9
  * and provides character information.
@@ -75,9 +75,12 @@ export declare class TextmodeFont {
75
75
  $getCharacterColors(characters: string): [number, number, number][];
76
76
  /**
77
77
  * Lazily retrieves glyph data for the given Unicode code point.
78
+ *
78
79
  * Glyph data is cached after the first access to avoid repeated Typr parsing.
80
+ *
79
81
  * @param codePoint Unicode code point
80
82
  * @returns Parsed glyph data or null if unavailable
83
+ * @ignore
81
84
  */
82
85
  getGlyphData(codePoint: number): GlyphData | null;
83
86
  private _getGlyphIndex;
@@ -1,6 +1,6 @@
1
1
  import type { TextmodeCharacter, GlyphDimensions } from './types.ts';
2
- import type { GLRenderer } from '../../rendering/webgl/Renderer.ts';
3
- import type { GLFramebuffer } from '../../rendering/webgl/Framebuffer.ts';
2
+ import type { GLRenderer } from '../../../rendering/webgl/core/Renderer.ts';
3
+ import type { GLFramebuffer } from '../../../rendering/webgl/core/Framebuffer.ts';
4
4
  import type { TyprFont } from './typr/types.ts';
5
5
  /**
6
6
  * Handles creation of texture atlases for font rendering.
@@ -23,10 +23,10 @@ export declare class TextureAtlasCreation {
23
23
  * @param characters Array of TextmodeCharacter objects
24
24
  * @param maxGlyphDimensions Maximum dimensions of glyphs
25
25
  * @param fontSize Font size for rendering
26
- * @param fontDataOrFamilyName Either Typr.js font data object for path rendering, or font family name string for fillText rendering
26
+ * @param font Either Typr.js font data object for path rendering, or font family name string for fillText rendering
27
27
  * @returns Object containing framebuffer, columns, and rows
28
28
  */
29
- createTextureAtlas(characters: TextmodeCharacter[], maxGlyphDimensions: GlyphDimensions, fontSize: number, fontDataOrFamilyName: TyprFont | string): {
29
+ $createTextureAtlas(characters: TextmodeCharacter[], maxGlyphDimensions: GlyphDimensions, fontSize: number, font: TyprFont): {
30
30
  framebuffer: GLFramebuffer;
31
31
  columns: number;
32
32
  rows: number;
@@ -53,13 +53,6 @@ export declare class TextureAtlasCreation {
53
53
  * @returns Parsed glyph data or null if not found
54
54
  */
55
55
  private _getGlyphData;
56
- /**
57
- * Gets the advance width for a glyph
58
- * @param fontData The Typr.js font data
59
- * @param glyphIndex The glyph index
60
- * @returns The advance width in font units
61
- */
62
- private _getGlyphAdvanceWidth;
63
56
  /**
64
57
  * Renders a glyph to the canvas using direct path rendering from glyph outline data.
65
58
  * @param glyphData Glyph data from Typr.js
@@ -18,12 +18,6 @@ export interface TyprBinary {
18
18
  readUint: (buff: Uint8Array, p: number) => number;
19
19
  /** Read ASCII string */
20
20
  readASCII: (buff: Uint8Array, p: number, l: number) => string;
21
- /** Write unsigned 16-bit integer (big-endian) */
22
- writeUshort: (buff: Uint8Array, p: number, n: number) => void;
23
- /** Write unsigned 32-bit integer (big-endian) */
24
- writeUint: (buff: Uint8Array, p: number, n: number) => void;
25
- /** Write ASCII string */
26
- writeASCII: (buff: Uint8Array, p: number, s: string) => void;
27
21
  /** Shared typed array buffers for efficient reading */
28
22
  t: {
29
23
  uint8: Uint8Array;
@@ -0,0 +1,5 @@
1
+ export { TextmodeImage } from './TextmodeImage';
2
+ export { TextmodeVideo } from './TextmodeVideo';
3
+ export { TextmodeFont } from './font/TextmodeFont';
4
+ export type { TextmodeCharacter } from './font/types';
5
+ export type { TextmodeVideoOptions } from './TextmodeVideo';
@@ -0,0 +1,20 @@
1
+ import type { LoadingPhaseSnapshot } from './types';
2
+ /**
3
+ * Tracks loading phases and their progress.
4
+ * @ignore
5
+ */
6
+ export declare class LoadingPhaseTracker {
7
+ private _phases;
8
+ private _phaseOrder;
9
+ private _totalWeight;
10
+ private _lastReportedProgress;
11
+ private _onProgressChange?;
12
+ get totalWeight(): number;
13
+ get progress(): number;
14
+ setProgressChangeCallback(callback: (progress: number) => void): void;
15
+ createPhase(label: string, weight?: number): string;
16
+ updatePhaseProgress(id: string, progress: number): void;
17
+ completePhase(id: string): void;
18
+ failPhase(id: string): void;
19
+ snapshotPhases(): LoadingPhaseSnapshot[];
20
+ }