textmode.js 0.1.6-beta.4 → 0.1.6-beta.5
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.
- package/dist/textmode.js +26 -0
- package/dist/textmode.min.js +25 -0
- package/dist/types/rendering/index.d.ts +0 -5
- package/dist/types/rendering/webgl/Framebuffer.d.ts +2 -9
- package/dist/types/rendering/webgl/Renderer.d.ts +2 -12
- package/dist/types/rendering/webgl/Shader.d.ts +5 -12
- package/dist/types/rendering/webgl/StateCache.d.ts +0 -2
- package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +40 -0
- package/dist/types/rendering/webgl/geometries/Line.d.ts +6 -26
- package/dist/types/rendering/webgl/geometries/Rectangle.d.ts +8 -18
- package/dist/types/rendering/webgl/geometries/index.d.ts +3 -0
- package/dist/types/textmode/Textmodifier.d.ts +27 -589
- package/dist/types/textmode/mixins/ExportMixin.d.ts +44 -0
- package/dist/types/textmode/mixins/FontMixin.d.ts +49 -0
- package/dist/types/textmode/mixins/MixinBase.d.ts +39 -0
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +106 -0
- package/dist/types/textmode/mixins/index.d.ts +4 -0
- package/package.json +4 -16
- package/dist/textmode.esm.js +0 -4374
- package/dist/textmode.esm.min.js +0 -4372
- package/dist/textmode.umd.js +0 -26
- package/dist/textmode.umd.min.js +0 -25
- package/dist/types/rendering/webgl/shapes/LineShape.d.ts +0 -20
- package/dist/types/rendering/webgl/shapes/RectangleShape.d.ts +0 -20
- package/dist/types/rendering/webgl/shapes/Shape.d.ts +0 -21
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { GLRenderer } from '../rendering/webgl/Renderer';
|
|
1
2
|
import { TextmodeFont } from './font';
|
|
2
3
|
import { TextmodeGrid } from './Grid';
|
|
4
|
+
import { TextmodeCanvas } from './Canvas';
|
|
3
5
|
import { TextmodeConversionPipeline } from './ConversionPipeline';
|
|
4
6
|
import type { TextmodeConverter } from './converters';
|
|
5
|
-
import { type
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import type {
|
|
7
|
+
import { type TextmodifierCore } from './mixins';
|
|
8
|
+
import type { RenderingCapabilities } from './mixins/RenderingMixin';
|
|
9
|
+
import type { ExportCapabilities } from './mixins/ExportMixin';
|
|
10
|
+
import type { FontCapabilities } from './mixins/FontMixin';
|
|
9
11
|
/**
|
|
10
12
|
* Supported capture sources for textmode rendering
|
|
11
13
|
*/
|
|
@@ -35,22 +37,28 @@ export type TextmodeOptions = {
|
|
|
35
37
|
*/
|
|
36
38
|
fontSource?: string;
|
|
37
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Base class for mixin application
|
|
42
|
+
*/
|
|
43
|
+
declare class TextmodifierBase implements TextmodifierCore {
|
|
44
|
+
_renderer: GLRenderer;
|
|
45
|
+
_font: TextmodeFont;
|
|
46
|
+
_pipeline: TextmodeConversionPipeline;
|
|
47
|
+
textmodeCanvas: TextmodeCanvas;
|
|
48
|
+
_grid: TextmodeGrid;
|
|
49
|
+
}
|
|
50
|
+
declare const Textmodifier_base: typeof TextmodifierBase;
|
|
38
51
|
/**
|
|
39
52
|
* Manages textmode rendering on a canvas or video element.
|
|
40
53
|
*
|
|
41
54
|
* Each `Textmodifier` instance can be applied to a specific HTML canvas or video element via {@link textmode.create},
|
|
42
55
|
* or created as a standalone instance for independent rendering.
|
|
43
56
|
*/
|
|
44
|
-
export declare class Textmodifier {
|
|
57
|
+
export declare class Textmodifier extends Textmodifier_base {
|
|
45
58
|
/** The element to capture content from (optional for standalone mode) */
|
|
46
59
|
private captureSource;
|
|
47
|
-
/**
|
|
48
|
-
private textmodeCanvas;
|
|
49
|
-
/** Core WebGL renderer */
|
|
50
|
-
private _renderer;
|
|
60
|
+
/** Canvas framebuffer for capturing source content */
|
|
51
61
|
private _canvasFramebuffer;
|
|
52
|
-
private _font;
|
|
53
|
-
private _grid;
|
|
54
62
|
private resizeObserver;
|
|
55
63
|
private _mode;
|
|
56
64
|
private _frameRateLimit;
|
|
@@ -63,182 +71,21 @@ export declare class Textmodifier {
|
|
|
63
71
|
private _frameCount;
|
|
64
72
|
private frameTimeHistory;
|
|
65
73
|
private frameTimeHistorySize;
|
|
66
|
-
private _pipeline;
|
|
67
74
|
private _isDisposed;
|
|
68
75
|
private _standalone;
|
|
69
76
|
private _drawCallback;
|
|
70
77
|
private _resizedCallback;
|
|
71
78
|
private _windowResizeListener;
|
|
72
79
|
private _printDebug;
|
|
73
|
-
|
|
80
|
+
constructor(source?: CaptureSource | null, opts?: TextmodeOptions);
|
|
74
81
|
/**
|
|
75
82
|
* Static factory method for creating and initializing a Textmodifier instance.
|
|
76
83
|
* @param source The HTML canvas or video element to capture content from. Pass `null` for standalone mode.
|
|
77
84
|
* @param opts Optional configuration options for the `Textmodifier` instance.
|
|
78
85
|
* @ignore
|
|
79
86
|
*/
|
|
80
|
-
static create(source?: CaptureSource | null, opts?: TextmodeOptions): Promise<
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Generate the current textmode rendering as a text string.
|
|
84
|
-
* @param options Options for text generation *(excluding filename)*
|
|
85
|
-
* @returns Textmode grid content as a string.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```javascript
|
|
89
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
90
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
91
|
-
*
|
|
92
|
-
* // Create a Textmodifier instance
|
|
93
|
-
* const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
|
|
94
|
-
*
|
|
95
|
-
* // Render a single frame
|
|
96
|
-
* textmodifier.render();
|
|
97
|
-
*
|
|
98
|
-
* // Get the current rendering as a text string
|
|
99
|
-
* const textString = textmodifier.toString({
|
|
100
|
-
* preserveTrailingSpaces: false,
|
|
101
|
-
* lineEnding: 'lf'
|
|
102
|
-
* });
|
|
103
|
-
*
|
|
104
|
-
* // Print to console or use otherwise
|
|
105
|
-
* console.log(textString);
|
|
106
|
-
*
|
|
107
|
-
* ////////
|
|
108
|
-
*
|
|
109
|
-
* // Example with video element
|
|
110
|
-
* const video = document.querySelector('video#myVideo');
|
|
111
|
-
* const videoTextmodifier = await textmode.create(video);
|
|
112
|
-
*
|
|
113
|
-
* // The textmode overlay will automatically update as the video plays
|
|
114
|
-
* video.play();
|
|
115
|
-
*
|
|
116
|
-
* // Get current frame as ASCII
|
|
117
|
-
* const videoFrame = videoTextmodifier.toString();
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
toString(options?: Omit<TXTExportOptions, 'filename'>): string;
|
|
121
|
-
/**
|
|
122
|
-
* Export the current textmode rendering to a TXT file.
|
|
123
|
-
* @param options Options for TXT export
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```javascript
|
|
127
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
128
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
129
|
-
*
|
|
130
|
-
* // Create a Textmodifier instance
|
|
131
|
-
* const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
|
|
132
|
-
*
|
|
133
|
-
* // Render a single frame
|
|
134
|
-
* textmodifier.render();
|
|
135
|
-
*
|
|
136
|
-
* // Export the current rendering to a TXT file
|
|
137
|
-
* textmodifier.saveStrings({
|
|
138
|
-
* filename: 'my_textmode_rendering',
|
|
139
|
-
* preserveTrailingSpaces: false
|
|
140
|
-
* });
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
saveStrings(options?: TXTExportOptions): void;
|
|
144
|
-
/**
|
|
145
|
-
* Generate the current textmode rendering as an SVG string.
|
|
146
|
-
* @param options Options for SVG generation *(excluding filename)*
|
|
147
|
-
* @returns SVG content as a string.
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```javascript
|
|
151
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
152
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
153
|
-
*
|
|
154
|
-
* // Create a Textmodifier instance
|
|
155
|
-
* const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
|
|
156
|
-
*
|
|
157
|
-
* // Render a single frame
|
|
158
|
-
* textmodifier.render();
|
|
159
|
-
*
|
|
160
|
-
* // Get the current rendering as an SVG string
|
|
161
|
-
* const svgString = textmodifier.toSVG({
|
|
162
|
-
* includeBackgroundRectangles: true,
|
|
163
|
-
* drawMode: 'fill'
|
|
164
|
-
* });
|
|
165
|
-
*
|
|
166
|
-
* // Print to console or use otherwise
|
|
167
|
-
* console.log(svgString);
|
|
168
|
-
* ```
|
|
169
|
-
*/
|
|
170
|
-
toSVG(options?: Omit<SVGExportOptions, 'filename'>): string;
|
|
171
|
-
/**
|
|
172
|
-
* Export the current textmode rendering to an SVG file.
|
|
173
|
-
* @param options Options for SVG export
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```javascript
|
|
177
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
178
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
179
|
-
*
|
|
180
|
-
* // Create a Textmodifier instance
|
|
181
|
-
* const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
|
|
182
|
-
*
|
|
183
|
-
* // Render a single frame
|
|
184
|
-
* textmodifier.render();
|
|
185
|
-
*
|
|
186
|
-
* // Export the current rendering to an SVG file
|
|
187
|
-
* textmodifier.saveSVG({
|
|
188
|
-
* filename: 'my_textmode_rendering',
|
|
189
|
-
* });
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
saveSVG(options?: SVGExportOptions): void;
|
|
193
|
-
/**
|
|
194
|
-
* Export the current textmode rendering to an image file.
|
|
195
|
-
* @param filename The filename (without extension) to save the image as
|
|
196
|
-
* @param format The image format ('png', 'jpg', or 'webp')
|
|
197
|
-
* @param options Additional options for image export
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* ```javascript
|
|
201
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
202
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
203
|
-
*
|
|
204
|
-
* // Create a Textmodifier instance
|
|
205
|
-
* const textmodifier = await textmode.create(canvas, {renderMode: 'manual'});
|
|
206
|
-
*
|
|
207
|
-
* // Render a single frame
|
|
208
|
-
* textmodifier.render();
|
|
209
|
-
*
|
|
210
|
-
* // Export the current rendering to a PNG file
|
|
211
|
-
* textmodifier.saveCanvas('my_textmode_rendering', 'png');
|
|
212
|
-
*
|
|
213
|
-
* // Export with custom options
|
|
214
|
-
* textmodifier.saveCanvas('my_textmode_rendering', 'jpg', {
|
|
215
|
-
* quality: 0.8,
|
|
216
|
-
* scale: 2.0,
|
|
217
|
-
* backgroundColor: 'white'
|
|
218
|
-
* });
|
|
219
|
-
* ```
|
|
220
|
-
*/
|
|
221
|
-
saveCanvas(filename: string, format?: ImageFormat, options?: Omit<ImageExportOptions, 'filename' | 'format'>): Promise<void>;
|
|
222
|
-
/**
|
|
223
|
-
* Update the font used for rendering.
|
|
224
|
-
* @param fontSource The URL of the font to load.
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* ```javascript
|
|
228
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
229
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
230
|
-
*
|
|
231
|
-
* // Create a Textmodifier instance
|
|
232
|
-
* const textmodifier = await textmode.create(canvas);
|
|
233
|
-
*
|
|
234
|
-
* // Load a custom font from a URL
|
|
235
|
-
* await textmodifier.loadFont('https://example.com/fonts/myfont.ttf');
|
|
236
|
-
*
|
|
237
|
-
* // Local font example
|
|
238
|
-
* // await textmodifier.loadFont('./fonts/myfont.ttf');
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
loadFont(fontSource: string): Promise<void>;
|
|
87
|
+
static create<T extends Textmodifier>(source?: CaptureSource | null, opts?: TextmodeOptions): Promise<T>;
|
|
88
|
+
setupEventListeners(): void;
|
|
242
89
|
/**
|
|
243
90
|
* Apply textmode rendering to the canvas.
|
|
244
91
|
*
|
|
@@ -282,7 +129,7 @@ export declare class Textmodifier {
|
|
|
282
129
|
/**
|
|
283
130
|
* Start automatic rendering
|
|
284
131
|
*/
|
|
285
|
-
|
|
132
|
+
startAutoRendering(): void;
|
|
286
133
|
/**
|
|
287
134
|
* Update FPS measurement - works for both auto and manual modes
|
|
288
135
|
* Uses a rolling average for smoother frame rate reporting
|
|
@@ -451,23 +298,6 @@ export declare class Textmodifier {
|
|
|
451
298
|
* ```
|
|
452
299
|
*/
|
|
453
300
|
isLooping(): boolean;
|
|
454
|
-
/**
|
|
455
|
-
* Set the font size used for rendering.
|
|
456
|
-
* @param size The font size to set.
|
|
457
|
-
*
|
|
458
|
-
* @example
|
|
459
|
-
* ```javascript
|
|
460
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
461
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
462
|
-
*
|
|
463
|
-
* // Create a Textmodifier instance
|
|
464
|
-
* const textmodifier = await textmode.create(canvas);
|
|
465
|
-
*
|
|
466
|
-
* // Set the font size to 24
|
|
467
|
-
* textmodifier.fontSize(24);
|
|
468
|
-
* ```
|
|
469
|
-
*/
|
|
470
|
-
fontSize(size: number): void;
|
|
471
301
|
/**
|
|
472
302
|
* Set a draw callback function that will be executed before each render.
|
|
473
303
|
* This method is primarily useful for standalone textmodifier instances.
|
|
@@ -549,402 +379,6 @@ export declare class Textmodifier {
|
|
|
549
379
|
* ```
|
|
550
380
|
*/
|
|
551
381
|
converter(name: string): TextmodeConverter | void;
|
|
552
|
-
/**
|
|
553
|
-
* Sets the fill color for subsequent rendering operations
|
|
554
|
-
* @param r Red component (0-255)
|
|
555
|
-
* @param g Green component (0-255, optional)
|
|
556
|
-
* @param b Blue component (0-255, optional)
|
|
557
|
-
* @param a Alpha component (0-255, optional)
|
|
558
|
-
*
|
|
559
|
-
* @example
|
|
560
|
-
* ```javascript
|
|
561
|
-
* const t = await textmode.create({
|
|
562
|
-
* width: 800,
|
|
563
|
-
* height: 600,
|
|
564
|
-
* })
|
|
565
|
-
*
|
|
566
|
-
* t.draw(() => {
|
|
567
|
-
* // Set the background color to black
|
|
568
|
-
* t.background(0);
|
|
569
|
-
*
|
|
570
|
-
* const centerX = t.width / 2;
|
|
571
|
-
* const centerY = t.height / 2;
|
|
572
|
-
* const radius = Math.min(t.width, t .height) / 3;
|
|
573
|
-
* const speed = 0.02; // Adjust speed of rotation
|
|
574
|
-
*
|
|
575
|
-
* const angle = t.frameCount * speed;
|
|
576
|
-
* const x = centerX + Math.cos(angle) * radius - 100;
|
|
577
|
-
* const y = centerY + Math.sin(angle) * radius - 50;
|
|
578
|
-
*
|
|
579
|
-
* // Set the fill color to white
|
|
580
|
-
* t.fill(255);
|
|
581
|
-
*
|
|
582
|
-
* // Draw a rectangle with the fill color
|
|
583
|
-
* t.rect(x, y, 200, 150);
|
|
584
|
-
* });
|
|
585
|
-
* ```
|
|
586
|
-
*/
|
|
587
|
-
fill(r: number, g?: number, b?: number, a?: number): void;
|
|
588
|
-
/**
|
|
589
|
-
* Sets the stroke color for subsequent rendering operations
|
|
590
|
-
* @param r Red component (0-255)
|
|
591
|
-
* @param g Green component (0-255, optional)
|
|
592
|
-
* @param b Blue component (0-255, optional)
|
|
593
|
-
* @param a Alpha component (0-255, optional)
|
|
594
|
-
*
|
|
595
|
-
* @example
|
|
596
|
-
* ```javascript
|
|
597
|
-
* const t = await textmode.create({
|
|
598
|
-
* width: 800,
|
|
599
|
-
* height: 600,
|
|
600
|
-
* })
|
|
601
|
-
*
|
|
602
|
-
* t.draw(() => {
|
|
603
|
-
* // Set the background color to black
|
|
604
|
-
* t.background(0);
|
|
605
|
-
*
|
|
606
|
-
* // Set stroke color to red and stroke weight to 4 pixels
|
|
607
|
-
* t.stroke(255, 0, 0);
|
|
608
|
-
* t.strokeWeight(4);
|
|
609
|
-
*
|
|
610
|
-
* // Draw a rectangle with red stroke
|
|
611
|
-
* t.rect(100, 100, 200, 150);
|
|
612
|
-
*
|
|
613
|
-
* // Rectangle with both fill and stroke
|
|
614
|
-
* t.fill(0, 255, 0);
|
|
615
|
-
* t.stroke(0, 0, 255);
|
|
616
|
-
* t.strokeWeight(2);
|
|
617
|
-
* t.rect(350, 100, 200, 150);
|
|
618
|
-
* });
|
|
619
|
-
* ```
|
|
620
|
-
*/
|
|
621
|
-
stroke(r: number, g?: number, b?: number, a?: number): void;
|
|
622
|
-
/**
|
|
623
|
-
* Sets the stroke weight (thickness) for subsequent stroke operations
|
|
624
|
-
* @param weight The stroke thickness in pixels
|
|
625
|
-
*
|
|
626
|
-
* @example
|
|
627
|
-
* ```javascript
|
|
628
|
-
* const t = await textmode.create({
|
|
629
|
-
* width: 800,
|
|
630
|
-
* height: 600,
|
|
631
|
-
* })
|
|
632
|
-
*
|
|
633
|
-
* t.draw(() => {
|
|
634
|
-
* t.background(0);
|
|
635
|
-
*
|
|
636
|
-
* // Thin stroke
|
|
637
|
-
* t.stroke(255);
|
|
638
|
-
* t.strokeWeight(1);
|
|
639
|
-
* t.rect(50, 50, 100, 100);
|
|
640
|
-
*
|
|
641
|
-
* // Thick stroke
|
|
642
|
-
* t.strokeWeight(8);
|
|
643
|
-
* t.rect(200, 50, 100, 100);
|
|
644
|
-
* });
|
|
645
|
-
* ```
|
|
646
|
-
*/
|
|
647
|
-
strokeWeight(weight: number): void;
|
|
648
|
-
/**
|
|
649
|
-
* Disables stroke rendering for subsequent operations
|
|
650
|
-
*
|
|
651
|
-
* @example
|
|
652
|
-
* ```javascript
|
|
653
|
-
* const t = await textmode.create({
|
|
654
|
-
* width: 800,
|
|
655
|
-
* height: 600,
|
|
656
|
-
* })
|
|
657
|
-
*
|
|
658
|
-
* t.draw(() => {
|
|
659
|
-
* t.background(0);
|
|
660
|
-
*
|
|
661
|
-
* // Rectangle with stroke
|
|
662
|
-
* t.fill(255, 0, 0);
|
|
663
|
-
* t.stroke(0, 255, 0);
|
|
664
|
-
* t.strokeWeight(4);
|
|
665
|
-
* t.rect(100, 100, 150, 100);
|
|
666
|
-
*
|
|
667
|
-
* // Rectangle without stroke (fill only)
|
|
668
|
-
* t.noStroke();
|
|
669
|
-
* t.rect(300, 100, 150, 100);
|
|
670
|
-
* });
|
|
671
|
-
* ```
|
|
672
|
-
*/
|
|
673
|
-
noStroke(): void;
|
|
674
|
-
/**
|
|
675
|
-
* Disables fill rendering for subsequent operations
|
|
676
|
-
*
|
|
677
|
-
* @example
|
|
678
|
-
* ```javascript
|
|
679
|
-
* const t = await textmode.create({
|
|
680
|
-
* width: 800,
|
|
681
|
-
* height: 600,
|
|
682
|
-
* })
|
|
683
|
-
*
|
|
684
|
-
* t.draw(() => {
|
|
685
|
-
* t.background(0);
|
|
686
|
-
*
|
|
687
|
-
* // Rectangle with fill
|
|
688
|
-
* t.fill(255, 0, 0);
|
|
689
|
-
* t.stroke(0, 255, 0);
|
|
690
|
-
* t.strokeWeight(4);
|
|
691
|
-
* t.rect(100, 100, 150, 100);
|
|
692
|
-
*
|
|
693
|
-
* // Rectangle without fill (stroke only)
|
|
694
|
-
* t.noFill();
|
|
695
|
-
* t.rect(300, 100, 150, 100);
|
|
696
|
-
* });
|
|
697
|
-
* ```
|
|
698
|
-
*/
|
|
699
|
-
noFill(): void;
|
|
700
|
-
/**
|
|
701
|
-
* Sets the rotation angle for subsequent rendering operations
|
|
702
|
-
* @param degrees The rotation angle in degrees
|
|
703
|
-
*
|
|
704
|
-
* @example
|
|
705
|
-
* ```javascript
|
|
706
|
-
* const t = await textmode.create({
|
|
707
|
-
* width: 800,
|
|
708
|
-
* height: 600,
|
|
709
|
-
* })
|
|
710
|
-
*
|
|
711
|
-
* t.draw(() => {
|
|
712
|
-
* t.background(0);
|
|
713
|
-
*
|
|
714
|
-
* // Normal rectangle
|
|
715
|
-
* t.fill(255, 0, 0);
|
|
716
|
-
* t.rect(100, 100, 150, 100);
|
|
717
|
-
*
|
|
718
|
-
* // Rotated rectangle
|
|
719
|
-
* t.push(); // Save current state
|
|
720
|
-
* t.rotate(45); // Rotate 45 degrees
|
|
721
|
-
* t.fill(0, 255, 0);
|
|
722
|
-
* t.rect(300, 100, 150, 100);
|
|
723
|
-
* t.pop(); // Restore state (no rotation)
|
|
724
|
-
*
|
|
725
|
-
* // Back to normal (no rotation)
|
|
726
|
-
* t.fill(0, 0, 255);
|
|
727
|
-
* t.rect(500, 100, 150, 100);
|
|
728
|
-
* });
|
|
729
|
-
* ```
|
|
730
|
-
*/
|
|
731
|
-
rotate(degrees: number): void;
|
|
732
|
-
/**
|
|
733
|
-
* Save the current rendering state (fill, stroke, etc.) to the state stack.
|
|
734
|
-
* Use with {@link pop} to isolate style changes within a block.
|
|
735
|
-
*
|
|
736
|
-
* @example
|
|
737
|
-
* ```javascript
|
|
738
|
-
* const t = await textmode.create({
|
|
739
|
-
* width: 800,
|
|
740
|
-
* height: 600,
|
|
741
|
-
* })
|
|
742
|
-
*
|
|
743
|
-
* t.draw(() => {
|
|
744
|
-
* t.background(0);
|
|
745
|
-
*
|
|
746
|
-
* // Set initial styles
|
|
747
|
-
* t.fill(255, 0, 0); // Red fill
|
|
748
|
-
* t.stroke(0, 255, 0); // Green stroke
|
|
749
|
-
* t.strokeWeight(4); // Thick stroke
|
|
750
|
-
*
|
|
751
|
-
* t.push(); // Save current state
|
|
752
|
-
*
|
|
753
|
-
* // Change styles temporarily
|
|
754
|
-
* t.fill(0, 0, 255); // Blue fill
|
|
755
|
-
* t.stroke(255, 255, 0); // Yellow stroke
|
|
756
|
-
* t.strokeWeight(2); // Thin stroke
|
|
757
|
-
* t.rect(100, 100, 150, 100);
|
|
758
|
-
*
|
|
759
|
-
* t.pop(); // Restore previous state
|
|
760
|
-
*
|
|
761
|
-
* // Back to red fill, green stroke, thick stroke
|
|
762
|
-
* t.rect(300, 100, 150, 100);
|
|
763
|
-
* });
|
|
764
|
-
* ```
|
|
765
|
-
*/
|
|
766
|
-
push(): void;
|
|
767
|
-
/**
|
|
768
|
-
* Restore the most recently saved rendering state from the state stack.
|
|
769
|
-
* Use with {@link push} to isolate style changes within a block.
|
|
770
|
-
*
|
|
771
|
-
* @example
|
|
772
|
-
* ```javascript
|
|
773
|
-
* const t = await textmode.create({
|
|
774
|
-
* width: 800,
|
|
775
|
-
* height: 600,
|
|
776
|
-
* })
|
|
777
|
-
*
|
|
778
|
-
* t.draw(() => {
|
|
779
|
-
* t.background(0);
|
|
780
|
-
*
|
|
781
|
-
* // Default styles
|
|
782
|
-
* t.fill(255); // White fill
|
|
783
|
-
* t.stroke(0); // Black stroke
|
|
784
|
-
* t.strokeWeight(1); // Thin stroke
|
|
785
|
-
*
|
|
786
|
-
* t.push(); // Save current state
|
|
787
|
-
*
|
|
788
|
-
* // Temporary style changes
|
|
789
|
-
* t.fill(255, 0, 0); // Red fill
|
|
790
|
-
* t.strokeWeight(8); // Thick stroke
|
|
791
|
-
* t.rect(50, 50, 100, 100);
|
|
792
|
-
*
|
|
793
|
-
* t.push(); // Save red style state
|
|
794
|
-
*
|
|
795
|
-
* t.fill(0, 255, 0); // Green fill
|
|
796
|
-
* t.noStroke(); // No stroke
|
|
797
|
-
* t.rect(200, 50, 100, 100);
|
|
798
|
-
*
|
|
799
|
-
* t.pop(); // Back to red fill, thick stroke
|
|
800
|
-
* t.rect(350, 50, 100, 100);
|
|
801
|
-
*
|
|
802
|
-
* t.pop(); // Back to white fill, black stroke, thin stroke
|
|
803
|
-
* t.rect(500, 50, 100, 100);
|
|
804
|
-
* });
|
|
805
|
-
* ```
|
|
806
|
-
*/
|
|
807
|
-
pop(): void;
|
|
808
|
-
/**
|
|
809
|
-
* Draw a rectangle with the current shader or fill color.
|
|
810
|
-
* @param x X-coordinate of the rectangle
|
|
811
|
-
* @param y Y-coordinate of the rectangle
|
|
812
|
-
* @param width Width of the rectangle
|
|
813
|
-
* @param height Height of the rectangle
|
|
814
|
-
*
|
|
815
|
-
* @example
|
|
816
|
-
* ```javascript
|
|
817
|
-
* const t = await textmode.create({
|
|
818
|
-
* width: 800,
|
|
819
|
-
* height: 600,
|
|
820
|
-
* })
|
|
821
|
-
*
|
|
822
|
-
* t.draw(() => {
|
|
823
|
-
* // Set the background color to black
|
|
824
|
-
* t.background(0);
|
|
825
|
-
*
|
|
826
|
-
* const centerX = t.width / 2;
|
|
827
|
-
* const centerY = t.height / 2;
|
|
828
|
-
* const radius = Math.min(t.width, t .height) / 3;
|
|
829
|
-
* const speed = 0.02; // Adjust speed of rotation
|
|
830
|
-
*
|
|
831
|
-
* const angle = t.frameCount * speed;
|
|
832
|
-
* const x = centerX + Math.cos(angle) * radius - 100;
|
|
833
|
-
* const y = centerY + Math.sin(angle) * radius - 50;
|
|
834
|
-
*
|
|
835
|
-
* // Set the fill color to white
|
|
836
|
-
* t.fill(255);
|
|
837
|
-
*
|
|
838
|
-
* // Draw a rectangle with the fill color
|
|
839
|
-
* t.rect(x, y, 200, 150);
|
|
840
|
-
* });
|
|
841
|
-
* ```
|
|
842
|
-
*/
|
|
843
|
-
rect(x: number, y: number, width?: number, height?: number): void;
|
|
844
|
-
/**
|
|
845
|
-
* Draw a line from point (x1, y1) to point (x2, y2) with the current stroke settings.
|
|
846
|
-
* Lines respect stroke color, stroke weight, and rotation, but ignore fill properties.
|
|
847
|
-
* @param x1 X-coordinate of the line start point
|
|
848
|
-
* @param y1 Y-coordinate of the line start point
|
|
849
|
-
* @param x2 X-coordinate of the line end point
|
|
850
|
-
* @param y2 Y-coordinate of the line end point
|
|
851
|
-
*
|
|
852
|
-
* @example
|
|
853
|
-
* ```javascript
|
|
854
|
-
* const t = await textmode.create({
|
|
855
|
-
* width: 800,
|
|
856
|
-
* height: 600,
|
|
857
|
-
* })
|
|
858
|
-
*
|
|
859
|
-
* t.draw(() => {
|
|
860
|
-
* // Set the background color to black
|
|
861
|
-
* t.background(0);
|
|
862
|
-
*
|
|
863
|
-
* // Draw a simple line
|
|
864
|
-
* t.stroke(255, 0, 0); // Red stroke
|
|
865
|
-
* t.strokeWeight(2); // 2px thick
|
|
866
|
-
* t.line(100, 100, 300, 200);
|
|
867
|
-
*
|
|
868
|
-
* // Draw an animated rotating line
|
|
869
|
-
* t.push();
|
|
870
|
-
* t.stroke(0, 255, 0); // Green stroke
|
|
871
|
-
* t.strokeWeight(4); // 4px thick
|
|
872
|
-
* t.rotate(t.frameCount * 2); // Rotate based on frame count
|
|
873
|
-
* t.line(400, 300, 600, 300);
|
|
874
|
-
* t.pop();
|
|
875
|
-
*
|
|
876
|
-
* // Draw a thick yellow line
|
|
877
|
-
* t.stroke(255, 255, 0); // Yellow stroke
|
|
878
|
-
* t.strokeWeight(8); // 8px thick
|
|
879
|
-
* t.line(200, 400, 400, 500);
|
|
880
|
-
*
|
|
881
|
-
* // Line with no stroke won't be visible
|
|
882
|
-
* t.noStroke();
|
|
883
|
-
* t.line(500, 100, 700, 200); // This won't render
|
|
884
|
-
* });
|
|
885
|
-
* ```
|
|
886
|
-
*/
|
|
887
|
-
line(x1: number, y1: number, x2: number, y2: number): void;
|
|
888
|
-
/**
|
|
889
|
-
* Set the background color for the canvas.
|
|
890
|
-
* @param r Red component (0-255)
|
|
891
|
-
* @param g Green component (0-255, optional)
|
|
892
|
-
* @param b Blue component (0-255, optional)
|
|
893
|
-
* @param a Alpha component (0-255, optional)
|
|
894
|
-
*
|
|
895
|
-
* @example
|
|
896
|
-
* ```javascript
|
|
897
|
-
* const t = await textmode.create({
|
|
898
|
-
* width: 800,
|
|
899
|
-
* height: 600,
|
|
900
|
-
* })
|
|
901
|
-
*
|
|
902
|
-
* t.draw(() => {
|
|
903
|
-
* // Set the background color to black
|
|
904
|
-
* t.background(0);
|
|
905
|
-
*
|
|
906
|
-
* const centerX = t.width / 2;
|
|
907
|
-
* const centerY = t.height / 2;
|
|
908
|
-
* const radius = Math.min(t.width, t .height) / 3;
|
|
909
|
-
* const speed = 0.02; // Adjust speed of rotation
|
|
910
|
-
*
|
|
911
|
-
* const angle = t.frameCount * speed;
|
|
912
|
-
* const x = centerX + Math.cos(angle) * radius - 100;
|
|
913
|
-
* const y = centerY + Math.sin(angle) * radius - 50;
|
|
914
|
-
*
|
|
915
|
-
* // Set the fill color to white
|
|
916
|
-
* t.fill(255);
|
|
917
|
-
*
|
|
918
|
-
* // Draw a rectangle with the fill color
|
|
919
|
-
* t.rect(x, y, 200, 150);
|
|
920
|
-
* });
|
|
921
|
-
* ```
|
|
922
|
-
*/
|
|
923
|
-
background(r: number, g?: number, b?: number, a?: number): void;
|
|
924
|
-
/**
|
|
925
|
-
* Create a shader program from vertex and fragment source code.
|
|
926
|
-
* @param vertexSource The GLSL source code for the vertex shader.
|
|
927
|
-
* @param fragmentSource The GLSL source code for the fragment shader.
|
|
928
|
-
* @returns The created shader program for use in `textmode.js`.
|
|
929
|
-
*/
|
|
930
|
-
createShader(vertexSource: string, fragmentSource: string): Shader;
|
|
931
|
-
/**
|
|
932
|
-
* Create a filter shader program from a fragment source code.
|
|
933
|
-
* @param fragmentSource The GLSL source code for the fragment shader.
|
|
934
|
-
* @returns The created filter shader program for use in `textmode.js`.
|
|
935
|
-
*/
|
|
936
|
-
createFilterShader(fragmentSource: string): Shader;
|
|
937
|
-
/**
|
|
938
|
-
* Set the current shader for rendering.
|
|
939
|
-
* @param shader The shader program to use for rendering.
|
|
940
|
-
*/
|
|
941
|
-
shader(shader: Shader): void;
|
|
942
|
-
/**
|
|
943
|
-
* Set a uniform variable for the current shader.
|
|
944
|
-
* @param name The name of the uniform variable to set.
|
|
945
|
-
* @param value The value to set for the uniform variable.
|
|
946
|
-
*/
|
|
947
|
-
setUniform(name: string, value: any): void;
|
|
948
382
|
/**
|
|
949
383
|
* Completely destroy this Textmodifier instance and free all associated resources.
|
|
950
384
|
*
|
|
@@ -984,6 +418,7 @@ export declare class Textmodifier {
|
|
|
984
418
|
get pipeline(): TextmodeConversionPipeline;
|
|
985
419
|
/** Get the current frame count. */
|
|
986
420
|
get frameCount(): number;
|
|
421
|
+
/** Set the current frame count. */
|
|
987
422
|
set frameCount(value: number);
|
|
988
423
|
/** Get the width of the canvas. */
|
|
989
424
|
get width(): number;
|
|
@@ -992,3 +427,6 @@ export declare class Textmodifier {
|
|
|
992
427
|
/** Check if the instance has been disposed/destroyed. */
|
|
993
428
|
get isDisposed(): boolean;
|
|
994
429
|
}
|
|
430
|
+
export interface Textmodifier extends RenderingCapabilities, ExportCapabilities, FontCapabilities {
|
|
431
|
+
}
|
|
432
|
+
export {};
|