textmode.js 0.1.9 → 0.2.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 (63) hide show
  1. package/README.md +4 -4
  2. package/dist/textmode.esm.js +1431 -1480
  3. package/dist/textmode.esm.min.js +1491 -1540
  4. package/dist/textmode.umd.js +19 -56
  5. package/dist/textmode.umd.min.js +19 -56
  6. package/dist/types/Textmode.d.ts +10 -38
  7. package/dist/types/export/base/DataExtractor.d.ts +3 -3
  8. package/dist/types/export/image/ImageExporter.d.ts +4 -11
  9. package/dist/types/export/image/types.d.ts +2 -3
  10. package/dist/types/export/svg/SVGExporter.d.ts +1 -1
  11. package/dist/types/export/svg/types.d.ts +1 -0
  12. package/dist/types/export/txt/TXTExporter.d.ts +1 -1
  13. package/dist/types/export/txt/types.d.ts +2 -2
  14. package/dist/types/index.d.ts +1 -7
  15. package/dist/types/rendering/index.d.ts +0 -1
  16. package/dist/types/rendering/webgl/DrawQueue.d.ts +26 -0
  17. package/dist/types/rendering/webgl/Framebuffer.d.ts +41 -40
  18. package/dist/types/rendering/webgl/InstanceBatch.d.ts +91 -0
  19. package/dist/types/rendering/webgl/InstanceData.d.ts +65 -0
  20. package/dist/types/rendering/webgl/RenderPipeline.d.ts +15 -0
  21. package/dist/types/rendering/webgl/RenderState.d.ts +76 -0
  22. package/dist/types/rendering/webgl/Renderer.d.ts +54 -81
  23. package/dist/types/rendering/webgl/Shader.d.ts +11 -16
  24. package/dist/types/rendering/webgl/VAOManager.d.ts +15 -0
  25. package/dist/types/rendering/webgl/geometries/Arc.d.ts +16 -0
  26. package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +35 -29
  27. package/dist/types/rendering/webgl/geometries/BezierCurve.d.ts +22 -0
  28. package/dist/types/rendering/webgl/geometries/Ellipse.d.ts +20 -0
  29. package/dist/types/rendering/webgl/geometries/Line.d.ts +13 -4
  30. package/dist/types/rendering/webgl/geometries/Rectangle.d.ts +13 -8
  31. package/dist/types/rendering/webgl/geometries/Triangle.d.ts +20 -0
  32. package/dist/types/rendering/webgl/geometries/index.d.ts +4 -1
  33. package/dist/types/rendering/webgl/index.d.ts +17 -1
  34. package/dist/types/rendering/webgl/types/DrawCommand.d.ts +9 -0
  35. package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +144 -0
  36. package/dist/types/rendering/webgl/types/RenderTypes.d.ts +12 -0
  37. package/dist/types/textmode/AnimationController.d.ts +81 -0
  38. package/dist/types/textmode/Canvas.d.ts +18 -19
  39. package/dist/types/textmode/Grid.d.ts +1 -34
  40. package/dist/types/textmode/Textmodifier.d.ts +36 -277
  41. package/dist/types/textmode/font/CharacterColorMapper.d.ts +3 -3
  42. package/dist/types/textmode/font/TextmodeFont.d.ts +6 -11
  43. package/dist/types/textmode/font/types.d.ts +1 -1
  44. package/dist/types/textmode/font/typr/types.d.ts +1 -1
  45. package/dist/types/textmode/font/utils/index.d.ts +0 -1
  46. package/dist/types/textmode/mixins/AnimationMixin.d.ts +120 -0
  47. package/dist/types/textmode/mixins/ExportMixin.d.ts +4 -6
  48. package/dist/types/textmode/mixins/FontMixin.d.ts +4 -10
  49. package/dist/types/textmode/mixins/RenderingMixin.d.ts +224 -246
  50. package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +13 -4
  51. package/dist/types/textmode/mixins/index.d.ts +2 -2
  52. package/package.json +1 -1
  53. package/dist/types/ColorPalette.d.ts +0 -35
  54. package/dist/types/rendering/core/Framebuffer.d.ts +0 -140
  55. package/dist/types/rendering/core/Shader.d.ts +0 -59
  56. package/dist/types/rendering/core/index.d.ts +0 -2
  57. package/dist/types/textmode/ConversionPipeline.d.ts +0 -110
  58. package/dist/types/textmode/converters/BrightnessConverter.d.ts +0 -58
  59. package/dist/types/textmode/converters/Converter.d.ts +0 -69
  60. package/dist/types/textmode/converters/FeatureConverter.d.ts +0 -128
  61. package/dist/types/textmode/converters/index.d.ts +0 -3
  62. package/dist/types/textmode/font/utils/FontConstants.d.ts +0 -60
  63. package/dist/types/textmode/mixins/ConversionMixin.d.ts +0 -62
@@ -9,11 +9,8 @@ export interface FontCapabilities {
9
9
  *
10
10
  * @example
11
11
  * ```javascript
12
- * // Fetch a canvas element to apply textmode rendering to
13
- * const canvas = document.querySelector('canvas#myCanvas');
14
- *
15
12
  * // Create a Textmodifier instance
16
- * const textmodifier = await textmode.create(canvas);
13
+ * const textmodifier = await textmode.create();
17
14
  *
18
15
  * // Load a custom font from a URL
19
16
  * await textmodifier.loadFont('https://example.com/fonts/myfont.ttf');
@@ -29,14 +26,11 @@ export interface FontCapabilities {
29
26
  *
30
27
  * @example
31
28
  * ```javascript
32
- * // Fetch a canvas element to apply textmode rendering to
33
- * const canvas = document.querySelector('canvas#myCanvas');
34
- *
35
29
  * // Create a Textmodifier instance
36
- * const textmodifier = await textmode.create(canvas);
30
+ * const textmodifier = await textmode.create();
37
31
  *
38
- * // Set the font size to 24
39
- * textmodifier.fontSize(24);
32
+ * // Set the font size to 32
33
+ * textmodifier.fontSize(32);
40
34
  * ```
41
35
  */
42
36
  fontSize(size: number): void;
@@ -1,16 +1,11 @@
1
1
  import type { Mixin } from './TextmodifierMixin';
2
- import type { Framebuffer, Shader, UniformValue } from '../../rendering';
3
- import type { FramebufferOptions } from '../../rendering/core/Framebuffer';
4
2
  /**
5
3
  * Interface for rendering capabilities that will be mixed into Textmodifier
6
4
  */
7
5
  export interface RenderingCapabilities {
8
6
  /**
9
- * Sets the fill color for subsequent rendering operations
10
- * @param r Red component (0-255)
11
- * @param g Green component (0-255, optional)
12
- * @param b Blue component (0-255, optional)
13
- * @param a Alpha component (0-255, optional)
7
+ * Sets the rotation angle for subsequent shape rendering operations
8
+ * @param degrees The rotation angle in degrees
14
9
  *
15
10
  * @example
16
11
  * ```javascript
@@ -20,33 +15,16 @@ export interface RenderingCapabilities {
20
15
  * })
21
16
  *
22
17
  * t.draw(() => {
23
- * // Set the background color to black
24
18
  * t.background(0);
25
19
  *
26
- * const centerX = t.width / 2;
27
- * const centerY = t.height / 2;
28
- * const radius = Math.min(t.width, t .height) / 3;
29
- * const speed = 0.02; // Adjust speed of rotation
30
- *
31
- * const angle = t.frameCount * speed;
32
- * const x = centerX + Math.cos(angle) * radius - 100;
33
- * const y = centerY + Math.sin(angle) * radius - 50;
34
- *
35
- * // Set the fill color to white
36
- * t.fill(255);
37
- *
38
- * // Draw a rectangle with the fill color
39
- * t.rect(x, y, 200, 150);
20
+ * // todo...
40
21
  * });
41
22
  * ```
42
23
  */
43
- fill(r: number, g?: number, b?: number, a?: number): void;
24
+ rotate(degrees: number): void;
44
25
  /**
45
- * Sets the stroke color for subsequent rendering operations
46
- * @param r Red component (0-255)
47
- * @param g Green component (0-255, optional)
48
- * @param b Blue component (0-255, optional)
49
- * @param a Alpha component (0-255, optional)
26
+ * Save the current rendering state to the state stack.
27
+ * Use with {@link pop} to isolate style changes within a block.
50
28
  *
51
29
  * @example
52
30
  * ```javascript
@@ -56,28 +34,18 @@ export interface RenderingCapabilities {
56
34
  * })
57
35
  *
58
36
  * t.draw(() => {
59
- * // Set the background color to black
60
37
  * t.background(0);
61
38
  *
62
- * // Set stroke color to red and stroke weight to 4 pixels
63
- * t.stroke(255, 0, 0);
64
- * t.strokeWeight(4);
65
- *
66
- * // Draw a rectangle with red stroke
67
- * t.rect(100, 100, 200, 150);
68
- *
69
- * // Rectangle with both fill and stroke
70
- * t.fill(0, 255, 0);
71
- * t.stroke(0, 0, 255);
72
- * t.strokeWeight(2);
73
- * t.rect(350, 100, 200, 150);
39
+ * t.push(); // Save current state
40
+ * // todo...
41
+ * t.pop(); // Restore previous state
74
42
  * });
75
43
  * ```
76
44
  */
77
- stroke(r: number, g?: number, b?: number, a?: number): void;
45
+ push(): void;
78
46
  /**
79
- * Sets the stroke weight (thickness) for subsequent stroke operations
80
- * @param weight The stroke thickness in pixels
47
+ * Restore the most recently saved rendering state from the state stack.
48
+ * Use with {@link push} to isolate style changes within a block.
81
49
  *
82
50
  * @example
83
51
  * ```javascript
@@ -89,20 +57,19 @@ export interface RenderingCapabilities {
89
57
  * t.draw(() => {
90
58
  * t.background(0);
91
59
  *
92
- * // Thin stroke
93
- * t.stroke(255);
94
- * t.strokeWeight(1);
95
- * t.rect(50, 50, 100, 100);
96
- *
97
- * // Thick stroke
98
- * t.strokeWeight(8);
99
- * t.rect(200, 50, 100, 100);
60
+ * t.push(); // Save current state
61
+ * // todo...
62
+ * t.pop(); // Restore previous state
100
63
  * });
101
64
  * ```
102
65
  */
103
- strokeWeight(weight: number): void;
66
+ pop(): void;
104
67
  /**
105
- * Disables stroke rendering for subsequent operations
68
+ * Draw a rectangle with the current settings.
69
+ * @param x X-coordinate of the rectangle
70
+ * @param y Y-coordinate of the rectangle
71
+ * @param width Width of the rectangle
72
+ * @param height Height of the rectangle
106
73
  *
107
74
  * @example
108
75
  * ```javascript
@@ -112,23 +79,20 @@ export interface RenderingCapabilities {
112
79
  * })
113
80
  *
114
81
  * t.draw(() => {
82
+ * // Set the background color to black
115
83
  * t.background(0);
116
84
  *
117
- * // Rectangle with stroke
118
- * t.fill(255, 0, 0);
119
- * t.stroke(0, 255, 0);
120
- * t.strokeWeight(4);
121
- * t.rect(100, 100, 150, 100);
122
- *
123
- * // Rectangle without stroke (fill only)
124
- * t.noStroke();
125
- * t.rect(300, 100, 150, 100);
85
+ * // todo...
126
86
  * });
127
87
  * ```
128
88
  */
129
- noStroke(): void;
89
+ rect(x: number, y: number, width?: number, height?: number): void;
130
90
  /**
131
- * Disables fill rendering for subsequent operations
91
+ * Draw a line from point (x1, y1) to point (x2, y2) with the settings.
92
+ * @param x1 X-coordinate of the line start point
93
+ * @param y1 Y-coordinate of the line start point
94
+ * @param x2 X-coordinate of the line end point
95
+ * @param y2 Y-coordinate of the line end point
132
96
  *
133
97
  * @example
134
98
  * ```javascript
@@ -138,24 +102,20 @@ export interface RenderingCapabilities {
138
102
  * })
139
103
  *
140
104
  * t.draw(() => {
105
+ * // Set the background color to black
141
106
  * t.background(0);
142
107
  *
143
- * // Rectangle with fill
144
- * t.fill(255, 0, 0);
145
- * t.stroke(0, 255, 0);
146
- * t.strokeWeight(4);
147
- * t.rect(100, 100, 150, 100);
148
- *
149
- * // Rectangle without fill (stroke only)
150
- * t.noFill();
151
- * t.rect(300, 100, 150, 100);
108
+ * // todo
152
109
  * });
153
110
  * ```
154
111
  */
155
- noFill(): void;
112
+ line(x1: number, y1: number, x2: number, y2: number): void;
156
113
  /**
157
- * Sets the rotation angle for subsequent rendering operations
158
- * @param degrees The rotation angle in degrees
114
+ * Set the background color for the canvas.
115
+ * @param r Red component (0-255)
116
+ * @param g Green component (0-255)
117
+ * @param b Blue component (0-255)
118
+ * @param a Alpha component (0-255)
159
119
  *
160
120
  * @example
161
121
  * ```javascript
@@ -165,64 +125,59 @@ export interface RenderingCapabilities {
165
125
  * })
166
126
  *
167
127
  * t.draw(() => {
168
- * t.background(0);
169
- *
170
- * // Normal rectangle
171
- * t.fill(255, 0, 0);
172
- * t.rect(100, 100, 150, 100);
173
- *
174
- * // Rotated rectangle
175
- * t.push(); // Save current state
176
- * t.rotate(45); // Rotate 45 degrees
177
- * t.fill(0, 255, 0);
178
- * t.rect(300, 100, 150, 100);
179
- * t.pop(); // Restore state (no rotation)
180
- *
181
- * // Back to normal (no rotation)
182
- * t.fill(0, 0, 255);
183
- * t.rect(500, 100, 150, 100);
128
+ * // Set the background color to white
129
+ * t.background(255);
184
130
  * });
185
131
  * ```
186
132
  */
187
- rotate(degrees: number): void;
133
+ background(r: number, g?: number, b?: number, a?: number): void;
188
134
  /**
189
- * Save the current rendering state (fill, stroke, etc.) to the state stack.
190
- * Use with {@link pop} to isolate style changes within a block.
135
+ * Clear the canvas.
191
136
  *
192
137
  * @example
193
138
  * ```javascript
194
139
  * const t = await textmode.create({
195
- * width: 800,
196
- * height: 600,
140
+ * width: 800,
141
+ * height: 600,
197
142
  * })
198
143
  *
199
144
  * t.draw(() => {
200
- * t.background(0);
201
- *
202
- * // Set initial styles
203
- * t.fill(255, 0, 0); // Red fill
204
- * t.stroke(0, 255, 0); // Green stroke
205
- * t.strokeWeight(4); // Thick stroke
206
- *
207
- * t.push(); // Save current state
208
- *
209
- * // Change styles temporarily
210
- * t.fill(0, 0, 255); // Blue fill
211
- * t.stroke(255, 255, 0); // Yellow stroke
212
- * t.strokeWeight(2); // Thin stroke
213
- * t.rect(100, 100, 150, 100);
145
+ * // Clear the canvas
146
+ * t.clear();
147
+ * });
148
+ * ```
149
+ */
150
+ clear(): void;
151
+ /**
152
+ * Update the line weight (thickness) for subsequent {@link line} and {@link bezierCurve} calls.
153
+ * @param weight The line weight (thickness) to set.
214
154
  *
215
- * t.pop(); // Restore previous state
155
+ * @example
156
+ * ```javascript
157
+ * const t = await textmode.create({
158
+ * width: 800,
159
+ * height: 600,
160
+ * })
216
161
  *
217
- * // Back to red fill, green stroke, thick stroke
218
- * t.rect(300, 100, 150, 100);
162
+ * t.draw(() => {
163
+ * t.background(0);
164
+ * t.lineWeight(1); // Thin line
165
+ * t.line(0, 0, t.grid.cols, t.grid.rows);
219
166
  * });
220
167
  * ```
221
168
  */
222
- push(): void;
169
+ lineWeight(weight: number): void;
223
170
  /**
224
- * Restore the most recently saved rendering state from the state stack.
225
- * Use with {@link push} to isolate style changes within a block.
171
+ * Draw a smooth cubic bezier curve between two points with two control points.
172
+ * The curve thickness is controlled by the current {@link lineWeight} setting.
173
+ * @param x1 Start point X coordinate
174
+ * @param y1 Start point Y coordinate
175
+ * @param cp1x First control point X coordinate
176
+ * @param cp1y First control point Y coordinate
177
+ * @param cp2x Second control point X coordinate
178
+ * @param cp2y Second control point Y coordinate
179
+ * @param x2 End point X coordinate
180
+ * @param y2 End point Y coordinate
226
181
  *
227
182
  * @example
228
183
  * ```javascript
@@ -234,39 +189,14 @@ export interface RenderingCapabilities {
234
189
  * t.draw(() => {
235
190
  * t.background(0);
236
191
  *
237
- * // Default styles
238
- * t.fill(255); // White fill
239
- * t.stroke(0); // Black stroke
240
- * t.strokeWeight(1); // Thin stroke
241
- *
242
- * t.push(); // Save current state
243
- *
244
- * // Temporary style changes
245
- * t.fill(255, 0, 0); // Red fill
246
- * t.strokeWeight(8); // Thick stroke
247
- * t.rect(50, 50, 100, 100);
248
- *
249
- * t.push(); // Save red style state
250
- *
251
- * t.fill(0, 255, 0); // Green fill
252
- * t.noStroke(); // No stroke
253
- * t.rect(200, 50, 100, 100);
254
- *
255
- * t.pop(); // Back to red fill, thick stroke
256
- * t.rect(350, 50, 100, 100);
257
- *
258
- * t.pop(); // Back to white fill, black stroke, thin stroke
259
- * t.rect(500, 50, 100, 100);
192
+ * // todo
260
193
  * });
261
194
  * ```
262
195
  */
263
- pop(): void;
196
+ bezierCurve(x1: number, y1: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): void;
264
197
  /**
265
- * Draw a rectangle with the current shader or fill color.
266
- * @param x X-coordinate of the rectangle
267
- * @param y Y-coordinate of the rectangle
268
- * @param width Width of the rectangle
269
- * @param height Height of the rectangle
198
+ * Set the character to be used for subsequent rendering operations.
199
+ * @param character The character to set
270
200
  *
271
201
  * @example
272
202
  * ```javascript
@@ -276,34 +206,19 @@ export interface RenderingCapabilities {
276
206
  * })
277
207
  *
278
208
  * t.draw(() => {
279
- * // Set the background color to black
280
209
  * t.background(0);
281
- *
282
- * const centerX = t.width / 2;
283
- * const centerY = t.height / 2;
284
- * const radius = Math.min(t.width, t .height) / 3;
285
- * const speed = 0.02; // Adjust speed of rotation
286
- *
287
- * const angle = t.frameCount * speed;
288
- * const x = centerX + Math.cos(angle) * radius - 100;
289
- * const y = centerY + Math.sin(angle) * radius - 50;
290
- *
291
- * // Set the fill color to white
292
- * t.fill(255);
293
- *
294
- * // Draw a rectangle with the fill color
295
- * t.rect(x, y, 200, 150);
210
+ * t.char('█');
211
+ * t.rect(10, 10, 5, 5);
296
212
  * });
297
213
  * ```
298
214
  */
299
- rect(x: number, y: number, width?: number, height?: number): void;
215
+ char(character: string): void;
300
216
  /**
301
- * Draw a line from point (x1, y1) to point (x2, y2) with the current stroke settings.
302
- * Lines respect stroke color, stroke weight, and rotation, but ignore fill properties.
303
- * @param x1 X-coordinate of the line start point
304
- * @param y1 Y-coordinate of the line start point
305
- * @param x2 X-coordinate of the line end point
306
- * @param y2 Y-coordinate of the line end point
217
+ * Set the character color for subsequent rendering operations.
218
+ * @param r Red component (0-255)
219
+ * @param g Green component (0-255)
220
+ * @param b Blue component (0-255)
221
+ * @param a Alpha component (0-255)
307
222
  *
308
223
  * @example
309
224
  * ```javascript
@@ -313,40 +228,19 @@ export interface RenderingCapabilities {
313
228
  * })
314
229
  *
315
230
  * t.draw(() => {
316
- * // Set the background color to black
317
231
  * t.background(0);
318
- *
319
- * // Draw a simple line
320
- * t.stroke(255, 0, 0); // Red stroke
321
- * t.strokeWeight(2); // 2px thick
322
- * t.line(100, 100, 300, 200);
323
- *
324
- * // Draw an animated rotating line
325
- * t.push();
326
- * t.stroke(0, 255, 0); // Green stroke
327
- * t.strokeWeight(4); // 4px thick
328
- * t.rotate(t.frameCount * 2); // Rotate based on frame count
329
- * t.line(400, 300, 600, 300);
330
- * t.pop();
331
- *
332
- * // Draw a thick yellow line
333
- * t.stroke(255, 255, 0); // Yellow stroke
334
- * t.strokeWeight(8); // 8px thick
335
- * t.line(200, 400, 400, 500);
336
- *
337
- * // Line with no stroke won't be visible
338
- * t.noStroke();
339
- * t.line(500, 100, 700, 200); // This won't render
232
+ * t.charColor(255, 0, 0, 255); // Red character
233
+ * t.rect(10, 10, 5, 5);
340
234
  * });
341
235
  * ```
342
236
  */
343
- line(x1: number, y1: number, x2: number, y2: number): void;
237
+ charColor(r: number, g: number, b: number, a: number): void;
344
238
  /**
345
- * Set the background color for the canvas.
239
+ * Set the cell background color for subsequent rendering operations.
346
240
  * @param r Red component (0-255)
347
- * @param g Green component (0-255, optional)
348
- * @param b Blue component (0-255, optional)
349
- * @param a Alpha component (0-255, optional)
241
+ * @param g Green component (0-255)
242
+ * @param b Blue component (0-255)
243
+ * @param a Alpha component (0-255)
350
244
  *
351
245
  * @example
352
246
  * ```javascript
@@ -356,72 +250,156 @@ export interface RenderingCapabilities {
356
250
  * })
357
251
  *
358
252
  * t.draw(() => {
359
- * // Set the background color to black
360
253
  * t.background(0);
361
- *
362
- * const centerX = t.width / 2;
363
- * const centerY = t.height / 2;
364
- * const radius = Math.min(t.width, t .height) / 3;
365
- * const speed = 0.02; // Adjust speed of rotation
366
- *
367
- * const angle = t.frameCount * speed;
368
- * const x = centerX + Math.cos(angle) * radius - 100;
369
- * const y = centerY + Math.sin(angle) * radius - 50;
370
- *
371
- * // Set the fill color to white
372
- * t.fill(255);
373
- *
374
- * // Draw a rectangle with the fill color
375
- * t.rect(x, y, 200, 150);
254
+ * t.cellColor(0, 255, 0, 255); // Green cell background
255
+ * t.rect(10, 10, 5, 5);
376
256
  * });
377
257
  * ```
378
258
  */
379
- background(r: number, g?: number, b?: number, a?: number): void;
259
+ cellColor(r: number, g: number, b: number, a: number): void;
380
260
  /**
381
- * Create a shader program from vertex and fragment source code.
382
- * @param vertexSource The GLSL source code for the vertex shader.
383
- * @param fragmentSource The GLSL source code for the fragment shader.
384
- * @returns The created shader program for use in `textmode.js`.
385
- * @ignore
261
+ * Toggle horizontal flipping for subsequent character rendering.
262
+ * @param toggle Whether to flip horizontally
263
+ *
264
+ * @example
265
+ * ```javascript
266
+ * const t = await textmode.create({
267
+ * width: 800,
268
+ * height: 600,
269
+ * })
270
+ *
271
+ * t.draw(() => {
272
+ * t.background(0);
273
+ * t.flipHorizontally(true);
274
+ * t.rect(10, 10, 5, 5);
275
+ * });
276
+ * ```
386
277
  */
387
- createShader(vertexSource: string, fragmentSource: string): Shader;
278
+ flipHorizontally(toggle: boolean): void;
388
279
  /**
389
- * Create a filter shader program from a fragment source code.
390
- * @param fragmentSource The GLSL source code for the fragment shader.
391
- * @returns The created filter shader program for use in `textmode.js`.
280
+ * Toggle vertical flipping for subsequent character rendering.
281
+ * @param toggle Whether to flip vertically
282
+ *
283
+ * @example
284
+ * ```javascript
285
+ * const t = await textmode.create({
286
+ * width: 800,
287
+ * height: 600,
288
+ * })
289
+ *
290
+ * t.draw(() => {
291
+ * t.background(0);
292
+ * t.flipVertically(true);
293
+ * t.rect(10, 10, 5, 5);
294
+ * });
295
+ * ```
392
296
  */
393
- createFilterShader(fragmentSource: string): Shader;
297
+ flipVertically(toggle: boolean): void;
394
298
  /**
395
- * Set the current shader for rendering.
396
- * @param shader The shader program to use for rendering.
299
+ * Set the character rotation angle for subsequent character rendering.
300
+ * @param degrees The rotation angle in degrees
301
+ *
302
+ * @example
303
+ * ```javascript
304
+ * const t = await textmode.create({
305
+ * width: 800,
306
+ * height: 600,
307
+ * })
308
+ *
309
+ * t.draw(() => {
310
+ * t.background(0);
311
+ * t.charRotation(45); // Rotate character 45 degrees
312
+ * t.rect(10, 10, 5, 5);
313
+ * });
314
+ * ```
397
315
  */
398
- shader(shader: Shader): void;
316
+ charRotation(degrees: number): void;
399
317
  /**
400
- * Set a uniform variable for the current shader.
401
- * @param name The name of the uniform variable to set.
402
- * @param value The value to set for the uniform variable.
318
+ * Toggle color inversion for subsequent character rendering.
319
+ * @param toggle Whether to invert colors
320
+ *
321
+ * @example
322
+ * ```javascript
323
+ * const t = await textmode.create({
324
+ * width: 800,
325
+ * height: 600,
326
+ * })
327
+ *
328
+ * t.draw(() => {
329
+ * t.background(0);
330
+ * t.invert(true);
331
+ * t.rect(10, 10, 5, 5);
332
+ * });
333
+ * ```
403
334
  */
404
- setUniform(name: string, value: UniformValue): void;
335
+ invert(toggle: boolean): void;
405
336
  /**
406
- * Draw an image to the canvas.
407
- * @param source The image source
408
- * @param posX The x position to draw the image
409
- * @param posY The y position to draw the image
410
- * @param width The width to draw the image (optional)
411
- * @param height The height to draw the image (optional)
337
+ * Draw an ellipse with the current settings.
338
+ * @param x X-coordinate of the ellipse center
339
+ * @param y Y-coordinate of the ellipse center
340
+ * @param width Width of the ellipse
341
+ * @param height Height of the ellipse
342
+ *
343
+ * @example
344
+ * ```javascript
345
+ * const t = await textmode.create({
346
+ * width: 800,
347
+ * height: 600,
348
+ * })
349
+ *
350
+ * t.draw(() => {
351
+ * t.background(0);
352
+ * t.ellipse(20, 15, 10, 8);
353
+ * });
354
+ * ```
412
355
  */
413
- image(source: Framebuffer, posX: number, posY: number, width?: number, height?: number): void;
356
+ ellipse(x: number, y: number, width: number, height: number): void;
414
357
  /**
415
- * Clear the canvas.
358
+ * Draw a triangle with the current settings.
359
+ * @param x1 X-coordinate of the first vertex
360
+ * @param y1 Y-coordinate of the first vertex
361
+ * @param x2 X-coordinate of the second vertex
362
+ * @param y2 Y-coordinate of the second vertex
363
+ * @param x3 X-coordinate of the third vertex
364
+ * @param y3 Y-coordinate of the third vertex
365
+ *
366
+ * @example
367
+ * ```javascript
368
+ * const t = await textmode.create({
369
+ * width: 800,
370
+ * height: 600,
371
+ * })
372
+ *
373
+ * t.draw(() => {
374
+ * t.background(0);
375
+ * t.triangle(10, 10, 20, 10, 15, 20);
376
+ * });
377
+ * ```
416
378
  */
417
- clear(): void;
379
+ triangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
418
380
  /**
419
- * Create a framebuffer.
420
- * @param width The width in pixels
421
- * @param height The height in pixels
422
- * @param options Additional options for the framebuffer
381
+ * Draw an arc with the current settings.
382
+ * @param x X-coordinate of the arc center
383
+ * @param y Y-coordinate of the arc center
384
+ * @param width Width of the arc
385
+ * @param height Height of the arc
386
+ * @param startAngle Starting angle in radians
387
+ * @param endAngle Ending angle in radians
388
+ *
389
+ * @example
390
+ * ```javascript
391
+ * const t = await textmode.create({
392
+ * width: 800,
393
+ * height: 600,
394
+ * })
395
+ *
396
+ * t.draw(() => {
397
+ * t.background(0);
398
+ * t.arc(20, 15, 10, 10, 0, Math.PI);
399
+ * });
400
+ * ```
423
401
  */
424
- createFramebuffer(width: number, height: number, options: FramebufferOptions): Framebuffer;
402
+ arc(x: number, y: number, width: number, height: number, startAngle: number, endAngle: number): void;
425
403
  }
426
404
  /**
427
405
  * Mixin that adds rendering capabilities to a class by delegating to GLRenderer