textmode.js 0.1.6-beta.4 → 0.1.6-beta.6

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 (39) hide show
  1. package/dist/textmode.esm.js +1487 -4016
  2. package/dist/textmode.esm.min.js +1486 -4014
  3. package/dist/textmode.umd.js +19 -19
  4. package/dist/textmode.umd.min.js +18 -18
  5. package/dist/types/ColorPalette.d.ts +1 -5
  6. package/dist/types/Textmode.d.ts +0 -10
  7. package/dist/types/export/image/ImageDataExtractor.d.ts +1 -1
  8. package/dist/types/export/image/ImageExporter.d.ts +1 -1
  9. package/dist/types/export/image/ImageFileHandler.d.ts +1 -7
  10. package/dist/types/export/svg/SVGContentGenerator.d.ts +1 -1
  11. package/dist/types/export/svg/SVGDataExtractor.d.ts +1 -1
  12. package/dist/types/export/svg/SVGPathGenerator.d.ts +0 -5
  13. package/dist/types/export/txt/TXTDataExtractor.d.ts +1 -1
  14. package/dist/types/index.d.ts +0 -1
  15. package/dist/types/rendering/index.d.ts +0 -5
  16. package/dist/types/rendering/webgl/Framebuffer.d.ts +2 -9
  17. package/dist/types/rendering/webgl/Renderer.d.ts +2 -12
  18. package/dist/types/rendering/webgl/Shader.d.ts +5 -12
  19. package/dist/types/rendering/webgl/StateCache.d.ts +0 -2
  20. package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +40 -0
  21. package/dist/types/rendering/webgl/geometries/Line.d.ts +6 -26
  22. package/dist/types/rendering/webgl/geometries/Rectangle.d.ts +8 -18
  23. package/dist/types/rendering/webgl/geometries/index.d.ts +3 -0
  24. package/dist/types/textmode/Canvas.d.ts +0 -11
  25. package/dist/types/textmode/ConversionPipeline.d.ts +12 -9
  26. package/dist/types/textmode/Grid.d.ts +1 -6
  27. package/dist/types/textmode/Textmodifier.d.ts +28 -610
  28. package/dist/types/textmode/converters/FeatureConverter.d.ts +24 -0
  29. package/dist/types/textmode/mixins/ConversionMixin.d.ts +63 -0
  30. package/dist/types/textmode/mixins/ExportMixin.d.ts +155 -0
  31. package/dist/types/textmode/mixins/FontMixin.d.ts +49 -0
  32. package/dist/types/textmode/mixins/RenderingMixin.d.ts +409 -0
  33. package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +39 -0
  34. package/dist/types/textmode/mixins/index.d.ts +5 -0
  35. package/package.json +3 -1
  36. package/dist/types/rendering/webgl/shapes/LineShape.d.ts +0 -20
  37. package/dist/types/rendering/webgl/shapes/RectangleShape.d.ts +0 -20
  38. package/dist/types/rendering/webgl/shapes/Shape.d.ts +0 -21
  39. package/dist/types/types/index.d.ts +0 -4
@@ -73,6 +73,30 @@ export declare abstract class TextmodeFeatureConverter extends TextmodeConverter
73
73
  * @param flip If `true`, characters are flipped vertically. If `false`, no flip is applied.
74
74
  */
75
75
  flipVertically(flip: boolean | number): void;
76
+ /**
77
+ * Helper method to parse color values from either hex string or RGB(A) parameters.
78
+ * @param r Red component (0-255) or hex string.
79
+ * @param methodName The name of the calling method for error reporting.
80
+ * @param g Green component (0-255).
81
+ * @param b Blue component (0-255).
82
+ * @param a Alpha component (0-255).
83
+ * @returns Normalized RGBA array [r, g, b, a] (0-1 range) or null if invalid.
84
+ */
85
+ private parseColor;
86
+ /**
87
+ * Helper method to set color mode with validation.
88
+ * @param mode The color mode to set.
89
+ * @param optionKey The option key to set in _options.
90
+ * @param errorMessage The error message to show if validation fails.
91
+ */
92
+ private setColorMode;
93
+ /**
94
+ * Helper method to set boolean options with validation.
95
+ * @param value The boolean or number value to set.
96
+ * @param optionKey The option key to set in _options.
97
+ * @param displayName The display name for error messages.
98
+ */
99
+ private setBooleanOption;
76
100
  /**
77
101
  * Parses a hex color string and returns RGBA values.
78
102
  * @param hex Hex color string (e.g., '#FF0000', '#F00', 'FF0000', 'F00').
@@ -0,0 +1,63 @@
1
+ import type { Mixin } from './TextmodifierMixin';
2
+ import type { TextmodeConverter } from '../converters';
3
+ /**
4
+ * Interface for conversion pipeline capabilities that will be mixed into Textmodifier
5
+ */
6
+ export interface ConversionCapabilities {
7
+ /**
8
+ * Adds a new converter to the pipeline.
9
+ * @param name A unique name for the converter.
10
+ * @param type The type of converter to add. Can be either "brightness" or "custom".
11
+ * @returns The newly created {@link TextmodeConverter} instance or `void` if the addition failed.
12
+ *
13
+ * @example
14
+ * ```javascript
15
+ * // Fetch a canvas element to apply textmode rendering to
16
+ * const canvas = document.querySelector('canvas#myCanvas');
17
+ *
18
+ * // Create a Textmodifier instance
19
+ * const textmodifier = await textmode.create(canvas);
20
+ *
21
+ * // Add a new brightness converter
22
+ * const myConverter = textmodifier.addConverter('my-brightness', 'brightness');
23
+ *
24
+ * // Configure the new converter
25
+ * myConverter.characters("▓▒░ ");
26
+ * myConverter.enabled(true);
27
+ *
28
+ * // Add a custom converter
29
+ * const customConverter = textmodifier.addConverter('my-custom', 'custom');
30
+ * ```
31
+ */
32
+ addConverter(name: string, type: 'brightness' | 'custom'): TextmodeConverter | void;
33
+ /**
34
+ * Removes a converter from the pipeline by name or instance.
35
+ * @param nameOrInstance The unique name of the converter or the converter instance to remove.
36
+ *
37
+ * @example
38
+ * ```javascript
39
+ * // Fetch a canvas element to apply textmode rendering to
40
+ * const canvas = document.querySelector('canvas#myCanvas');
41
+ *
42
+ * // Create a Textmodifier instance
43
+ * const textmodifier = await textmode.create(canvas);
44
+ *
45
+ * // Add a converter
46
+ * const myConverter = textmodifier.addConverter('temp-converter', 'brightness');
47
+ *
48
+ * // Remove by name
49
+ * textmodifier.removeConverter('temp-converter');
50
+ *
51
+ * // Or remove by instance
52
+ * const anotherConverter = textmodifier.addConverter('another', 'custom');
53
+ * textmodifier.removeConverter(anotherConverter);
54
+ * ```
55
+ */
56
+ removeConverter(nameOrInstance: string | TextmodeConverter): void;
57
+ }
58
+ /**
59
+ * Mixin that adds conversion pipeline capabilities to a class by delegating to TextmodeConversionPipeline
60
+ * @param Base The base class to extend
61
+ * @returns Extended class with conversion capabilities
62
+ */
63
+ export declare const ConversionMixin: Mixin<ConversionCapabilities>;
@@ -0,0 +1,155 @@
1
+ import type { Mixin } from './TextmodifierMixin';
2
+ import { type SVGExportOptions } from '../../export/svg';
3
+ import { type TXTExportOptions } from '../../export/txt';
4
+ import { type ImageExportOptions, type ImageFormat } from '../../export/image';
5
+ /**
6
+ * Interface for export capabilities that will be mixed into Textmodifier
7
+ */
8
+ export interface ExportCapabilities {
9
+ /**
10
+ * Generate the current textmode rendering as a text string.
11
+ * @param options Options for text generation *(excluding filename)*
12
+ * @returns Textmode grid content as a string.
13
+ *
14
+ * @example
15
+ * ```javascript
16
+ * // Fetch a canvas element to apply textmode rendering to
17
+ * const canvas = document.querySelector('canvas#myCanvas');
18
+ *
19
+ * // Create a Textmodifier instance
20
+ * const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
21
+ *
22
+ * // Render a single frame
23
+ * textmodifier.render();
24
+ *
25
+ * // Get the current rendering as a text string
26
+ * const textString = textmodifier.toString({
27
+ * preserveTrailingSpaces: false,
28
+ * lineEnding: 'lf'
29
+ * });
30
+ *
31
+ * // Print to console or use otherwise
32
+ * console.log(textString);
33
+ *
34
+ * ////////
35
+ *
36
+ * // Example with video element
37
+ * const video = document.querySelector('video#myVideo');
38
+ * const videoTextmodifier = await textmode.create(video);
39
+ *
40
+ * // The textmode overlay will automatically update as the video plays
41
+ * video.play();
42
+ *
43
+ * // Get current frame as ASCII
44
+ * const videoFrame = videoTextmodifier.toString();
45
+ * ```
46
+ */
47
+ toString(options?: Omit<TXTExportOptions, 'filename'>): string;
48
+ /**
49
+ * Export the current textmode rendering to a TXT file.
50
+ * @param options Options for TXT export
51
+ *
52
+ * @example
53
+ * ```javascript
54
+ * // Fetch a canvas element to apply textmode rendering to
55
+ * const canvas = document.querySelector('canvas#myCanvas');
56
+ *
57
+ * // Create a Textmodifier instance
58
+ * const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
59
+ *
60
+ * // Render a single frame
61
+ * textmodifier.render();
62
+ *
63
+ * // Export the current rendering to a TXT file
64
+ * textmodifier.saveStrings({
65
+ * filename: 'my_textmode_rendering',
66
+ * preserveTrailingSpaces: false
67
+ * });
68
+ * ```
69
+ */
70
+ saveStrings(options?: TXTExportOptions): void;
71
+ /**
72
+ * Generate the current textmode rendering as an SVG string.
73
+ * @param options Options for SVG generation *(excluding filename)*
74
+ * @returns SVG content as a string.
75
+ *
76
+ * @example
77
+ * ```javascript
78
+ * // Fetch a canvas element to apply textmode rendering to
79
+ * const canvas = document.querySelector('canvas#myCanvas');
80
+ *
81
+ * // Create a Textmodifier instance
82
+ * const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
83
+ *
84
+ * // Render a single frame
85
+ * textmodifier.render();
86
+ *
87
+ * // Get the current rendering as an SVG string
88
+ * const svgString = textmodifier.toSVG({
89
+ * includeBackgroundRectangles: true,
90
+ * drawMode: 'fill'
91
+ * });
92
+ *
93
+ * // Print to console or use otherwise
94
+ * console.log(svgString);
95
+ * ```
96
+ */
97
+ toSVG(options?: Omit<SVGExportOptions, 'filename'>): string;
98
+ /**
99
+ * Export the current textmode rendering to an SVG file.
100
+ * @param options Options for SVG export
101
+ *
102
+ * @example
103
+ * ```javascript
104
+ * // Fetch a canvas element to apply textmode rendering to
105
+ * const canvas = document.querySelector('canvas#myCanvas');
106
+ *
107
+ * // Create a Textmodifier instance
108
+ * const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
109
+ *
110
+ * // Render a single frame
111
+ * textmodifier.render();
112
+ *
113
+ * // Export the current rendering to an SVG file
114
+ * textmodifier.saveSVG({
115
+ * filename: 'my_textmode_rendering',
116
+ * });
117
+ * ```
118
+ */
119
+ saveSVG(options?: SVGExportOptions): void;
120
+ /**
121
+ * Export the current textmode rendering to an image file.
122
+ * @param filename The filename (without extension) to save the image as
123
+ * @param format The image format ('png', 'jpg', or 'webp')
124
+ * @param options Additional options for image export
125
+ *
126
+ * @example
127
+ * ```javascript
128
+ * // Fetch a canvas element to apply textmode rendering to
129
+ * const canvas = document.querySelector('canvas#myCanvas');
130
+ *
131
+ * // Create a Textmodifier instance
132
+ * const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
133
+ *
134
+ * // Render a single frame
135
+ * textmodifier.render();
136
+ *
137
+ * // Export the current rendering to a PNG file
138
+ * textmodifier.saveCanvas('my_textmode_rendering', 'png');
139
+ *
140
+ * // Export with custom options
141
+ * textmodifier.saveCanvas('my_textmode_rendering', 'jpg', {
142
+ * quality: 0.8,
143
+ * scale: 2.0,
144
+ * backgroundColor: 'white'
145
+ * });
146
+ * ```
147
+ */
148
+ saveCanvas(filename: string, format?: ImageFormat, options?: Omit<ImageExportOptions, 'filename' | 'format'>): Promise<void>;
149
+ }
150
+ /**
151
+ * Mixin that adds export capabilities to a class
152
+ * @param Base The base class to extend
153
+ * @returns Extended class with export capabilities
154
+ */
155
+ export declare const ExportMixin: Mixin<ExportCapabilities>;
@@ -0,0 +1,49 @@
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
+ * // Fetch a canvas element to apply textmode rendering to
13
+ * const canvas = document.querySelector('canvas#myCanvas');
14
+ *
15
+ * // Create a Textmodifier instance
16
+ * const textmodifier = await textmode.create(canvas);
17
+ *
18
+ * // Load a custom font from a URL
19
+ * await textmodifier.loadFont('https://example.com/fonts/myfont.ttf');
20
+ *
21
+ * // Local font example
22
+ * // await textmodifier.loadFont('./fonts/myfont.ttf');
23
+ * ```
24
+ */
25
+ loadFont(fontSource: string): Promise<void>;
26
+ /**
27
+ * Set the font size used for rendering.
28
+ * @param size The font size to set.
29
+ *
30
+ * @example
31
+ * ```javascript
32
+ * // Fetch a canvas element to apply textmode rendering to
33
+ * const canvas = document.querySelector('canvas#myCanvas');
34
+ *
35
+ * // Create a Textmodifier instance
36
+ * const textmodifier = await textmode.create(canvas);
37
+ *
38
+ * // Set the font size to 24
39
+ * textmodifier.fontSize(24);
40
+ * ```
41
+ */
42
+ fontSize(size: number): void;
43
+ }
44
+ /**
45
+ * Mixin that adds font capabilities to a class
46
+ * @param Base The base class to extend
47
+ * @returns Extended class with font capabilities
48
+ */
49
+ export declare const FontMixin: Mixin<FontCapabilities>;
@@ -0,0 +1,409 @@
1
+ import type { Mixin } from './TextmodifierMixin';
2
+ import type { Shader } from '../../rendering';
3
+ /**
4
+ * Interface for rendering capabilities that will be mixed into Textmodifier
5
+ */
6
+ export interface RenderingCapabilities {
7
+ /**
8
+ * Sets the fill color for subsequent rendering operations
9
+ * @param r Red component (0-255)
10
+ * @param g Green component (0-255, optional)
11
+ * @param b Blue component (0-255, optional)
12
+ * @param a Alpha component (0-255, optional)
13
+ *
14
+ * @example
15
+ * ```javascript
16
+ * const t = await textmode.create({
17
+ * width: 800,
18
+ * height: 600,
19
+ * })
20
+ *
21
+ * t.draw(() => {
22
+ * // Set the background color to black
23
+ * t.background(0);
24
+ *
25
+ * const centerX = t.width / 2;
26
+ * const centerY = t.height / 2;
27
+ * const radius = Math.min(t.width, t .height) / 3;
28
+ * const speed = 0.02; // Adjust speed of rotation
29
+ *
30
+ * const angle = t.frameCount * speed;
31
+ * const x = centerX + Math.cos(angle) * radius - 100;
32
+ * const y = centerY + Math.sin(angle) * radius - 50;
33
+ *
34
+ * // Set the fill color to white
35
+ * t.fill(255);
36
+ *
37
+ * // Draw a rectangle with the fill color
38
+ * t.rect(x, y, 200, 150);
39
+ * });
40
+ * ```
41
+ */
42
+ fill(r: number, g?: number, b?: number, a?: number): void;
43
+ /**
44
+ * Sets the stroke color for subsequent rendering operations
45
+ * @param r Red component (0-255)
46
+ * @param g Green component (0-255, optional)
47
+ * @param b Blue component (0-255, optional)
48
+ * @param a Alpha component (0-255, optional)
49
+ *
50
+ * @example
51
+ * ```javascript
52
+ * const t = await textmode.create({
53
+ * width: 800,
54
+ * height: 600,
55
+ * })
56
+ *
57
+ * t.draw(() => {
58
+ * // Set the background color to black
59
+ * t.background(0);
60
+ *
61
+ * // Set stroke color to red and stroke weight to 4 pixels
62
+ * t.stroke(255, 0, 0);
63
+ * t.strokeWeight(4);
64
+ *
65
+ * // Draw a rectangle with red stroke
66
+ * t.rect(100, 100, 200, 150);
67
+ *
68
+ * // Rectangle with both fill and stroke
69
+ * t.fill(0, 255, 0);
70
+ * t.stroke(0, 0, 255);
71
+ * t.strokeWeight(2);
72
+ * t.rect(350, 100, 200, 150);
73
+ * });
74
+ * ```
75
+ */
76
+ stroke(r: number, g?: number, b?: number, a?: number): void;
77
+ /**
78
+ * Sets the stroke weight (thickness) for subsequent stroke operations
79
+ * @param weight The stroke thickness in pixels
80
+ *
81
+ * @example
82
+ * ```javascript
83
+ * const t = await textmode.create({
84
+ * width: 800,
85
+ * height: 600,
86
+ * })
87
+ *
88
+ * t.draw(() => {
89
+ * t.background(0);
90
+ *
91
+ * // Thin stroke
92
+ * t.stroke(255);
93
+ * t.strokeWeight(1);
94
+ * t.rect(50, 50, 100, 100);
95
+ *
96
+ * // Thick stroke
97
+ * t.strokeWeight(8);
98
+ * t.rect(200, 50, 100, 100);
99
+ * });
100
+ * ```
101
+ */
102
+ strokeWeight(weight: number): void;
103
+ /**
104
+ * Disables stroke rendering for subsequent operations
105
+ *
106
+ * @example
107
+ * ```javascript
108
+ * const t = await textmode.create({
109
+ * width: 800,
110
+ * height: 600,
111
+ * })
112
+ *
113
+ * t.draw(() => {
114
+ * t.background(0);
115
+ *
116
+ * // Rectangle with stroke
117
+ * t.fill(255, 0, 0);
118
+ * t.stroke(0, 255, 0);
119
+ * t.strokeWeight(4);
120
+ * t.rect(100, 100, 150, 100);
121
+ *
122
+ * // Rectangle without stroke (fill only)
123
+ * t.noStroke();
124
+ * t.rect(300, 100, 150, 100);
125
+ * });
126
+ * ```
127
+ */
128
+ noStroke(): void;
129
+ /**
130
+ * Disables fill rendering for subsequent operations
131
+ *
132
+ * @example
133
+ * ```javascript
134
+ * const t = await textmode.create({
135
+ * width: 800,
136
+ * height: 600,
137
+ * })
138
+ *
139
+ * t.draw(() => {
140
+ * t.background(0);
141
+ *
142
+ * // Rectangle with fill
143
+ * t.fill(255, 0, 0);
144
+ * t.stroke(0, 255, 0);
145
+ * t.strokeWeight(4);
146
+ * t.rect(100, 100, 150, 100);
147
+ *
148
+ * // Rectangle without fill (stroke only)
149
+ * t.noFill();
150
+ * t.rect(300, 100, 150, 100);
151
+ * });
152
+ * ```
153
+ */
154
+ noFill(): void;
155
+ /**
156
+ * Sets the rotation angle for subsequent rendering operations
157
+ * @param degrees The rotation angle in degrees
158
+ *
159
+ * @example
160
+ * ```javascript
161
+ * const t = await textmode.create({
162
+ * width: 800,
163
+ * height: 600,
164
+ * })
165
+ *
166
+ * t.draw(() => {
167
+ * t.background(0);
168
+ *
169
+ * // Normal rectangle
170
+ * t.fill(255, 0, 0);
171
+ * t.rect(100, 100, 150, 100);
172
+ *
173
+ * // Rotated rectangle
174
+ * t.push(); // Save current state
175
+ * t.rotate(45); // Rotate 45 degrees
176
+ * t.fill(0, 255, 0);
177
+ * t.rect(300, 100, 150, 100);
178
+ * t.pop(); // Restore state (no rotation)
179
+ *
180
+ * // Back to normal (no rotation)
181
+ * t.fill(0, 0, 255);
182
+ * t.rect(500, 100, 150, 100);
183
+ * });
184
+ * ```
185
+ */
186
+ rotate(degrees: number): void;
187
+ /**
188
+ * Save the current rendering state (fill, stroke, etc.) to the state stack.
189
+ * Use with {@link pop} to isolate style changes within a block.
190
+ *
191
+ * @example
192
+ * ```javascript
193
+ * const t = await textmode.create({
194
+ * width: 800,
195
+ * height: 600,
196
+ * })
197
+ *
198
+ * t.draw(() => {
199
+ * t.background(0);
200
+ *
201
+ * // Set initial styles
202
+ * t.fill(255, 0, 0); // Red fill
203
+ * t.stroke(0, 255, 0); // Green stroke
204
+ * t.strokeWeight(4); // Thick stroke
205
+ *
206
+ * t.push(); // Save current state
207
+ *
208
+ * // Change styles temporarily
209
+ * t.fill(0, 0, 255); // Blue fill
210
+ * t.stroke(255, 255, 0); // Yellow stroke
211
+ * t.strokeWeight(2); // Thin stroke
212
+ * t.rect(100, 100, 150, 100);
213
+ *
214
+ * t.pop(); // Restore previous state
215
+ *
216
+ * // Back to red fill, green stroke, thick stroke
217
+ * t.rect(300, 100, 150, 100);
218
+ * });
219
+ * ```
220
+ */
221
+ push(): void;
222
+ /**
223
+ * Restore the most recently saved rendering state from the state stack.
224
+ * Use with {@link push} to isolate style changes within a block.
225
+ *
226
+ * @example
227
+ * ```javascript
228
+ * const t = await textmode.create({
229
+ * width: 800,
230
+ * height: 600,
231
+ * })
232
+ *
233
+ * t.draw(() => {
234
+ * t.background(0);
235
+ *
236
+ * // Default styles
237
+ * t.fill(255); // White fill
238
+ * t.stroke(0); // Black stroke
239
+ * t.strokeWeight(1); // Thin stroke
240
+ *
241
+ * t.push(); // Save current state
242
+ *
243
+ * // Temporary style changes
244
+ * t.fill(255, 0, 0); // Red fill
245
+ * t.strokeWeight(8); // Thick stroke
246
+ * t.rect(50, 50, 100, 100);
247
+ *
248
+ * t.push(); // Save red style state
249
+ *
250
+ * t.fill(0, 255, 0); // Green fill
251
+ * t.noStroke(); // No stroke
252
+ * t.rect(200, 50, 100, 100);
253
+ *
254
+ * t.pop(); // Back to red fill, thick stroke
255
+ * t.rect(350, 50, 100, 100);
256
+ *
257
+ * t.pop(); // Back to white fill, black stroke, thin stroke
258
+ * t.rect(500, 50, 100, 100);
259
+ * });
260
+ * ```
261
+ */
262
+ pop(): void;
263
+ /**
264
+ * Draw a rectangle with the current shader or fill color.
265
+ * @param x X-coordinate of the rectangle
266
+ * @param y Y-coordinate of the rectangle
267
+ * @param width Width of the rectangle
268
+ * @param height Height of the rectangle
269
+ *
270
+ * @example
271
+ * ```javascript
272
+ * const t = await textmode.create({
273
+ * width: 800,
274
+ * height: 600,
275
+ * })
276
+ *
277
+ * t.draw(() => {
278
+ * // Set the background color to black
279
+ * t.background(0);
280
+ *
281
+ * const centerX = t.width / 2;
282
+ * const centerY = t.height / 2;
283
+ * const radius = Math.min(t.width, t .height) / 3;
284
+ * const speed = 0.02; // Adjust speed of rotation
285
+ *
286
+ * const angle = t.frameCount * speed;
287
+ * const x = centerX + Math.cos(angle) * radius - 100;
288
+ * const y = centerY + Math.sin(angle) * radius - 50;
289
+ *
290
+ * // Set the fill color to white
291
+ * t.fill(255);
292
+ *
293
+ * // Draw a rectangle with the fill color
294
+ * t.rect(x, y, 200, 150);
295
+ * });
296
+ * ```
297
+ */
298
+ rect(x: number, y: number, width?: number, height?: number): void;
299
+ /**
300
+ * Draw a line from point (x1, y1) to point (x2, y2) with the current stroke settings.
301
+ * Lines respect stroke color, stroke weight, and rotation, but ignore fill properties.
302
+ * @param x1 X-coordinate of the line start point
303
+ * @param y1 Y-coordinate of the line start point
304
+ * @param x2 X-coordinate of the line end point
305
+ * @param y2 Y-coordinate of the line end point
306
+ *
307
+ * @example
308
+ * ```javascript
309
+ * const t = await textmode.create({
310
+ * width: 800,
311
+ * height: 600,
312
+ * })
313
+ *
314
+ * t.draw(() => {
315
+ * // Set the background color to black
316
+ * t.background(0);
317
+ *
318
+ * // Draw a simple line
319
+ * t.stroke(255, 0, 0); // Red stroke
320
+ * t.strokeWeight(2); // 2px thick
321
+ * t.line(100, 100, 300, 200);
322
+ *
323
+ * // Draw an animated rotating line
324
+ * t.push();
325
+ * t.stroke(0, 255, 0); // Green stroke
326
+ * t.strokeWeight(4); // 4px thick
327
+ * t.rotate(t.frameCount * 2); // Rotate based on frame count
328
+ * t.line(400, 300, 600, 300);
329
+ * t.pop();
330
+ *
331
+ * // Draw a thick yellow line
332
+ * t.stroke(255, 255, 0); // Yellow stroke
333
+ * t.strokeWeight(8); // 8px thick
334
+ * t.line(200, 400, 400, 500);
335
+ *
336
+ * // Line with no stroke won't be visible
337
+ * t.noStroke();
338
+ * t.line(500, 100, 700, 200); // This won't render
339
+ * });
340
+ * ```
341
+ */
342
+ line(x1: number, y1: number, x2: number, y2: number): void;
343
+ /**
344
+ * Set the background color for the canvas.
345
+ * @param r Red component (0-255)
346
+ * @param g Green component (0-255, optional)
347
+ * @param b Blue component (0-255, optional)
348
+ * @param a Alpha component (0-255, optional)
349
+ *
350
+ * @example
351
+ * ```javascript
352
+ * const t = await textmode.create({
353
+ * width: 800,
354
+ * height: 600,
355
+ * })
356
+ *
357
+ * t.draw(() => {
358
+ * // Set the background color to black
359
+ * t.background(0);
360
+ *
361
+ * const centerX = t.width / 2;
362
+ * const centerY = t.height / 2;
363
+ * const radius = Math.min(t.width, t .height) / 3;
364
+ * const speed = 0.02; // Adjust speed of rotation
365
+ *
366
+ * const angle = t.frameCount * speed;
367
+ * const x = centerX + Math.cos(angle) * radius - 100;
368
+ * const y = centerY + Math.sin(angle) * radius - 50;
369
+ *
370
+ * // Set the fill color to white
371
+ * t.fill(255);
372
+ *
373
+ * // Draw a rectangle with the fill color
374
+ * t.rect(x, y, 200, 150);
375
+ * });
376
+ * ```
377
+ */
378
+ background(r: number, g?: number, b?: number, a?: number): void;
379
+ /**
380
+ * Create a shader program from vertex and fragment source code.
381
+ * @param vertexSource The GLSL source code for the vertex shader.
382
+ * @param fragmentSource The GLSL source code for the fragment shader.
383
+ * @returns The created shader program for use in `textmode.js`.
384
+ */
385
+ createShader(vertexSource: string, fragmentSource: string): Shader;
386
+ /**
387
+ * Create a filter shader program from a fragment source code.
388
+ * @param fragmentSource The GLSL source code for the fragment shader.
389
+ * @returns The created filter shader program for use in `textmode.js`.
390
+ */
391
+ createFilterShader(fragmentSource: string): Shader;
392
+ /**
393
+ * Set the current shader for rendering.
394
+ * @param shader The shader program to use for rendering.
395
+ */
396
+ shader(shader: Shader): void;
397
+ /**
398
+ * Set a uniform variable for the current shader.
399
+ * @param name The name of the uniform variable to set.
400
+ * @param value The value to set for the uniform variable.
401
+ */
402
+ setUniform(name: string, value: any): void;
403
+ }
404
+ /**
405
+ * Mixin that adds rendering capabilities to a class by delegating to GLRenderer
406
+ * @param Base The base class to extend
407
+ * @returns Extended class with rendering capabilities
408
+ */
409
+ export declare const RenderingMixin: Mixin<RenderingCapabilities>;