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.
- package/README.md +4 -4
- package/dist/textmode.esm.js +1431 -1480
- package/dist/textmode.esm.min.js +1491 -1540
- package/dist/textmode.umd.js +19 -56
- package/dist/textmode.umd.min.js +19 -56
- package/dist/types/Textmode.d.ts +10 -38
- package/dist/types/export/base/DataExtractor.d.ts +3 -3
- package/dist/types/export/image/ImageExporter.d.ts +4 -11
- package/dist/types/export/image/types.d.ts +2 -3
- package/dist/types/export/svg/SVGExporter.d.ts +1 -1
- package/dist/types/export/svg/types.d.ts +1 -0
- package/dist/types/export/txt/TXTExporter.d.ts +1 -1
- package/dist/types/export/txt/types.d.ts +2 -2
- package/dist/types/index.d.ts +1 -7
- package/dist/types/rendering/index.d.ts +0 -1
- package/dist/types/rendering/webgl/DrawQueue.d.ts +26 -0
- package/dist/types/rendering/webgl/Framebuffer.d.ts +41 -40
- package/dist/types/rendering/webgl/InstanceBatch.d.ts +91 -0
- package/dist/types/rendering/webgl/InstanceData.d.ts +65 -0
- package/dist/types/rendering/webgl/RenderPipeline.d.ts +15 -0
- package/dist/types/rendering/webgl/RenderState.d.ts +76 -0
- package/dist/types/rendering/webgl/Renderer.d.ts +54 -81
- package/dist/types/rendering/webgl/Shader.d.ts +11 -16
- package/dist/types/rendering/webgl/VAOManager.d.ts +15 -0
- package/dist/types/rendering/webgl/geometries/Arc.d.ts +16 -0
- package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +35 -29
- package/dist/types/rendering/webgl/geometries/BezierCurve.d.ts +22 -0
- package/dist/types/rendering/webgl/geometries/Ellipse.d.ts +20 -0
- package/dist/types/rendering/webgl/geometries/Line.d.ts +13 -4
- package/dist/types/rendering/webgl/geometries/Rectangle.d.ts +13 -8
- package/dist/types/rendering/webgl/geometries/Triangle.d.ts +20 -0
- package/dist/types/rendering/webgl/geometries/index.d.ts +4 -1
- package/dist/types/rendering/webgl/index.d.ts +17 -1
- package/dist/types/rendering/webgl/types/DrawCommand.d.ts +9 -0
- package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +144 -0
- package/dist/types/rendering/webgl/types/RenderTypes.d.ts +12 -0
- package/dist/types/textmode/AnimationController.d.ts +81 -0
- package/dist/types/textmode/Canvas.d.ts +18 -19
- package/dist/types/textmode/Grid.d.ts +1 -34
- package/dist/types/textmode/Textmodifier.d.ts +36 -277
- package/dist/types/textmode/font/CharacterColorMapper.d.ts +3 -3
- package/dist/types/textmode/font/TextmodeFont.d.ts +6 -11
- package/dist/types/textmode/font/types.d.ts +1 -1
- package/dist/types/textmode/font/typr/types.d.ts +1 -1
- package/dist/types/textmode/font/utils/index.d.ts +0 -1
- package/dist/types/textmode/mixins/AnimationMixin.d.ts +120 -0
- package/dist/types/textmode/mixins/ExportMixin.d.ts +4 -6
- package/dist/types/textmode/mixins/FontMixin.d.ts +4 -10
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +224 -246
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +13 -4
- package/dist/types/textmode/mixins/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/ColorPalette.d.ts +0 -35
- package/dist/types/rendering/core/Framebuffer.d.ts +0 -140
- package/dist/types/rendering/core/Shader.d.ts +0 -59
- package/dist/types/rendering/core/index.d.ts +0 -2
- package/dist/types/textmode/ConversionPipeline.d.ts +0 -110
- package/dist/types/textmode/converters/BrightnessConverter.d.ts +0 -58
- package/dist/types/textmode/converters/Converter.d.ts +0 -69
- package/dist/types/textmode/converters/FeatureConverter.d.ts +0 -128
- package/dist/types/textmode/converters/index.d.ts +0 -3
- package/dist/types/textmode/font/utils/FontConstants.d.ts +0 -60
- package/dist/types/textmode/mixins/ConversionMixin.d.ts +0 -62
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { GLRenderer } from '../../rendering/webgl/Renderer';
|
|
5
5
|
import type { TextmodeFont } from '../font';
|
|
6
|
-
import type { TextmodeConversionPipeline } from '../ConversionPipeline';
|
|
7
6
|
import type { TextmodeCanvas } from '../Canvas';
|
|
8
7
|
import type { TextmodeGrid } from '../Grid';
|
|
8
|
+
import type { AnimationController } from '../AnimationController';
|
|
9
|
+
import type { GLFramebuffer, Shader } from '../../rendering';
|
|
9
10
|
/**
|
|
10
11
|
* Constructor type for mixin pattern
|
|
11
12
|
*/
|
|
@@ -23,12 +24,20 @@ export interface TextmodifierContext {
|
|
|
23
24
|
readonly _renderer: GLRenderer;
|
|
24
25
|
/** Font management @ignore */
|
|
25
26
|
readonly _font: TextmodeFont;
|
|
26
|
-
/** Conversion pipeline @ignore */
|
|
27
|
-
readonly _pipeline: TextmodeConversionPipeline;
|
|
28
27
|
/** Canvas management @ignore */
|
|
29
28
|
readonly _canvas: TextmodeCanvas;
|
|
30
29
|
/** Grid management @ignore */
|
|
31
30
|
readonly _grid: TextmodeGrid;
|
|
31
|
+
/** Animation controller for managing rendering loop @ignore */
|
|
32
|
+
readonly _animationController: AnimationController;
|
|
33
|
+
/** Draw shader that contains content drawn by the user @ignore */
|
|
34
|
+
readonly _textmodeDrawShader: Shader;
|
|
35
|
+
/** Framebuffer used for offscreen rendering @ignore */
|
|
36
|
+
readonly _textmodeDrawFramebuffer: GLFramebuffer;
|
|
37
|
+
/** Shader used for converting pixels to textmode grid format @ignore */
|
|
38
|
+
readonly _textmodeConversionShader: Shader;
|
|
39
|
+
/** Main render method @ignore */
|
|
40
|
+
$render(): void;
|
|
32
41
|
}
|
|
33
42
|
/**
|
|
34
43
|
* Simple utility function to apply multiple mixins to a base class
|
|
@@ -36,4 +45,4 @@ export interface TextmodifierContext {
|
|
|
36
45
|
* @param mixins Array of mixin functions to apply
|
|
37
46
|
* @returns The composed class with all mixins applied
|
|
38
47
|
*/
|
|
39
|
-
export declare function applyMixins<T extends Constructor>(Base: T, ...mixins: any[]): T;
|
|
48
|
+
export declare function $applyMixins<T extends Constructor>(Base: T, ...mixins: any[]): T;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { type Constructor, type Mixin, type TextmodifierContext, applyMixins } from './TextmodifierMixin';
|
|
1
|
+
export { type Constructor, type Mixin, type TextmodifierContext, $applyMixins } from './TextmodifierMixin';
|
|
2
2
|
export { RenderingMixin, type RenderingCapabilities } from './RenderingMixin';
|
|
3
3
|
export { ExportMixin, type ExportCapabilities } from './ExportMixin';
|
|
4
4
|
export { FontMixin, type FontCapabilities } from './FontMixin';
|
|
5
|
-
export {
|
|
5
|
+
export { AnimationMixin, type AnimationCapabilities } from './AnimationMixin';
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Framebuffer } from './rendering/core/Framebuffer';
|
|
2
|
-
import type { GLRenderer } from './rendering/webgl/Renderer';
|
|
3
|
-
/**
|
|
4
|
-
* A 1D color palette stored in a framebuffer that is used to pass colors to shaders.
|
|
5
|
-
* @ignore
|
|
6
|
-
*/
|
|
7
|
-
export declare class TextmodeColorPalette {
|
|
8
|
-
/** The framebuffer used to store the color palette. */
|
|
9
|
-
private _framebuffer;
|
|
10
|
-
private _renderer;
|
|
11
|
-
private _colors;
|
|
12
|
-
/**
|
|
13
|
-
* Create a new color palette instance.
|
|
14
|
-
* @param renderer The renderer instance.
|
|
15
|
-
* @param colors The RGB colors to store as [r, g, b] arrays where values are 0-255.
|
|
16
|
-
*/
|
|
17
|
-
constructor(renderer: GLRenderer, colors: [number, number, number][]);
|
|
18
|
-
/**
|
|
19
|
-
* Update the framebuffer with the currently selected colors.
|
|
20
|
-
*/
|
|
21
|
-
private _update;
|
|
22
|
-
/**
|
|
23
|
-
* Sets the colors of the palette and updates the framebuffer.
|
|
24
|
-
* @param newColors The new RGB colors to set as [r, g, b] arrays.
|
|
25
|
-
*/
|
|
26
|
-
setColors(newColors: [number, number, number][]): void;
|
|
27
|
-
/**
|
|
28
|
-
* Get the colors of the palette.
|
|
29
|
-
*/
|
|
30
|
-
get colors(): [number, number, number][];
|
|
31
|
-
/**
|
|
32
|
-
* Get the framebuffer containing the colors of the palette.
|
|
33
|
-
*/
|
|
34
|
-
get framebuffer(): Framebuffer;
|
|
35
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common framebuffer configuration options
|
|
3
|
-
*/
|
|
4
|
-
export type FramebufferOptions = {
|
|
5
|
-
/** Texture filtering mode */
|
|
6
|
-
filter?: 'nearest' | 'linear';
|
|
7
|
-
/** Texture wrapping mode */
|
|
8
|
-
wrap?: 'clamp' | 'repeat';
|
|
9
|
-
/** Texture format */
|
|
10
|
-
format?: 'rgba' | 'rgb';
|
|
11
|
-
/** Data type for texture data */
|
|
12
|
-
type?: 'unsigned_byte' | 'float';
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Core interface that all framebuffer implementations must satisfy.
|
|
16
|
-
* Defines the contract for render targets across different graphics APIs.
|
|
17
|
-
* @ignore
|
|
18
|
-
*/
|
|
19
|
-
export interface IFramebuffer {
|
|
20
|
-
/** Width of the framebuffer in pixels */
|
|
21
|
-
readonly width: number;
|
|
22
|
-
/** Height of the framebuffer in pixels */
|
|
23
|
-
readonly height: number;
|
|
24
|
-
/** Current pixel data *(if loaded)* */
|
|
25
|
-
readonly pixels: Uint8Array | null;
|
|
26
|
-
/**
|
|
27
|
-
* Begin rendering to this framebuffer.
|
|
28
|
-
* Saves current render state and sets this framebuffer as the active render target.
|
|
29
|
-
*/
|
|
30
|
-
begin(): void;
|
|
31
|
-
/**
|
|
32
|
-
* End rendering to this framebuffer and restore previous render state.
|
|
33
|
-
*/
|
|
34
|
-
end(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Resize the framebuffer to new dimensions.
|
|
37
|
-
* @param width New width in pixels
|
|
38
|
-
* @param height New height in pixels
|
|
39
|
-
*/
|
|
40
|
-
resize(width: number, height: number): void;
|
|
41
|
-
/**
|
|
42
|
-
* Update the framebuffer texture with media source content.
|
|
43
|
-
* @param source Canvas or video element to copy from
|
|
44
|
-
* @ignore
|
|
45
|
-
*/
|
|
46
|
-
$update(source: HTMLCanvasElement | HTMLVideoElement): void;
|
|
47
|
-
/**
|
|
48
|
-
* Update the framebuffer texture with raw pixel data.
|
|
49
|
-
* @param pixelData RGBA pixel data
|
|
50
|
-
* @param width Width of the pixel data
|
|
51
|
-
* @param height Height of the pixel data
|
|
52
|
-
*/
|
|
53
|
-
updatePixels(pixelData: Uint8Array, width: number, height: number): void;
|
|
54
|
-
/**
|
|
55
|
-
* Load pixel data from the framebuffer into the pixels property.
|
|
56
|
-
* This operation may be expensive and should be used sparingly.
|
|
57
|
-
*/
|
|
58
|
-
loadPixels(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Get pixel data from the framebuffer.
|
|
61
|
-
* Overloaded to support different access patterns:
|
|
62
|
-
* - No parameters: returns entire framebuffer as `Uint8Array`
|
|
63
|
-
* - Two parameters `(x, y)`: returns single pixel as `RGBA` array
|
|
64
|
-
* - Four parameters `(x, y, w, h)`: returns region as `Uint8Array`
|
|
65
|
-
*/
|
|
66
|
-
get(): Uint8Array;
|
|
67
|
-
get(x: number, y: number): [number, number, number, number];
|
|
68
|
-
get(x: number, y: number, w: number, h: number): Uint8Array;
|
|
69
|
-
/**
|
|
70
|
-
* Dispose of resources used by this framebuffer.
|
|
71
|
-
* After calling this method, the framebuffer should not be used.
|
|
72
|
-
* @ignore
|
|
73
|
-
*/
|
|
74
|
-
$dispose(): void;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Abstract base class for framebuffer implementations.
|
|
78
|
-
*/
|
|
79
|
-
export declare abstract class Framebuffer implements IFramebuffer {
|
|
80
|
-
protected _width: number;
|
|
81
|
-
protected _height: number;
|
|
82
|
-
protected _options: FramebufferOptions;
|
|
83
|
-
protected _pixels: Uint8Array | null;
|
|
84
|
-
/**
|
|
85
|
-
* Creates an instance of the Framebuffer class.
|
|
86
|
-
* @param width - The width of the framebuffer.
|
|
87
|
-
* @param height - The height of the framebuffer.
|
|
88
|
-
* @param options - Optional configuration options for the framebuffer.
|
|
89
|
-
* @ignore
|
|
90
|
-
*/
|
|
91
|
-
constructor(width: number, height?: number, options?: FramebufferOptions);
|
|
92
|
-
get width(): number;
|
|
93
|
-
get height(): number;
|
|
94
|
-
get pixels(): Uint8Array | null;
|
|
95
|
-
get options(): FramebufferOptions;
|
|
96
|
-
/**
|
|
97
|
-
* Validate and clamp coordinates to framebuffer bounds.
|
|
98
|
-
* @param x X coordinate
|
|
99
|
-
* @param y Y coordinate
|
|
100
|
-
* @param showWarning Whether to show warning for out-of-bounds coordinates
|
|
101
|
-
* @returns Clamped coordinates
|
|
102
|
-
*/
|
|
103
|
-
protected validateCoordinates(x: number, y: number, showWarning?: boolean): [number, number];
|
|
104
|
-
/**
|
|
105
|
-
* Validate and clamp region bounds to framebuffer dimensions.
|
|
106
|
-
* @param x X coordinate
|
|
107
|
-
* @param y Y coordinate
|
|
108
|
-
* @param w Width
|
|
109
|
-
* @param h Height
|
|
110
|
-
* @returns Clamped region bounds
|
|
111
|
-
*/
|
|
112
|
-
protected validateRegion(x: number, y: number, w: number, h: number): [number, number, number, number];
|
|
113
|
-
/**
|
|
114
|
-
* Update internal dimensions and clear pixel cache.
|
|
115
|
-
* Should be called by subclasses when resizing.
|
|
116
|
-
* @param width New width
|
|
117
|
-
* @param height New height
|
|
118
|
-
*/
|
|
119
|
-
protected updateDimensions(width: number, height: number): void;
|
|
120
|
-
abstract begin(): void;
|
|
121
|
-
abstract end(): void;
|
|
122
|
-
abstract resize(width: number, height: number): void;
|
|
123
|
-
abstract $update(source: HTMLCanvasElement | HTMLVideoElement): void;
|
|
124
|
-
abstract updatePixels(pixelData: Uint8Array, width: number, height: number): void;
|
|
125
|
-
abstract loadPixels(): void;
|
|
126
|
-
abstract get(): Uint8Array;
|
|
127
|
-
abstract get(x: number, y: number): [number, number, number, number];
|
|
128
|
-
abstract get(x: number, y: number, w: number, h: number): Uint8Array;
|
|
129
|
-
abstract $dispose(): void;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Default framebuffer options used when no options are specified.
|
|
133
|
-
*
|
|
134
|
-
* **Default values:**
|
|
135
|
-
* - `filter`: `'nearest'` - Use nearest neighbor filtering for sharp pixels
|
|
136
|
-
* - `wrap`: `'clamp'` - Clamp texture coordinates to edges
|
|
137
|
-
* - `format`: `'rgba'` - Use RGBA color format with alpha channel
|
|
138
|
-
* - `type`: `'unsigned_byte'` - Store color components as 8-bit unsigned integers *(0-255)*
|
|
139
|
-
*/
|
|
140
|
-
export declare const DEFAULT_FRAMEBUFFER_OPTIONS: FramebufferOptions;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core shader abstractions for textmode.js rendering system.
|
|
3
|
-
* Provides base classes and interfaces for WebGL and future WebGPU shader implementations.
|
|
4
|
-
*/
|
|
5
|
-
import type { IFramebuffer } from './Framebuffer';
|
|
6
|
-
/**
|
|
7
|
-
* Supported uniform value types
|
|
8
|
-
*/
|
|
9
|
-
export type UniformValue = number | boolean | number[] | Float32Array | Int32Array | IFramebuffer;
|
|
10
|
-
/**
|
|
11
|
-
* Core interface that all shader implementations must satisfy.
|
|
12
|
-
* Defines the contract for shader programs across different graphics APIs.
|
|
13
|
-
* @ignore
|
|
14
|
-
*/
|
|
15
|
-
export interface IShader {
|
|
16
|
-
/** Whether the shader is currently compiled and ready to use */
|
|
17
|
-
readonly isReady: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Activate this shader for rendering.
|
|
20
|
-
* Makes this shader the active program for subsequent draw calls.
|
|
21
|
-
* @ignore
|
|
22
|
-
*/
|
|
23
|
-
$use(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Set a uniform value by name.
|
|
26
|
-
* @param name Name of the uniform
|
|
27
|
-
* @param value Value to set
|
|
28
|
-
*/
|
|
29
|
-
setUniform(name: string, value: UniformValue): void;
|
|
30
|
-
/**
|
|
31
|
-
* Set multiple uniforms at once.
|
|
32
|
-
* @param uniforms Object containing uniform name-value pairs
|
|
33
|
-
*/
|
|
34
|
-
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
35
|
-
/**
|
|
36
|
-
* Reset internal state (texture units, etc.) for a new frame.
|
|
37
|
-
* @ignore
|
|
38
|
-
*/
|
|
39
|
-
$resetState(): void;
|
|
40
|
-
/**
|
|
41
|
-
* Dispose of resources used by this shader.
|
|
42
|
-
* After calling this method, the shader should not be used.
|
|
43
|
-
* @ignore
|
|
44
|
-
*/
|
|
45
|
-
$dispose(): void;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Abstract base class for shader implementations.
|
|
49
|
-
*/
|
|
50
|
-
export declare abstract class Shader implements IShader {
|
|
51
|
-
protected _isReady: boolean;
|
|
52
|
-
protected constructor();
|
|
53
|
-
get isReady(): boolean;
|
|
54
|
-
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
55
|
-
abstract $use(): void;
|
|
56
|
-
abstract setUniform(name: string, value: UniformValue): void;
|
|
57
|
-
abstract $resetState(): void;
|
|
58
|
-
abstract $dispose(): void;
|
|
59
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import type { Framebuffer } from "../rendering/core/Framebuffer";
|
|
2
|
-
import type { GLRenderer } from "../rendering/webgl/Renderer";
|
|
3
|
-
import { TextmodeBrightnessConverter, TextmodeConverter } from "./converters";
|
|
4
|
-
import type { TextmodeFont } from "./font";
|
|
5
|
-
import type { TextmodeGrid } from "./Grid";
|
|
6
|
-
/**
|
|
7
|
-
* Manages the conversion pipeline for textmode rendering.
|
|
8
|
-
*
|
|
9
|
-
* A conversion pipeline consists of multiple converters that process the input texture in sequence.
|
|
10
|
-
* Each converter can modify the texture in various ways, such as applying brightness mapping,
|
|
11
|
-
* color adjustments, transformations, and more.
|
|
12
|
-
*/
|
|
13
|
-
export declare class TextmodeConversionPipeline {
|
|
14
|
-
private _renderer;
|
|
15
|
-
private _font;
|
|
16
|
-
private _grid;
|
|
17
|
-
private _converters;
|
|
18
|
-
private _brightness;
|
|
19
|
-
private _custom;
|
|
20
|
-
private _resultFramebuffer;
|
|
21
|
-
private _asciiShader;
|
|
22
|
-
private _characterFramebuffer;
|
|
23
|
-
private _primaryColorFramebuffer;
|
|
24
|
-
private _secondaryColorFramebuffer;
|
|
25
|
-
private _rotationFramebuffer;
|
|
26
|
-
private _transformFramebuffer;
|
|
27
|
-
/**
|
|
28
|
-
* Creates an instance of TextmodeConversionPipeline.
|
|
29
|
-
* @param renderer The renderer to use for the pipeline.
|
|
30
|
-
* @param font The textmode font to use.
|
|
31
|
-
* @param grid The textmode grid to use.
|
|
32
|
-
* @ignore
|
|
33
|
-
*/
|
|
34
|
-
constructor(renderer: GLRenderer, font: TextmodeFont, grid: TextmodeGrid);
|
|
35
|
-
/**
|
|
36
|
-
* Performs the conversion process by applying all converters in the pipeline.
|
|
37
|
-
* @param sourceFramebuffer The source framebuffer to convert.
|
|
38
|
-
* @ignore
|
|
39
|
-
*/
|
|
40
|
-
$render(sourceFramebuffer: Framebuffer): void;
|
|
41
|
-
/**
|
|
42
|
-
* Adds a new converter to the pipeline.
|
|
43
|
-
* @param converter The converter instance to add.
|
|
44
|
-
* @returns The added {@link TextmodeConverter} instance.
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* Adds a new converter to the pipeline.
|
|
48
|
-
* @param type The type of converter to add. Can be either "brightness" or "custom".
|
|
49
|
-
* @returns The newly created {@link TextmodeConverter} instance or `void` if the addition failed.
|
|
50
|
-
*/
|
|
51
|
-
add(type: "brightness" | "custom"): TextmodeConverter | void;
|
|
52
|
-
/**
|
|
53
|
-
* Removes a converter from the pipeline.
|
|
54
|
-
* @param converter The converter instance to remove.
|
|
55
|
-
*/
|
|
56
|
-
remove(converter: TextmodeConverter): void;
|
|
57
|
-
/**
|
|
58
|
-
* Swaps two converters in the pipeline.
|
|
59
|
-
* @param first Either an index *(integer)* or a {@link TextmodeConverter} instance.
|
|
60
|
-
* @param second Either an index *(integer)* or a {@link TextmodeConverter} instance.
|
|
61
|
-
*/
|
|
62
|
-
swap(first: number | TextmodeConverter, second: number | TextmodeConverter): void;
|
|
63
|
-
/**
|
|
64
|
-
* Resizes all internal framebuffers.
|
|
65
|
-
* @ignore
|
|
66
|
-
*/
|
|
67
|
-
$resize(): void;
|
|
68
|
-
/**
|
|
69
|
-
* Checks if any converter in the pipeline is enabled.
|
|
70
|
-
* @returns `true` if any converter is enabled, `false` otherwise.
|
|
71
|
-
*/
|
|
72
|
-
hasEnabledConverters(): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Disables all converters in the pipeline.
|
|
75
|
-
*/
|
|
76
|
-
disable(): void;
|
|
77
|
-
/**
|
|
78
|
-
* Enables all converters in the pipeline.
|
|
79
|
-
*/
|
|
80
|
-
enable(): void;
|
|
81
|
-
/**
|
|
82
|
-
* Dispose of all resources used by this conversion pipeline.
|
|
83
|
-
* @ignore
|
|
84
|
-
*/
|
|
85
|
-
$dispose(): void;
|
|
86
|
-
/** Returns the framebuffer containing the textmode conversion result.*/
|
|
87
|
-
get texture(): Framebuffer;
|
|
88
|
-
/** Returns the character framebuffer containing the combined result of all converters. */
|
|
89
|
-
get characterFramebuffer(): Framebuffer;
|
|
90
|
-
/** Returns the primary color framebuffer containing the combined result of all converters. */
|
|
91
|
-
get primaryColorFramebuffer(): Framebuffer;
|
|
92
|
-
/** Returns the secondary color framebuffer containing the combined result of all converters. */
|
|
93
|
-
get secondaryColorFramebuffer(): Framebuffer;
|
|
94
|
-
/** Returns the rotation framebuffer containing the combined result of all converters. */
|
|
95
|
-
get rotationFramebuffer(): Framebuffer;
|
|
96
|
-
/** Returns the transform framebuffer containing the combined result of all converters. */
|
|
97
|
-
get transformFramebuffer(): Framebuffer;
|
|
98
|
-
/**
|
|
99
|
-
* Returns the pre-defined brightness converter that is part of the pipeline by default.
|
|
100
|
-
*
|
|
101
|
-
* This converter can also be removed from the pipeline via `pipeline.remove(pipeline.brightness)`.
|
|
102
|
-
*/
|
|
103
|
-
get brightness(): TextmodeBrightnessConverter;
|
|
104
|
-
/**
|
|
105
|
-
* Returns the pre-defined custom converter that is part of the pipeline by default.
|
|
106
|
-
*
|
|
107
|
-
* This converter can also be removed from the pipeline via `pipeline.remove(pipeline.custom)`.
|
|
108
|
-
*/
|
|
109
|
-
get custom(): TextmodeConverter;
|
|
110
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { GLRenderer } from "../../rendering/webgl/Renderer";
|
|
2
|
-
import { TextmodeFont } from "../font";
|
|
3
|
-
import { TextmodeGrid } from "../Grid";
|
|
4
|
-
import { TextmodeFeatureConverter, type TextmodeFeatureConverterOptions } from "./FeatureConverter";
|
|
5
|
-
import type { Framebuffer } from "../../rendering";
|
|
6
|
-
/**
|
|
7
|
-
* Options interface for the brightness converter.
|
|
8
|
-
*/
|
|
9
|
-
export interface TextmodeBrightnessConverterOptions extends TextmodeFeatureConverterOptions {
|
|
10
|
-
/** Range of brightness values to map to ASCII characters */
|
|
11
|
-
brightnessRange: [number, number];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Default brightness converter options used when no options are specified.
|
|
15
|
-
*
|
|
16
|
-
* **Default values:**
|
|
17
|
-
* - `enabled`: `true` - Enable the brightness converter
|
|
18
|
-
* - `characters`: `" .:-=+*%@#"` - Character set for brightness mapping *(from darkest to brightest)*
|
|
19
|
-
* - `characterColor`: `#FFFFFF` - White color for ASCII characters *(only used when `characterColorMode` is `'fixed'`)*
|
|
20
|
-
* - `characterColorMode`: `'sampled'` - Sample character colors from source texture
|
|
21
|
-
* - `cellColor`: `#000000` - Black background color for cells *(only used when `cellColorMode` is `'fixed'`)*
|
|
22
|
-
* - `cellColorMode`: `'fixed'` - Use fixed background color for all cells
|
|
23
|
-
* - `invert`: `false` - Don't swap character and background colors
|
|
24
|
-
* - `rotation`: `0` - No rotation applied to characters
|
|
25
|
-
* - `flipHorizontally`: `false` - Don't flip characters horizontally
|
|
26
|
-
* - `flipVertically`: `false` - Don't flip characters vertically
|
|
27
|
-
* - `brightnessRange`: `[0, 255]` - Full brightness range for character mapping
|
|
28
|
-
*/
|
|
29
|
-
export declare const BRIGHTNESS_DEFAULT_OPTIONS: TextmodeBrightnessConverterOptions;
|
|
30
|
-
/**
|
|
31
|
-
* Converter that maps brightness values from a source texture to ASCII characters.
|
|
32
|
-
*/
|
|
33
|
-
export declare class TextmodeBrightnessConverter extends TextmodeFeatureConverter<TextmodeBrightnessConverterOptions> {
|
|
34
|
-
private _sampleShader;
|
|
35
|
-
private _colorFillShader;
|
|
36
|
-
private _charMappingShader;
|
|
37
|
-
private _transformFillShader;
|
|
38
|
-
private _rotationFillShader;
|
|
39
|
-
private _sampleFramebuffer;
|
|
40
|
-
/**
|
|
41
|
-
* Creates a new TextmodeBrightnessConverter instance.
|
|
42
|
-
* @param renderer Renderer instance for texture creation
|
|
43
|
-
* @param fontManager Font manager for character extraction and color mapping
|
|
44
|
-
* @param grid Grid manager for layout and positioning
|
|
45
|
-
* @ignore
|
|
46
|
-
*/
|
|
47
|
-
constructor(renderer: GLRenderer, fontManager: TextmodeFont, grid: TextmodeGrid);
|
|
48
|
-
$convert(framebuffer: Framebuffer): void;
|
|
49
|
-
$resize(): void;
|
|
50
|
-
/**
|
|
51
|
-
* Sets the brightness range for ASCII character mapping.
|
|
52
|
-
*
|
|
53
|
-
* Cells that sample outside this range are rendered as transparent.
|
|
54
|
-
*
|
|
55
|
-
* @param range Array of two numbers `[min, max]`, where `min` is darkest and `max` is brightest.
|
|
56
|
-
*/
|
|
57
|
-
brightnessRange(range: [number, number]): void;
|
|
58
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { TextmodeFont } from "../font";
|
|
2
|
-
import type { GLRenderer } from "../../rendering/webgl/Renderer";
|
|
3
|
-
import type { TextmodeGrid } from "../Grid";
|
|
4
|
-
import type { Framebuffer } from "../../rendering";
|
|
5
|
-
/**
|
|
6
|
-
* Base options interface for all textmode converters.
|
|
7
|
-
*/
|
|
8
|
-
export interface TextmodeConverterOptions {
|
|
9
|
-
/** Enable/disable the converter */
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Base class for all textmode converters.
|
|
14
|
-
*/
|
|
15
|
-
export declare class TextmodeConverter<TOptions extends TextmodeConverterOptions = TextmodeConverterOptions> {
|
|
16
|
-
protected _renderer: GLRenderer;
|
|
17
|
-
protected _fontManager: TextmodeFont;
|
|
18
|
-
protected _grid: TextmodeGrid;
|
|
19
|
-
protected _characterFramebuffer: Framebuffer;
|
|
20
|
-
protected _primaryColorFramebuffer: Framebuffer;
|
|
21
|
-
protected _secondaryColorFramebuffer: Framebuffer;
|
|
22
|
-
protected _rotationFramebuffer: Framebuffer;
|
|
23
|
-
protected _transformFramebuffer: Framebuffer;
|
|
24
|
-
protected _options: TOptions;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new TextmodeConverter instance.
|
|
27
|
-
* @param renderer Renderer instance for texture creation
|
|
28
|
-
* @param fontManager Font manager for character extraction and color mapping
|
|
29
|
-
* @param grid Grid instance for managing textmode layout
|
|
30
|
-
* @param options Additional options for the converter
|
|
31
|
-
* @ignore
|
|
32
|
-
*/
|
|
33
|
-
constructor(renderer: GLRenderer, fontManager: TextmodeFont, grid: TextmodeGrid, options?: Partial<TOptions>);
|
|
34
|
-
/**
|
|
35
|
-
* Resizes all internal framebuffers to match the grid dimensions.
|
|
36
|
-
* @ignore
|
|
37
|
-
*/
|
|
38
|
-
$resize(): void;
|
|
39
|
-
/**
|
|
40
|
-
* Enables or disables the converter.
|
|
41
|
-
* @param enabled Whether to enable or disable the converter.<br/>Accepts boolean or number *(0 = false, any other number = true)*.
|
|
42
|
-
*/
|
|
43
|
-
enabled(enabled: boolean | number): void;
|
|
44
|
-
/**
|
|
45
|
-
* Enables the converter.
|
|
46
|
-
*/
|
|
47
|
-
enable(): void;
|
|
48
|
-
/**
|
|
49
|
-
* Disables the converter.
|
|
50
|
-
*/
|
|
51
|
-
disable(): void;
|
|
52
|
-
/**
|
|
53
|
-
* Dispose of all framebuffers used by this converter.
|
|
54
|
-
* @ignore
|
|
55
|
-
*/
|
|
56
|
-
$dispose(): void;
|
|
57
|
-
/** Returns the framebuffer containing character data. */
|
|
58
|
-
get characterFramebuffer(): Framebuffer;
|
|
59
|
-
/** Returns the framebuffer containing primary color data. */
|
|
60
|
-
get primaryColorFramebuffer(): Framebuffer;
|
|
61
|
-
/** Returns the framebuffer containing secondary color data. */
|
|
62
|
-
get secondaryColorFramebuffer(): Framebuffer;
|
|
63
|
-
/** Returns the framebuffer containing rotation data. */
|
|
64
|
-
get rotationFramebuffer(): Framebuffer;
|
|
65
|
-
/** Returns the framebuffer containing transformation data. */
|
|
66
|
-
get transformFramebuffer(): Framebuffer;
|
|
67
|
-
/** Returns the defined options for this converter. */
|
|
68
|
-
get options(): TOptions;
|
|
69
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { TextmodeColorPalette } from "../../ColorPalette";
|
|
2
|
-
import type { TextmodeFont } from "../font";
|
|
3
|
-
import type { GLRenderer } from "../../rendering/webgl/Renderer";
|
|
4
|
-
import type { TextmodeGrid } from "../Grid";
|
|
5
|
-
import { TextmodeConverter, type TextmodeConverterOptions } from "./Converter";
|
|
6
|
-
import type { Framebuffer } from "../../rendering";
|
|
7
|
-
/**
|
|
8
|
-
* Options interface for feature-based textmode converters.
|
|
9
|
-
*/
|
|
10
|
-
export interface TextmodeFeatureConverterOptions extends TextmodeConverterOptions {
|
|
11
|
-
/** Characters used for mapping, usually ordered from least dense to most dense */
|
|
12
|
-
characters: string;
|
|
13
|
-
/** Color of the characters. Only used when `characterColorMode` is set to `'fixed'` */
|
|
14
|
-
characterColor: [number, number, number, number];
|
|
15
|
-
/** Character color mode */
|
|
16
|
-
characterColorMode: "sampled" | "fixed";
|
|
17
|
-
/** Cell background color. Only used when `cellColorMode` is set to `'fixed'` */
|
|
18
|
-
cellColor: [number, number, number, number];
|
|
19
|
-
/** Background color mode */
|
|
20
|
-
cellColorMode: "sampled" | "fixed";
|
|
21
|
-
/** Swap the character and cell colors */
|
|
22
|
-
invert: boolean;
|
|
23
|
-
/** Rotation angle stored as RGBA where RGB encodes the rotation and A is always 1 */
|
|
24
|
-
rotation: [number, number, number, number];
|
|
25
|
-
/** Flip the characters horizontally */
|
|
26
|
-
flipHorizontally: boolean;
|
|
27
|
-
/** Flip the characters vertically */
|
|
28
|
-
flipVertically: boolean;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Abstract base class for all feature-based textmode converters like `'brightness'`.
|
|
32
|
-
*/
|
|
33
|
-
export declare abstract class TextmodeFeatureConverter<TOptions extends TextmodeFeatureConverterOptions = TextmodeFeatureConverterOptions> extends TextmodeConverter<TOptions> {
|
|
34
|
-
protected _palette: TextmodeColorPalette;
|
|
35
|
-
protected constructor(renderer: GLRenderer, fontManager: TextmodeFont, grid: TextmodeGrid, options?: Partial<TOptions>);
|
|
36
|
-
/**
|
|
37
|
-
* Converts the source framebuffer to the target format.
|
|
38
|
-
* @param sourceFramebuffer The source framebuffer to convert.
|
|
39
|
-
* @ignore
|
|
40
|
-
*/
|
|
41
|
-
abstract $convert(sourceFramebuffer: Framebuffer): void;
|
|
42
|
-
/**
|
|
43
|
-
* Sets the characters used for mapping.
|
|
44
|
-
* @param characters The characters to use for mapping, usually ordered from least dense to most dense.
|
|
45
|
-
*/
|
|
46
|
-
characters(characters: string): void;
|
|
47
|
-
/**
|
|
48
|
-
* Sets the color of the characters affected by the converter.
|
|
49
|
-
* This is only used when `characterColorMode` is set to `'fixed'`.
|
|
50
|
-
* @param r Red component (0-255) or hex string *(e.g., '#FF0000', '#F00', 'FF0000', 'F00')*.
|
|
51
|
-
* @param g Green component (0-255).
|
|
52
|
-
* @param b Blue component (0-255).
|
|
53
|
-
* @param a Alpha component (0-255).
|
|
54
|
-
*/
|
|
55
|
-
characterColor(r: number | string, g?: number, b?: number, a?: number): void;
|
|
56
|
-
/**
|
|
57
|
-
* Sets the character color mode.
|
|
58
|
-
* - `'sampled'`: Uses sampled colors from the source texture.
|
|
59
|
-
* - `'fixed'`: Uses a fixed color set by `characterColor()`.
|
|
60
|
-
* @param mode The color mode to use for characters.
|
|
61
|
-
*/
|
|
62
|
-
characterColorMode(mode: "sampled" | "fixed"): void;
|
|
63
|
-
/**
|
|
64
|
-
* Sets the cell color for all cells affected by the converter.
|
|
65
|
-
* This is only used when `cellColorMode` is set to `'fixed'`.
|
|
66
|
-
* @param r Red component (0-255) or hex string *(e.g., '#FF0000', '#F00', 'FF0000', 'F00')*.
|
|
67
|
-
* @param g Green component (0-255).
|
|
68
|
-
* @param b Blue component (0-255).
|
|
69
|
-
* @param a Alpha component (0-255).
|
|
70
|
-
*/
|
|
71
|
-
cellColor(r: number | string, g?: number, b?: number, a?: number): void;
|
|
72
|
-
/**
|
|
73
|
-
* Sets the cell color mode.
|
|
74
|
-
* - `'sampled'`: Uses sampled colors from the source texture.
|
|
75
|
-
* - `'fixed'`: Uses a fixed color set via {@link cellColor}.
|
|
76
|
-
* @param mode The color mode to use for background cells.
|
|
77
|
-
*/
|
|
78
|
-
cellColorMode(mode: "sampled" | "fixed"): void;
|
|
79
|
-
/**
|
|
80
|
-
* Swaps the character and cell color.
|
|
81
|
-
* @param invert If `true`, the character color becomes the cell color and vice versa.
|
|
82
|
-
*/
|
|
83
|
-
invert(invert: boolean | number): void;
|
|
84
|
-
/**
|
|
85
|
-
* Sets the rotation angle for the characters.
|
|
86
|
-
* @param angle The rotation angle in degrees.
|
|
87
|
-
*/
|
|
88
|
-
rotation(angle: number): void;
|
|
89
|
-
/**
|
|
90
|
-
* Flips the characters horizontally.
|
|
91
|
-
* @param flip If `true`, characters are flipped horizontally. If `false`, no flip is applied.
|
|
92
|
-
*/
|
|
93
|
-
flipHorizontally(flip: boolean | number): void;
|
|
94
|
-
/**
|
|
95
|
-
* Flips the characters vertically.
|
|
96
|
-
* @param flip If `true`, characters are flipped vertically. If `false`, no flip is applied.
|
|
97
|
-
*/
|
|
98
|
-
flipVertically(flip: boolean | number): void;
|
|
99
|
-
/**
|
|
100
|
-
* Helper method to parse color values from either hex string or RGB(A) parameters.
|
|
101
|
-
* @param r Red component (0-255) or hex string.
|
|
102
|
-
* @param methodName The name of the calling method for error reporting.
|
|
103
|
-
* @param g Green component (0-255).
|
|
104
|
-
* @param b Blue component (0-255).
|
|
105
|
-
* @param a Alpha component (0-255).
|
|
106
|
-
* @returns Normalized RGBA array [r, g, b, a] (0-1 range) or null if invalid.
|
|
107
|
-
*/
|
|
108
|
-
private _parseColor;
|
|
109
|
-
/**
|
|
110
|
-
* Helper method to set color mode with validation.
|
|
111
|
-
* @param mode The color mode to set.
|
|
112
|
-
* @param optionKey The option key to set in _options.
|
|
113
|
-
*/
|
|
114
|
-
private _setColorMode;
|
|
115
|
-
/**
|
|
116
|
-
* Helper method to set boolean options with validation.
|
|
117
|
-
* @param value The boolean or number value to set.
|
|
118
|
-
* @param optionKey The option key to set in _options.
|
|
119
|
-
* @param displayName The display name for error messages.
|
|
120
|
-
*/
|
|
121
|
-
private _setBooleanOption;
|
|
122
|
-
/**
|
|
123
|
-
* Parses a hex color string and returns RGBA values.
|
|
124
|
-
* @param hex Hex color string (e.g., '#FF0000', '#F00', 'FF0000', 'F00').
|
|
125
|
-
* @returns RGBA array [r, g, b, a] or null if invalid.
|
|
126
|
-
*/
|
|
127
|
-
private _parseHexColor;
|
|
128
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { TextmodeConverter, type TextmodeConverterOptions } from './Converter';
|
|
2
|
-
export { TextmodeFeatureConverter, type TextmodeFeatureConverterOptions } from './FeatureConverter';
|
|
3
|
-
export { TextmodeBrightnessConverter, type TextmodeBrightnessConverterOptions, BRIGHTNESS_DEFAULT_OPTIONS } from './BrightnessConverter';
|