textmode.js 0.1.6-beta.4 → 0.1.6-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/textmode.esm.js +1487 -4016
- package/dist/textmode.esm.min.js +1486 -4014
- package/dist/textmode.umd.js +19 -19
- package/dist/textmode.umd.min.js +18 -18
- package/dist/types/ColorPalette.d.ts +1 -5
- package/dist/types/Textmode.d.ts +0 -10
- package/dist/types/export/image/ImageDataExtractor.d.ts +1 -1
- package/dist/types/export/image/ImageExporter.d.ts +1 -1
- package/dist/types/export/image/ImageFileHandler.d.ts +1 -7
- package/dist/types/export/svg/SVGContentGenerator.d.ts +1 -1
- package/dist/types/export/svg/SVGDataExtractor.d.ts +1 -1
- package/dist/types/export/svg/SVGPathGenerator.d.ts +0 -5
- package/dist/types/export/txt/TXTDataExtractor.d.ts +1 -1
- package/dist/types/index.d.ts +0 -1
- 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/Canvas.d.ts +0 -11
- package/dist/types/textmode/ConversionPipeline.d.ts +12 -9
- package/dist/types/textmode/Grid.d.ts +1 -6
- package/dist/types/textmode/Textmodifier.d.ts +28 -610
- package/dist/types/textmode/converters/FeatureConverter.d.ts +24 -0
- package/dist/types/textmode/mixins/ConversionMixin.d.ts +63 -0
- package/dist/types/textmode/mixins/ExportMixin.d.ts +155 -0
- package/dist/types/textmode/mixins/FontMixin.d.ts +49 -0
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +409 -0
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +39 -0
- package/dist/types/textmode/mixins/index.d.ts +5 -0
- package/package.json +3 -1
- 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
- package/dist/types/types/index.d.ts +0 -4
|
@@ -5,12 +5,13 @@ export declare class Shader {
|
|
|
5
5
|
private gl;
|
|
6
6
|
private program;
|
|
7
7
|
private uniformLocations;
|
|
8
|
-
private
|
|
8
|
+
private uniformTypes;
|
|
9
9
|
private textureUnitCounter;
|
|
10
|
+
private maxTextureUnits;
|
|
10
11
|
constructor(gl: WebGLRenderingContext, vertexSource: string, fragmentSource: string);
|
|
12
|
+
private cacheLocations;
|
|
11
13
|
private createProgram;
|
|
12
14
|
private createShader;
|
|
13
|
-
private cacheLocations;
|
|
14
15
|
/**
|
|
15
16
|
* Use this shader program
|
|
16
17
|
*/
|
|
@@ -19,19 +20,11 @@ export declare class Shader {
|
|
|
19
20
|
* Set a single uniform value with automatic texture unit management
|
|
20
21
|
*/
|
|
21
22
|
setUniform(name: string, value: any): void;
|
|
22
|
-
/**
|
|
23
|
-
* Get uniform info to determine the correct WebGL type
|
|
24
|
-
*/
|
|
25
|
-
private getUniformInfo;
|
|
26
23
|
private getNextTextureUnit;
|
|
27
24
|
/**
|
|
28
|
-
* Check if
|
|
29
|
-
*/
|
|
30
|
-
hasUniform(name: string): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Check if this shader has a specific attribute
|
|
25
|
+
* Check if a uniform is an integer type
|
|
33
26
|
*/
|
|
34
|
-
|
|
27
|
+
private isUniformInteger;
|
|
35
28
|
/**
|
|
36
29
|
* Get the WebGL program
|
|
37
30
|
*/
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
type Viewport = [number, number, number, number];
|
|
2
2
|
export declare function setViewport(gl: WebGLRenderingContext, vp: Viewport): void;
|
|
3
3
|
export declare function getViewport(gl: WebGLRenderingContext): Viewport | undefined;
|
|
4
|
-
export declare function setIsFramebufferTarget(gl: WebGLRenderingContext, isFbo: boolean): void;
|
|
5
|
-
export declare function getIsFramebufferTarget(gl: WebGLRenderingContext): boolean | undefined;
|
|
6
4
|
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for WebGL geometry rendering with shared vertex buffer management
|
|
3
|
+
*/
|
|
4
|
+
export declare abstract class BaseGeometry {
|
|
5
|
+
protected gl: WebGLRenderingContext;
|
|
6
|
+
protected unitBuffer: WebGLBuffer | null;
|
|
7
|
+
protected bytesPerVertex: number;
|
|
8
|
+
private attribCache;
|
|
9
|
+
constructor(gl: WebGLRenderingContext);
|
|
10
|
+
/**
|
|
11
|
+
* Ensure the unit buffer is created and bound
|
|
12
|
+
*/
|
|
13
|
+
protected ensureUnitBuffer(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Enable vertex attributes and return their locations
|
|
16
|
+
*/
|
|
17
|
+
protected enableAttribs(): {
|
|
18
|
+
positionLoc: number;
|
|
19
|
+
texLoc: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Disable vertex attributes
|
|
23
|
+
*/
|
|
24
|
+
protected disableAttribs(positionLoc: number, texLoc: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Convert screen coordinates to NDC (Normalized Device Coordinates)
|
|
27
|
+
*/
|
|
28
|
+
protected toNDC(x: number, y: number): {
|
|
29
|
+
nx: number;
|
|
30
|
+
ny: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Upload quad vertices to the buffer in NDC coordinates
|
|
34
|
+
*/
|
|
35
|
+
protected uploadQuadNDC(x1: number, y1: number, x2: number, y2: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Dispose of WebGL resources used by this geometry
|
|
38
|
+
*/
|
|
39
|
+
dispose(): void;
|
|
40
|
+
}
|
|
@@ -1,31 +1,11 @@
|
|
|
1
|
+
import { BaseGeometry } from './BaseGeometry';
|
|
1
2
|
/**
|
|
2
|
-
* Line geometry
|
|
3
|
-
* Handles coordinate system differences between canvas and framebuffer targets by flipping Y-axis for framebuffers.
|
|
4
|
-
* Creates a rectangular geometry to represent the line segment with the specified thickness.
|
|
3
|
+
* Line geometry renderer
|
|
5
4
|
*/
|
|
6
|
-
export declare class Line {
|
|
7
|
-
|
|
8
|
-
private gl;
|
|
9
|
-
/** The vertex buffer containing position and texture coordinates */
|
|
10
|
-
private vertexBuffer;
|
|
11
|
-
/** The number of vertices in this geometry (always 6 for two triangles) */
|
|
12
|
-
private readonly vertexCount;
|
|
13
|
-
/** Bytes per vertex: vec2+vec2 = 16 bytes */
|
|
14
|
-
private bytesPerVertex;
|
|
15
|
-
constructor(gl: WebGLRenderingContext, x1: number, y1: number, x2: number, y2: number, weight: number);
|
|
5
|
+
export declare class Line extends BaseGeometry {
|
|
6
|
+
constructor(gl: WebGLRenderingContext);
|
|
16
7
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @private
|
|
8
|
+
* Draw a line from (x1, y1) to (x2, y2) with specified weight
|
|
19
9
|
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Generate vertex data for the line rectangle with texture coordinates
|
|
23
|
-
* Uses the four corners calculated based on line direction and thickness
|
|
24
|
-
* @private
|
|
25
|
-
*/
|
|
26
|
-
private generateLineVertices;
|
|
27
|
-
/**
|
|
28
|
-
* Render the line using position and texture coordinate attributes
|
|
29
|
-
*/
|
|
30
|
-
render(): void;
|
|
10
|
+
draw(x1: number, y1: number, x2: number, y2: number, weight: number): void;
|
|
31
11
|
}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
+
import { BaseGeometry } from './BaseGeometry';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Always includes texture coordinates for maximum shader compatibility.
|
|
4
|
-
* Handles coordinate system differences between canvas and framebuffer targets by flipping Y-axis for framebuffers.
|
|
3
|
+
* Rectangle geometry renderer with fill and stroke support
|
|
5
4
|
*/
|
|
6
|
-
export declare class Rectangle {
|
|
7
|
-
|
|
8
|
-
private gl;
|
|
9
|
-
/** The vertex buffer containing position and texture coordinates */
|
|
10
|
-
private vertexBuffer;
|
|
11
|
-
/** The number of vertices in this geometry (always 6 for two triangles) */
|
|
12
|
-
private readonly vertexCount;
|
|
13
|
-
/** Bytes per vertex: depends on position format (vec2 vs vec3) */
|
|
14
|
-
private bytesPerVertex;
|
|
15
|
-
constructor(gl: WebGLRenderingContext, x: number, y: number, width: number, height: number);
|
|
5
|
+
export declare class Rectangle extends BaseGeometry {
|
|
6
|
+
constructor(gl: WebGLRenderingContext);
|
|
16
7
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @private
|
|
8
|
+
* Draw a filled rectangle
|
|
19
9
|
*/
|
|
20
|
-
|
|
10
|
+
drawFill(x: number, y: number, width: number, height: number): void;
|
|
21
11
|
/**
|
|
22
|
-
*
|
|
12
|
+
* Draw a rectangle stroke (outline)
|
|
23
13
|
*/
|
|
24
|
-
|
|
14
|
+
drawStroke(x: number, y: number, width: number, height: number, weight: number): void;
|
|
25
15
|
}
|
|
@@ -23,17 +23,6 @@ export declare class TextmodeCanvas {
|
|
|
23
23
|
* Get the WebGL context for the overlay canvas
|
|
24
24
|
*/
|
|
25
25
|
getWebGLContext(): WebGL2RenderingContext | WebGLRenderingContext;
|
|
26
|
-
/**
|
|
27
|
-
* Get the effective rendering dimensions accounting for CSS transforms
|
|
28
|
-
*/
|
|
29
|
-
getEffectiveRenderingDimensions(): {
|
|
30
|
-
width: number;
|
|
31
|
-
height: number;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Check if the canvas is affected by CSS transforms
|
|
35
|
-
*/
|
|
36
|
-
isTransformed(): boolean;
|
|
37
26
|
/**
|
|
38
27
|
* Set up ResizeObserver to monitor for CSS transform changes
|
|
39
28
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Framebuffer } from "../rendering/webgl/Framebuffer";
|
|
2
2
|
import type { GLRenderer } from "../rendering/webgl/Renderer";
|
|
3
|
-
import { TextmodeConverter } from "./converters";
|
|
3
|
+
import { TextmodeBrightnessConverter, TextmodeConverter } from "./converters";
|
|
4
4
|
import type { TextmodeFont } from "./font";
|
|
5
5
|
import type { TextmodeGrid } from "./Grid";
|
|
6
6
|
/**
|
|
@@ -15,6 +15,10 @@ export declare class TextmodeConversionPipeline {
|
|
|
15
15
|
private font;
|
|
16
16
|
private grid;
|
|
17
17
|
private converters;
|
|
18
|
+
/** Pre-configured brightness converter for easy access */
|
|
19
|
+
readonly brightness: TextmodeBrightnessConverter;
|
|
20
|
+
/** Pre-configured custom converter for easy access */
|
|
21
|
+
readonly custom: TextmodeConverter;
|
|
18
22
|
private _resultFramebuffer;
|
|
19
23
|
private _asciiShader;
|
|
20
24
|
private _characterFramebuffer;
|
|
@@ -37,23 +41,22 @@ export declare class TextmodeConversionPipeline {
|
|
|
37
41
|
*/
|
|
38
42
|
render(sourceFramebuffer: Framebuffer): void;
|
|
39
43
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param
|
|
42
|
-
* @returns The
|
|
44
|
+
* Adds a new converter to the pipeline.
|
|
45
|
+
* @param converter The converter instance to add.
|
|
46
|
+
* @returns The added {@link TextmodeConverter} instance.
|
|
43
47
|
*/
|
|
44
|
-
get(name: string): TextmodeConverter | void;
|
|
45
48
|
/**
|
|
46
49
|
* Adds a new converter to the pipeline.
|
|
47
50
|
* @param name A unique name for the converter.
|
|
48
51
|
* @param type The type of converter to add. Can be either "brightness" or "custom".
|
|
49
52
|
* @returns The newly created {@link TextmodeConverter} instance or `void` if the addition failed.
|
|
50
53
|
*/
|
|
51
|
-
add(
|
|
54
|
+
add(type: "brightness" | "custom"): TextmodeConverter | void;
|
|
52
55
|
/**
|
|
53
|
-
* Removes a converter from the pipeline
|
|
54
|
-
* @param
|
|
56
|
+
* Removes a converter from the pipeline.
|
|
57
|
+
* @param converter The converter instance to remove.
|
|
55
58
|
*/
|
|
56
|
-
remove(
|
|
59
|
+
remove(converter: TextmodeConverter): void;
|
|
57
60
|
/**
|
|
58
61
|
* Returns the framebuffer containing the textmode conversion result.
|
|
59
62
|
*/
|
|
@@ -38,7 +38,7 @@ export declare class TextmodeGrid {
|
|
|
38
38
|
/**
|
|
39
39
|
* Reset the total grid width & height, and the offset to the outer canvas.
|
|
40
40
|
*/
|
|
41
|
-
private
|
|
41
|
+
private _updateDimensions;
|
|
42
42
|
/**
|
|
43
43
|
* Re-assign the grid cell dimensions and `reset()` the grid.
|
|
44
44
|
* @param newCellWidth The new cell width.
|
|
@@ -77,11 +77,6 @@ export declare class TextmodeGrid {
|
|
|
77
77
|
get cellWidth(): number;
|
|
78
78
|
/** Returns the height of each cell in the grid. */
|
|
79
79
|
get cellHeight(): number;
|
|
80
|
-
/**
|
|
81
|
-
* Dispose of this TextmodeGrid and clean up references.
|
|
82
|
-
* This method is idempotent and safe to call multiple times.
|
|
83
|
-
*/
|
|
84
|
-
dispose(): void;
|
|
85
80
|
/** Returns the number of columns in the grid. */
|
|
86
81
|
get cols(): number;
|
|
87
82
|
/** Returns the number of rows in the grid. */
|