textmode.js 0.1.4-beta.2 → 0.1.4-beta.4
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.esm.js +292 -222
- package/dist/textmode.esm.min.js +343 -273
- package/dist/textmode.umd.js +5 -5
- package/dist/textmode.umd.min.js +12 -12
- package/dist/types/rendering/webgl/Framebuffer.d.ts +0 -4
- package/dist/types/rendering/webgl/Renderer.d.ts +0 -4
- package/dist/types/rendering/webgl/Shader.d.ts +0 -4
- package/dist/types/textmode/Canvas.d.ts +0 -4
- package/dist/types/textmode/ConversionPipeline.d.ts +0 -4
- package/dist/types/textmode/Grid.d.ts +0 -4
- package/dist/types/textmode/Textmodifier.d.ts +89 -3
- package/dist/types/textmode/converters/Converter.d.ts +0 -4
- package/dist/types/textmode/converters/FeatureConverter.d.ts +10 -4
- package/dist/types/textmode/font/TextmodeFont.d.ts +0 -4
- package/package.json +2 -2
|
@@ -57,16 +57,17 @@ export declare class Textmodifier {
|
|
|
57
57
|
private animationFrameId;
|
|
58
58
|
private lastFrameTime;
|
|
59
59
|
private frameInterval;
|
|
60
|
+
private _isLooping;
|
|
60
61
|
private _frameRate;
|
|
61
62
|
private lastRenderTime;
|
|
62
63
|
private _frameCount;
|
|
63
64
|
private frameTimeHistory;
|
|
64
65
|
private frameTimeHistorySize;
|
|
65
66
|
private _pipeline;
|
|
67
|
+
private _isDisposed;
|
|
66
68
|
private _standalone;
|
|
67
69
|
private _drawCallback;
|
|
68
70
|
private _resizedCallback;
|
|
69
|
-
private _isDestroyed;
|
|
70
71
|
private _windowResizeListener;
|
|
71
72
|
private constructor();
|
|
72
73
|
/**
|
|
@@ -332,6 +333,90 @@ export declare class Textmodifier {
|
|
|
332
333
|
* ```
|
|
333
334
|
*/
|
|
334
335
|
frameRate(fps?: number): number | void;
|
|
336
|
+
/**
|
|
337
|
+
* Stop the automatic rendering loop while keeping the render mode as 'auto'.
|
|
338
|
+
*
|
|
339
|
+
* This method pauses the render loop without changing the render mode, allowing
|
|
340
|
+
* it to be resumed later with {@link loop}. This is useful for temporarily pausing
|
|
341
|
+
* animation while maintaining the ability to restart it.
|
|
342
|
+
*
|
|
343
|
+
* **Note:** This only affects rendering when in `'auto'` mode. In `'manual'` mode,
|
|
344
|
+
* this method has no effect since rendering is already controlled manually.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```javascript
|
|
348
|
+
* // Create a textmodifier instance in auto mode
|
|
349
|
+
* const textmodifier = await textmode.create(canvas);
|
|
350
|
+
*
|
|
351
|
+
* // The render loop is running automatically
|
|
352
|
+
* console.log(textmodifier.isLooping()); // true
|
|
353
|
+
*
|
|
354
|
+
* // Stop the automatic rendering loop
|
|
355
|
+
* textmodifier.noLoop();
|
|
356
|
+
* console.log(textmodifier.isLooping()); // false
|
|
357
|
+
*
|
|
358
|
+
* // Resume the automatic rendering loop
|
|
359
|
+
* textmodifier.loop();
|
|
360
|
+
* console.log(textmodifier.isLooping()); // true
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
noLoop(): void;
|
|
364
|
+
/**
|
|
365
|
+
* Resume the automatic rendering loop if it was stopped by {@link noLoop}.
|
|
366
|
+
*
|
|
367
|
+
* This method restarts the render loop when in `'auto'` mode. If the render mode
|
|
368
|
+
* is `'manual'`, the loop state will be set but automatic rendering will not start
|
|
369
|
+
* until the mode is changed back to `'auto'`.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```javascript
|
|
373
|
+
* // Create a textmodifier instance
|
|
374
|
+
* const textmodifier = await textmode.create(canvas);
|
|
375
|
+
*
|
|
376
|
+
* // Stop the loop
|
|
377
|
+
* textmodifier.noLoop();
|
|
378
|
+
*
|
|
379
|
+
* // Resume the loop
|
|
380
|
+
* textmodifier.loop();
|
|
381
|
+
*
|
|
382
|
+
* // You can also use this pattern for conditional animation
|
|
383
|
+
* if (someCondition) {
|
|
384
|
+
* textmodifier.loop();
|
|
385
|
+
* } else {
|
|
386
|
+
* textmodifier.noLoop();
|
|
387
|
+
* }
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
loop(): void;
|
|
391
|
+
/**
|
|
392
|
+
* Check whether the textmodifier is currently running the automatic render loop.
|
|
393
|
+
*
|
|
394
|
+
* Returns `true` when both the render mode is `'auto'` AND the loop is active.
|
|
395
|
+
* Returns `false` when in `'manual'` mode or when {@link noLoop} has been called.
|
|
396
|
+
*
|
|
397
|
+
* @returns True if the automatic render loop is currently active, false otherwise.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```javascript
|
|
401
|
+
* const textmodifier = await textmode.create(canvas);
|
|
402
|
+
*
|
|
403
|
+
* // Check loop status in different states
|
|
404
|
+
* console.log(textmodifier.isLooping()); // true (auto mode, looping)
|
|
405
|
+
*
|
|
406
|
+
* textmodifier.noLoop();
|
|
407
|
+
* console.log(textmodifier.isLooping()); // false (auto mode, not looping)
|
|
408
|
+
*
|
|
409
|
+
* textmodifier.renderMode('manual');
|
|
410
|
+
* console.log(textmodifier.isLooping()); // false (manual mode)
|
|
411
|
+
*
|
|
412
|
+
* textmodifier.renderMode('auto');
|
|
413
|
+
* console.log(textmodifier.isLooping()); // false (auto mode, but loop was stopped)
|
|
414
|
+
*
|
|
415
|
+
* textmodifier.loop();
|
|
416
|
+
* console.log(textmodifier.isLooping()); // true (auto mode, looping)
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
isLooping(): boolean;
|
|
335
420
|
/**
|
|
336
421
|
* Set the font size used for rendering.
|
|
337
422
|
* @param size The font size to set.
|
|
@@ -858,10 +943,11 @@ export declare class Textmodifier {
|
|
|
858
943
|
get pipeline(): TextmodeConversionPipeline;
|
|
859
944
|
/** Get the current frame count. */
|
|
860
945
|
get frameCount(): number;
|
|
946
|
+
set frameCount(value: number);
|
|
861
947
|
/** Get the width of the canvas. */
|
|
862
948
|
get width(): number;
|
|
863
949
|
/** Get the height of the canvas. */
|
|
864
950
|
get height(): number;
|
|
865
|
-
/** Check if
|
|
866
|
-
get
|
|
951
|
+
/** Check if the instance has been disposed/destroyed. */
|
|
952
|
+
get isDisposed(): boolean;
|
|
867
953
|
}
|
|
@@ -47,10 +47,6 @@ export declare class TextmodeConverter {
|
|
|
47
47
|
* This method is idempotent and safe to call multiple times.
|
|
48
48
|
*/
|
|
49
49
|
dispose(): void;
|
|
50
|
-
/**
|
|
51
|
-
* Check if this converter has been disposed
|
|
52
|
-
*/
|
|
53
|
-
get isDisposed(): boolean;
|
|
54
50
|
/** Returns the framebuffer containing character data. */
|
|
55
51
|
get characterFramebuffer(): Framebuffer;
|
|
56
52
|
/** Returns the framebuffer containing primary color data. */
|
|
@@ -24,12 +24,12 @@ export declare abstract class TextmodeFeatureConverter extends TextmodeConverter
|
|
|
24
24
|
/**
|
|
25
25
|
* Sets the color of the characters affected by the converter.
|
|
26
26
|
* This is only used when `characterColorMode` is set to `'fixed'`.
|
|
27
|
-
* @param r Red component (0-255).
|
|
27
|
+
* @param r Red component (0-255) or hex string (e.g., '#FF0000', '#F00', 'FF0000', 'F00').
|
|
28
28
|
* @param g Green component (0-255).
|
|
29
29
|
* @param b Blue component (0-255).
|
|
30
30
|
* @param a Alpha component (0-255).
|
|
31
31
|
*/
|
|
32
|
-
characterColor(r: number, g?: number, b?: number, a?: number): void;
|
|
32
|
+
characterColor(r: number | string, g?: number, b?: number, a?: number): void;
|
|
33
33
|
/**
|
|
34
34
|
* Sets the character color mode.
|
|
35
35
|
* - `'sampled'`: Uses sampled colors from the source texture.
|
|
@@ -40,12 +40,12 @@ export declare abstract class TextmodeFeatureConverter extends TextmodeConverter
|
|
|
40
40
|
/**
|
|
41
41
|
* Sets the cell color for all cells affected by the converter.
|
|
42
42
|
* This is only used when `cellColorMode` is set to `'fixed'`.
|
|
43
|
-
* @param r Red component (0-255).
|
|
43
|
+
* @param r Red component (0-255) or hex string (e.g., '#FF0000', '#F00', 'FF0000', 'F00').
|
|
44
44
|
* @param g Green component (0-255).
|
|
45
45
|
* @param b Blue component (0-255).
|
|
46
46
|
* @param a Alpha component (0-255).
|
|
47
47
|
*/
|
|
48
|
-
cellColor(r: number, g?: number, b?: number, a?: number): void;
|
|
48
|
+
cellColor(r: number | string, g?: number, b?: number, a?: number): void;
|
|
49
49
|
/**
|
|
50
50
|
* Sets the cell color mode.
|
|
51
51
|
* - `'sampled'`: Uses sampled colors from the source texture.
|
|
@@ -73,4 +73,10 @@ 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
|
+
* Parses a hex color string and returns RGBA values.
|
|
78
|
+
* @param hex Hex color string (e.g., '#FF0000', '#F00', 'FF0000', 'F00').
|
|
79
|
+
* @returns RGBA array [r, g, b, a] or null if invalid.
|
|
80
|
+
*/
|
|
81
|
+
private parseHexColor;
|
|
76
82
|
}
|
|
@@ -97,10 +97,6 @@ export declare class TextmodeFont {
|
|
|
97
97
|
* This method is idempotent and safe to call multiple times.
|
|
98
98
|
*/
|
|
99
99
|
dispose(): void;
|
|
100
|
-
/**
|
|
101
|
-
* Check if this font manager has been disposed
|
|
102
|
-
*/
|
|
103
|
-
get isDisposed(): boolean;
|
|
104
100
|
/** Returns the font size used for rendering. */
|
|
105
101
|
get fontSize(): number;
|
|
106
102
|
/** Returns the Typr.js font object. @ignore */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textmode.js",
|
|
3
|
-
"version": "0.1.4-beta.
|
|
3
|
+
"version": "0.1.4-beta.4",
|
|
4
4
|
"description": "Apply real-time ASCII conversion to any HTML canvas.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"dev": "vite",
|
|
22
|
+
"dev": "vite --port 5177 --host",
|
|
23
23
|
"build": "vite build && vite build --mode min && tsc",
|
|
24
24
|
"build:full": "vite build && tsc",
|
|
25
25
|
"build:min": "vite build --mode min && tsc",
|