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,275 @@
1
+ import type { TextmodeGrid } from '../Grid';
2
+ import type { TextmodeFont } from '../loadables/font';
3
+ import type { TextmodeImage } from '../loadables/TextmodeImage';
4
+ import type { TextmodeCanvas } from '../Canvas';
5
+ import type { AnimationController } from '../AnimationController';
6
+ import type { GLFramebuffer, Shader } from '../../rendering';
7
+ import type { GLRenderer } from '../../rendering/webgl/core/Renderer';
8
+ import type { MouseManager } from '../managers/MouseManager';
9
+ import type { KeyboardManager } from '../managers/KeyboardManager';
10
+ import type { TouchManager } from '../managers/TouchManager';
11
+ import type { IRenderingMixin } from '../mixins/interfaces/IRenderingMixin';
12
+ import type { IFontMixin } from '../mixins/interfaces/IFontMixin';
13
+ import type { IKeyboardMixin } from '../mixins/interfaces/IKeyboardMixin';
14
+ import type { ITouchMixin } from '../mixins/interfaces/ITouchMixin';
15
+ import type { IMouseMixin } from '../mixins/interfaces/IMouseMixin';
16
+ import type { IAnimationMixin } from '../mixins/interfaces/IAnimationMixin';
17
+ import type { LoadingScreenManager } from '../loading/LoadingScreenManager';
18
+ /**
19
+ * Manages textmode rendering on a [`HTMLCanvasElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement) and provides methods for drawing,
20
+ * exporting, font management, event handling, and animation control.
21
+ *
22
+ * If the `Textmodifier` instance is created without a canvas parameter,
23
+ * it creates a new `HTMLCanvasElement` to draw on using the `textmode.js` drawing API.
24
+ * If a canvas is provided, it will use that canvas instead.
25
+ */
26
+ export interface ITextmodifier extends IRenderingMixin, IFontMixin, IAnimationMixin, IMouseMixin, ITouchMixin, IKeyboardMixin {
27
+ /** Core WebGL renderer @ignore */
28
+ readonly _renderer: GLRenderer;
29
+ /** Font management @ignore */
30
+ readonly _font: TextmodeFont;
31
+ /** Canvas management @ignore */
32
+ readonly _canvas: TextmodeCanvas;
33
+ /** Grid management @ignore */
34
+ readonly _grid: TextmodeGrid;
35
+ /** Animation controller for managing rendering loop @ignore */
36
+ readonly _animationController: AnimationController;
37
+ /** Mouse interaction manager @ignore */
38
+ readonly _mouseManager: MouseManager;
39
+ /** Touch interaction manager @ignore */
40
+ readonly _touchManager: TouchManager;
41
+ /** Keyboard interaction manager @ignore */
42
+ readonly _keyboardManager: KeyboardManager;
43
+ /** Framebuffer used for offscreen rendering @ignore */
44
+ readonly _textmodeDrawFramebuffer: GLFramebuffer;
45
+ /** Shader used for converting pixels to textmode grid format @ignore */
46
+ readonly _textmodeConversionShader: Shader;
47
+ /** Framebuffer used for textmode conversion @ignore */
48
+ readonly _textmodeFramebuffer: GLFramebuffer;
49
+ /** Shader used for final presentation to the screen @ignore */
50
+ readonly _presentShader: Shader;
51
+ /** Loading screen manager for boot-time UX @ignore */
52
+ readonly _loading: LoadingScreenManager;
53
+ /** Main render method @ignore */
54
+ $render(): void;
55
+ /**
56
+ * Set a setup callback function that will be executed once when initialization is complete.
57
+ *
58
+ * This callback is called after font loading and grid initialization, allowing access to
59
+ * properties like `textmodifier.grid.cols` for calculating layout or setup variables.
60
+ *
61
+ * @param callback The function to call when setup is complete
62
+ *
63
+ * @example
64
+ * ```javascript
65
+ * const textmodifier = textmode.create({
66
+ * width: 800,
67
+ * height: 600,
68
+ * fontSize: 16
69
+ * });
70
+ *
71
+ * // Setup callback - called once when ready
72
+ * textmodifier.setup(() => {
73
+ * // Now you can access grid properties
74
+ * const cols = textmodifier.grid.cols;
75
+ * const rows = textmodifier.grid.rows;
76
+ *
77
+ * // Initialize any variables that depend on grid size
78
+ * rectWidth = Math.floor(cols / 3);
79
+ * rectHeight = Math.floor(rows / 2);
80
+ * });
81
+ *
82
+ * // Draw callback - called every frame
83
+ * textmodifier.draw(() => {
84
+ * textmodifier.background(128);
85
+ * textmodifier.char('A');
86
+ * textmodifier.rotateZ(textmodifier.frameCount * 2);
87
+ * textmodifier.rect(rectWidth, rectHeight);
88
+ * });
89
+ * ```
90
+ */
91
+ setup(callback: () => void): void;
92
+ /**
93
+ * Set a draw callback function that will be executed before each render.
94
+ *
95
+ * This callback function is where all drawing commands should be placed for textmode rendering.
96
+ *
97
+ * @param callback The function to call before each render
98
+ *
99
+ * @example
100
+ * ```javascript
101
+ * // Create a textmodifier instance
102
+ * const t = textmode.create({
103
+ * width: 800,
104
+ * height: 600,
105
+ * });
106
+ *
107
+ * // Set up draw callback
108
+ * t.draw(() => {
109
+ * // Set background color
110
+ * t.background(128);
111
+ *
112
+ * // Draw a textmode rectangle
113
+ * t.char('A');
114
+ * t.rotateZ(t.frameCount * 2);
115
+ * t.rect(16, 16);
116
+ * });
117
+ * ```
118
+ */
119
+ draw(callback: () => void): void;
120
+ /**
121
+ * Set a callback function that will be called when the window is resized.
122
+ * @param callback The function to call when the window is resized.
123
+ *
124
+ * @example
125
+ * ```javascript
126
+ * // Create a standalone textmodifier instance
127
+ * const t = textmode.create({
128
+ * width: window.innerWidth,
129
+ * height: window.innerHeight,
130
+ * });
131
+ *
132
+ * // Draw callback to update content
133
+ * t.draw(() => {
134
+ * // Set background color
135
+ * t.background(128);
136
+ * t.char('A');
137
+ * t.rotateZ(t.frameCount * 2);
138
+ * t.rect(16, 16);
139
+ * });
140
+ *
141
+ * // Set up window resize callback
142
+ * t.windowResized(() => {
143
+ * // Resize the canvas to match window size
144
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
145
+ * });
146
+ * ```
147
+ */
148
+ windowResized(callback: () => void): void;
149
+ /**
150
+ * Resize the canvas and adjust all related components accordingly.
151
+ *
152
+ * @param width The new width of the canvas.
153
+ * @param height The new height of the canvas.
154
+ *
155
+ * @example
156
+ * ```javascript
157
+ * // Create a standalone textmodifier instance
158
+ * const t = textmode.create({
159
+ * width: window.innerWidth,
160
+ * height: window.innerHeight,
161
+ * });
162
+ *
163
+ * // Draw callback to update content
164
+ * t.draw(() => {
165
+ * // Set background color
166
+ * t.background(128);
167
+ * t.char('A');
168
+ * t.rotateZ(t.frameCount * 2);
169
+ * t.rect(16, 16);
170
+ * });
171
+ *
172
+ * // Set up window resize callback
173
+ * t.windowResized(() => {
174
+ * // Resize the canvas to match window size
175
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
176
+ * });
177
+ * ```
178
+ */
179
+ resizeCanvas(width: number, height: number): void;
180
+ /**
181
+ * Completely destroy this Textmodifier instance and free all associated resources.
182
+ *
183
+ * After calling this method, the instance should not be used and will be eligible for garbage collection.
184
+ *
185
+ * @example
186
+ * ```javascript
187
+ * // Create a textmodifier instance
188
+ * const textmodifier = textmode.create();
189
+ *
190
+ * // ...
191
+ *
192
+ * // When done, completely clean up
193
+ * textmodifier.destroy();
194
+ *
195
+ * // Instance is now safely disposed and ready for garbage collection
196
+ * ```
197
+ */
198
+ destroy(): void;
199
+ /** Get the current grid object used for rendering. */
200
+ readonly grid: TextmodeGrid;
201
+ /** Get the current font object used for rendering. */
202
+ readonly font: TextmodeFont;
203
+ /** Get the width of the canvas in pixels. */
204
+ readonly width: number;
205
+ /** Get the height of the canvas in pixels. */
206
+ readonly height: number;
207
+ /** Get the textmodifier canvas containing the rendered output. */
208
+ readonly canvas: HTMLCanvasElement;
209
+ /** Get the WebGL framebuffer used for drawing operations in {@link Textmodifier.draw}. */
210
+ readonly drawFramebuffer: GLFramebuffer;
211
+ /** Check if the instance has been disposed/destroyed. */
212
+ readonly isDisposed: boolean;
213
+ /**
214
+ * If in overlay mode, returns the {@link TextmodeImage} instance capturing the target canvas/video content,
215
+ * allowing further configuration of the conversion parameters.
216
+ *
217
+ * @example
218
+ * ```javascript
219
+ * // Create the textmode instance using the p5 canvas as input overlay
220
+ * const t = textmode.create({ fontSize: 16, canvas: p.canvas, overlay: true });
221
+ *
222
+ * // Configure overlay conversion once fonts and grid are ready
223
+ * t.setup(() => {
224
+ * t.overlay
225
+ * .characters(' .:-=+*#%@') // Character set for brightness mapping
226
+ * .cellColorMode('fixed') // Use fixed background cell color
227
+ * .cellColor(0, 0, 0) // Black background for each cell
228
+ * .charColorMode('sampled') // Sample the character color from the image
229
+ * .background(0, 0, 0, 255); // Black fallback for transparent pixels
230
+ * });
231
+ *
232
+ * // In the draw loop, pass the overlay into the text grid
233
+ * t.draw(() => {
234
+ * t.clear();
235
+ * t.image(t.overlay, t.grid.cols, t.grid.rows);
236
+ * });
237
+ *```
238
+ */
239
+ readonly overlay: TextmodeImage | undefined;
240
+ /**
241
+ * Provides access to the loading screen manager to control boot-time loading UX.
242
+ *
243
+ * @example
244
+ * ```javascript
245
+ * const t = textmode.create({ width: 800, height: 600, loadingScreen: { message: 'loading...' } });
246
+ *
247
+ * t.setup(async () => {
248
+ * // Initialize two loading phases
249
+ * const phase1 = t.loading.addPhase('Loading assets');
250
+ * const phase2 = t.loading.addPhase('Initializing game');
251
+ *
252
+ * // Start the first phase and simulate asset loading
253
+ * await phase1.track(async () => {
254
+ * for (let i = 0; i <= 5; i++) {
255
+ * phase1.report(i / 5);
256
+ * // Small delay — increases visibility of the loading animation
257
+ * await new Promise((r) => setTimeout(r, 200));
258
+ * }
259
+ * });
260
+ *
261
+ * // Start the second phase and simulate initialization
262
+ * await phase2.track(async () => {
263
+ * for (let i = 0; i <= 5; i++) {
264
+ * phase2.report(i / 5);
265
+ * await new Promise((r) => setTimeout(r, 150));
266
+ * }
267
+ * });
268
+ *
269
+ * // Optionally set a final message before the screen transitions away
270
+ * t.loading.message('Ready - enjoy!');
271
+ * });
272
+ * ```
273
+ */
274
+ readonly loading: LoadingScreenManager;
275
+ }
@@ -0,0 +1 @@
1
+ export type { ITextmodifier } from './ITextmodifier';
@@ -0,0 +1,47 @@
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
+ * @example
13
+ * ```javascript
14
+ * const t = textmode.create({
15
+ * width: 800,
16
+ * height: 600,
17
+ * });
18
+ *
19
+ * let img;
20
+ *
21
+ * t.setup(async () => {
22
+ * img = await t.loadImage('https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&q=80');
23
+ * img.characters(" .:-=+*#%@");
24
+ * // ... other adjustments like img.flipX(boolean), img.cellColorMode('sampled' | 'fixed'), etc.
25
+ * // (can also be chained or updated during runtime)
26
+ * });
27
+ *
28
+ * t.draw(() => {
29
+ * t.background(0);
30
+ *
31
+ * if (img) {
32
+ * // Draw the loaded image
33
+ * t.image(img);
34
+ * }
35
+ * });
36
+ * ```
37
+ */
38
+ export declare class TextmodeImage extends TextmodeSource {
39
+ private constructor();
40
+ /**
41
+ * Create a TextmodeImage from an HTML image/video/canvas element.
42
+ * Texture parameters use NEAREST and CLAMP to align with grid sampling.
43
+ * @ignore
44
+ */
45
+ static $fromSource(renderer: GLRenderer, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, gridCols: number, gridRows: number, glyphResolver: (s: string) => ([number, number, number])[]): TextmodeImage;
46
+ protected $getActiveTexture(): WebGLTexture;
47
+ }
@@ -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 (0-255), hex string ('#RGB', '#RRGGBB', '#RRGGBBAA'), or TextmodeColor instance
75
+ * @param g Green component (0-255) if using RGB format
76
+ * @param b Blue component (0-255) if using RGB format
77
+ * @param a Alpha component (0-255) if using RGBA format
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 (0-255), hex string ('#RGB', '#RRGGBB', '#RRGGBBAA'), or TextmodeColor instance
84
+ * @param g Green component (0-255) if using RGB format
85
+ * @param b Blue component (0-255) if using RGB format
86
+ * @param a Alpha component (0-255) if using RGBA format
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 (0-255), hex string ('#RGB', '#RRGGBB', '#RRGGBBAA'), or TextmodeColor instance
93
+ * @param g Green component (0-255) if using RGB format
94
+ * @param b Blue component (0-255) if using RGB format
95
+ * @param a Alpha component (0-255) if using RGBA format
96
+ * @returns This instance for chaining.
97
+ */
98
+ background(colorOrGray: number | TextmodeColor | string, 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 {};