textmode.js 0.2.1-beta.1 → 0.2.1-beta.2
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 +1466 -1433
- package/dist/textmode.esm.min.js +1331 -1298
- package/dist/textmode.umd.js +10 -26
- package/dist/textmode.umd.min.js +9 -25
- package/dist/types/assets/shaders-minified/frag/ascii.d.ts +14 -0
- package/dist/types/assets/shaders-minified/frag/copy-mrt.d.ts +14 -0
- package/dist/types/assets/shaders-minified/frag/instanced-ascii-mrt.d.ts +14 -0
- package/dist/types/assets/shaders-minified/index.d.ts +5 -0
- package/dist/types/assets/shaders-minified/vert/instanced-ascii-mrt.d.ts +14 -0
- package/dist/types/assets/shaders-minified/vert/shader.d.ts +14 -0
- package/dist/types/export/svg/SVGContentGenerator.d.ts +0 -6
- package/dist/types/index.d.ts +2 -0
- package/dist/types/rendering/index.d.ts +2 -0
- package/dist/types/rendering/webgl/Framebuffer.d.ts +8 -8
- package/dist/types/rendering/webgl/InstanceData.d.ts +1 -1
- package/dist/types/rendering/webgl/RenderPipeline.d.ts +10 -3
- package/dist/types/rendering/webgl/RenderState.d.ts +11 -11
- package/dist/types/rendering/webgl/Renderer.d.ts +26 -2
- package/dist/types/rendering/webgl/Shader.d.ts +6 -7
- package/dist/types/rendering/webgl/ShaderManager.d.ts +65 -1
- package/dist/types/rendering/webgl/index.d.ts +1 -0
- package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +7 -7
- package/dist/types/rendering/webgl/types/ShaderTypes.d.ts +35 -0
- package/dist/types/textmode/Textmodifier.d.ts +2 -2
- package/dist/types/textmode/managers/index.d.ts +4 -0
- package/dist/types/textmode/mixins/KeyboardMixin.d.ts +1 -1
- package/dist/types/textmode/mixins/MouseMixin.d.ts +1 -1
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +85 -0
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +2 -2
- package/dist/types/textmode/mixins/index.d.ts +2 -2
- package/package.json +3 -2
- package/dist/types/textmode/keyboard/index.d.ts +0 -2
- package/dist/types/textmode/mouse/index.d.ts +0 -2
- /package/dist/types/textmode/{keyboard → managers}/KeyboardManager.d.ts +0 -0
- /package/dist/types/textmode/{mouse → managers}/MouseManager.d.ts +0 -0
|
@@ -2,6 +2,10 @@ import type { IGeometry } from './types/GeometryTypes';
|
|
|
2
2
|
import { GeometryType } from './types/GeometryTypes';
|
|
3
3
|
import type { RenderContext } from './types/RenderTypes';
|
|
4
4
|
import type { DrawCommand } from './types/DrawCommand';
|
|
5
|
+
import { GLShader } from './Shader';
|
|
6
|
+
interface IShaderProvider {
|
|
7
|
+
$getCopyShader(): GLShader;
|
|
8
|
+
}
|
|
5
9
|
/**
|
|
6
10
|
* Execute draw commands exactly in the order they were enqueued while
|
|
7
11
|
* still batching consecutive commands of the same geometry type to minimize
|
|
@@ -10,13 +14,16 @@ import type { DrawCommand } from './types/DrawCommand';
|
|
|
10
14
|
export declare class RenderPipeline {
|
|
11
15
|
private readonly _vaoMgr;
|
|
12
16
|
private readonly _gl;
|
|
13
|
-
private
|
|
17
|
+
private readonly _renderer;
|
|
14
18
|
private _tempRectFBO;
|
|
15
19
|
private _tempRectFBOSize;
|
|
16
|
-
constructor(gl: WebGL2RenderingContext);
|
|
20
|
+
constructor(gl: WebGL2RenderingContext, renderer: IShaderProvider);
|
|
17
21
|
$execute(context: RenderContext, commands: Iterable<DrawCommand>, geometries: Map<GeometryType, IGeometry>): void;
|
|
18
|
-
/**
|
|
22
|
+
/** Execute a custom-shaded rectangle using provided shader/uniforms */
|
|
19
23
|
private _drawCustomRect;
|
|
24
|
+
/** Draw a rectangle with the specified shader, uniforms, and viewport handling */
|
|
25
|
+
private _drawRectangleWithShader;
|
|
20
26
|
private _getCopyShader;
|
|
21
27
|
private _getTempRectFBO;
|
|
22
28
|
}
|
|
29
|
+
export {};
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* Represents a snapshot of the current rendering state
|
|
3
3
|
*/
|
|
4
4
|
export interface IRenderState {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
_lineWeight: number;
|
|
6
|
+
_rotationX: number;
|
|
7
|
+
_rotationY: number;
|
|
8
|
+
_rotationZ: number;
|
|
9
|
+
_character: [number, number, number];
|
|
10
|
+
_charColor: [number, number, number, number];
|
|
11
|
+
_cellColor: [number, number, number, number];
|
|
12
|
+
_flipHorizontally: boolean;
|
|
13
|
+
_flipVertically: boolean;
|
|
14
|
+
_invert: boolean;
|
|
15
|
+
_charRotation: [number, number];
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Manages rendering state and provides push/pop functionality for state management
|
|
@@ -2,12 +2,14 @@ import { GLFramebuffer } from "./Framebuffer";
|
|
|
2
2
|
import type { FramebufferOptions } from '../webgl/Framebuffer';
|
|
3
3
|
import { GLShader } from "./Shader";
|
|
4
4
|
import { RenderState } from "./RenderState";
|
|
5
|
+
import type { ShaderSource } from './types/ShaderTypes';
|
|
5
6
|
/**
|
|
6
7
|
* Core WebGL renderer that manages the WebGL context and provides high-level rendering operations
|
|
7
8
|
*/
|
|
8
9
|
export declare class GLRenderer {
|
|
9
10
|
private _gl;
|
|
10
11
|
private _currentShader;
|
|
12
|
+
private _shaderManager;
|
|
11
13
|
private _userShader;
|
|
12
14
|
private _userUniforms;
|
|
13
15
|
private _ndcQuadBuffer;
|
|
@@ -15,6 +17,7 @@ export declare class GLRenderer {
|
|
|
15
17
|
private readonly _renderPipeline;
|
|
16
18
|
private readonly _drawQueue;
|
|
17
19
|
private _renderState;
|
|
20
|
+
private _stateStack;
|
|
18
21
|
constructor(gl: WebGL2RenderingContext);
|
|
19
22
|
/** Get or create a geometry instance */
|
|
20
23
|
private _getGeometry;
|
|
@@ -22,7 +25,19 @@ export declare class GLRenderer {
|
|
|
22
25
|
* Set the current shader
|
|
23
26
|
*/
|
|
24
27
|
$shader(shader: GLShader): void;
|
|
25
|
-
$createShader(vertexSource:
|
|
28
|
+
$createShader(vertexSource: ShaderSource, fragmentSource: ShaderSource): GLShader;
|
|
29
|
+
/**
|
|
30
|
+
* Get the shared MRT copy shader
|
|
31
|
+
*/
|
|
32
|
+
$getCopyShader(): GLShader;
|
|
33
|
+
/**
|
|
34
|
+
* Get the main MRT draw shader
|
|
35
|
+
*/
|
|
36
|
+
$getMainDrawShader(): GLShader;
|
|
37
|
+
/**
|
|
38
|
+
* Get the ASCII conversion shader
|
|
39
|
+
*/
|
|
40
|
+
$getConversionShader(): GLShader;
|
|
26
41
|
/**
|
|
27
42
|
* Set a custom user shader for subsequent rendering operations
|
|
28
43
|
*/
|
|
@@ -30,7 +45,7 @@ export declare class GLRenderer {
|
|
|
30
45
|
/**
|
|
31
46
|
* Set a uniform value for the current user shader
|
|
32
47
|
*/
|
|
33
|
-
$
|
|
48
|
+
$setUniform(name: string, value: any): void;
|
|
34
49
|
/**
|
|
35
50
|
* Set multiple uniform values for the current user shader
|
|
36
51
|
*/
|
|
@@ -39,6 +54,11 @@ export declare class GLRenderer {
|
|
|
39
54
|
* Create a filter shader using the standard instanced vertex shader
|
|
40
55
|
*/
|
|
41
56
|
$createFilterShader(fragmentSource: string): GLShader;
|
|
57
|
+
/**
|
|
58
|
+
* Enqueue an image blit from a source MRT framebuffer to the current render target.
|
|
59
|
+
* This uses the internal copy shader and preserves draw ordering within the pipeline.
|
|
60
|
+
*/
|
|
61
|
+
$imageRect(src: GLFramebuffer, x: number, y: number, width: number, height: number): void;
|
|
42
62
|
/**
|
|
43
63
|
* Draw a quad covering the pixel rectangle (x, y, width, height) on the canvas.
|
|
44
64
|
* The quad is converted to NDC and rendered with the current shader using only a_position.
|
|
@@ -109,6 +129,10 @@ export declare class GLRenderer {
|
|
|
109
129
|
*/
|
|
110
130
|
get context(): WebGLRenderingContext;
|
|
111
131
|
get state(): RenderState;
|
|
132
|
+
/** Internal: push a specific render state as current (used by user FBO begin) */
|
|
133
|
+
$pushState(state: RenderState): void;
|
|
134
|
+
/** Internal: pop the render state after user FBO end */
|
|
135
|
+
$popState(): void;
|
|
112
136
|
/**
|
|
113
137
|
* Flush all batched instances for instanced rendering.
|
|
114
138
|
* This must be called at the end of each frame to actually render the batched geometry.
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { GLFramebuffer } from './Framebuffer';
|
|
2
|
+
import type { ShaderSource } from './types/ShaderTypes';
|
|
2
3
|
/**
|
|
3
4
|
* Supported uniform value types
|
|
4
5
|
*/
|
|
5
6
|
type UniformValue = number | boolean | number[] | Float32Array | Int32Array | GLFramebuffer | WebGLTexture;
|
|
6
7
|
/**
|
|
7
8
|
* WebGL implementation of the shader abstraction.
|
|
8
|
-
* Provides GPU shader program management with automatic uniform handling.
|
|
9
|
+
* Provides GPU shader program management with automatic uniform handling and minification support.
|
|
9
10
|
*/
|
|
10
11
|
export declare class GLShader {
|
|
11
12
|
private _gl;
|
|
12
13
|
private _program;
|
|
13
14
|
private _uniformLocations;
|
|
14
|
-
private _uniformTypes;
|
|
15
15
|
private _textureUnitCounter;
|
|
16
|
-
private _maxTextureUnits;
|
|
17
16
|
/**
|
|
18
17
|
* Creates a new GLShader instance.
|
|
19
18
|
* @param gl The WebGL rendering context.
|
|
20
|
-
* @param vertexSource The source code for the vertex shader.
|
|
21
|
-
* @param fragmentSource The source code for the fragment shader.
|
|
19
|
+
* @param vertexSource The source code for the vertex shader (or ShaderData object).
|
|
20
|
+
* @param fragmentSource The source code for the fragment shader (or ShaderData object).
|
|
22
21
|
* @ignore
|
|
23
22
|
*/
|
|
24
|
-
constructor(gl: WebGLRenderingContext, vertexSource:
|
|
23
|
+
constructor(gl: WebGLRenderingContext, vertexSource: ShaderSource, fragmentSource: ShaderSource);
|
|
25
24
|
private _cacheLocations;
|
|
26
25
|
private _createProgram;
|
|
27
26
|
private _createShader;
|
|
@@ -39,7 +38,7 @@ export declare class GLShader {
|
|
|
39
38
|
*/
|
|
40
39
|
$hasUniform(name: string): boolean;
|
|
41
40
|
/**
|
|
42
|
-
* Set a single uniform value with automatic texture unit management
|
|
41
|
+
* Set a single uniform value with automatic texture unit management and minification support
|
|
43
42
|
*/
|
|
44
43
|
$setUniform(name: string, value: UniformValue): void;
|
|
45
44
|
private _getNextTextureUnit;
|
|
@@ -1 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
import { GLShader } from './Shader';
|
|
2
|
+
import type { ShaderSource } from './types/ShaderTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Registry keys for built-in shaders
|
|
5
|
+
*/
|
|
6
|
+
export declare enum BuiltInShader {
|
|
7
|
+
MRT_DRAW = "mrt-draw",
|
|
8
|
+
MRT_COPY = "mrt-copy",
|
|
9
|
+
ASCII_CONVERSION = "ascii-conversion"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Centralized shader management system for textmode.js
|
|
13
|
+
*
|
|
14
|
+
* Provides a registry pattern for managing shared shaders, eliminating
|
|
15
|
+
* duplication and providing a single source of truth for shader lifecycle.
|
|
16
|
+
*
|
|
17
|
+
* Key benefits:
|
|
18
|
+
* - Eliminates shader duplication (especially copy shader)
|
|
19
|
+
* - Centralizes vertex shader imports
|
|
20
|
+
* - Provides lazy initialization
|
|
21
|
+
* - Supports future extensibility (shader variants, hot-reloading)
|
|
22
|
+
* - Consistent resource management
|
|
23
|
+
*/
|
|
24
|
+
export declare class ShaderManager {
|
|
25
|
+
private _shaders;
|
|
26
|
+
private _gl;
|
|
27
|
+
constructor(gl: WebGL2RenderingContext);
|
|
28
|
+
/**
|
|
29
|
+
* Get or create a shader with lazy initialization
|
|
30
|
+
* @param key Unique identifier for the shader
|
|
31
|
+
* @param factory Function that creates the shader if it doesn't exist
|
|
32
|
+
* @returns The shader instance
|
|
33
|
+
*/
|
|
34
|
+
$getOrCreateShader(key: string, factory: () => GLShader): GLShader;
|
|
35
|
+
/**
|
|
36
|
+
* Get the shared MRT copy shader used for framebuffer compositing
|
|
37
|
+
* This shader handles copying 5-attachment MRT data with proper transparency
|
|
38
|
+
*/
|
|
39
|
+
$getCopyShader(): GLShader;
|
|
40
|
+
/**
|
|
41
|
+
* Get the main MRT draw shader used for standard geometry rendering
|
|
42
|
+
* This shader outputs to all 5 MRT attachments for textmode rendering
|
|
43
|
+
*/
|
|
44
|
+
$getMainDrawShader(): GLShader;
|
|
45
|
+
/**
|
|
46
|
+
* Get the ASCII conversion shader used for final display output
|
|
47
|
+
* This shader converts MRT data to final ASCII characters
|
|
48
|
+
*/
|
|
49
|
+
$getConversionShader(): GLShader;
|
|
50
|
+
/**
|
|
51
|
+
* Create a custom filter shader using the standard instanced vertex shader
|
|
52
|
+
* These shaders are not cached as they are user-specific
|
|
53
|
+
*/
|
|
54
|
+
$createFilterShader(fragmentSource: string): GLShader;
|
|
55
|
+
/**
|
|
56
|
+
* Create a custom shader with arbitrary vertex and fragment sources
|
|
57
|
+
* These shaders are not cached as they are user-specific
|
|
58
|
+
*/
|
|
59
|
+
$createCustomShader(vertexSource: ShaderSource, fragmentSource: ShaderSource): GLShader;
|
|
60
|
+
/**
|
|
61
|
+
* Dispose of all managed shaders and clear the registry
|
|
62
|
+
* This method is idempotent and safe to call multiple times
|
|
63
|
+
*/
|
|
64
|
+
$dispose(): void;
|
|
65
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './Framebuffer';
|
|
2
2
|
export * from './Renderer';
|
|
3
3
|
export * from './Shader';
|
|
4
|
+
export * from './ShaderManager';
|
|
4
5
|
export * from './StateCache';
|
|
5
6
|
export { GeometryType } from './types/GeometryTypes';
|
|
6
7
|
export type { IGeometry as IInstancedGeometry, UnitGeometryData, RectangleParams, LineParams, EllipseParams, ArcParams, TriangleParams, BezierCurveParams, GeometryParams } from './types/GeometryTypes';
|
|
@@ -19,20 +19,20 @@ export declare enum GeometryType {
|
|
|
19
19
|
*/
|
|
20
20
|
export interface UnitGeometryData {
|
|
21
21
|
/** Vertex data as Float32Array (position + texCoord interleaved) */
|
|
22
|
-
|
|
22
|
+
_vertices: Float32Array;
|
|
23
23
|
/** Number of vertices in the geometry */
|
|
24
|
-
|
|
24
|
+
_vertexCount: number;
|
|
25
25
|
/** WebGL primitive type (gl.TRIANGLES, gl.LINES, etc.) */
|
|
26
|
-
|
|
26
|
+
_primitiveType: number;
|
|
27
27
|
/** Stride in bytes between vertices */
|
|
28
|
-
|
|
28
|
+
_stride: number;
|
|
29
29
|
/** Attribute configuration for position and texCoord */
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
_attributes: {
|
|
31
|
+
_position: {
|
|
32
32
|
size: number;
|
|
33
33
|
offset: number;
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
_texCoord: {
|
|
36
36
|
size: number;
|
|
37
37
|
offset: number;
|
|
38
38
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for shader data with minification support
|
|
3
|
+
*/
|
|
4
|
+
export interface ShaderData {
|
|
5
|
+
/** The shader source code (minified in production, original in development) */
|
|
6
|
+
sourceCode: string;
|
|
7
|
+
/** Original unminified source code (available in development builds) */
|
|
8
|
+
originalCode?: string;
|
|
9
|
+
/** Mapping of original uniform names to minified names and types */
|
|
10
|
+
uniforms: Record<string, {
|
|
11
|
+
/** Minified uniform name used in the shader */
|
|
12
|
+
variableName: string;
|
|
13
|
+
/** GLSL type of the uniform (vec2, sampler2D, etc.) */
|
|
14
|
+
variableType: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** Mapping of const variables (if any) */
|
|
17
|
+
consts: Record<string, {
|
|
18
|
+
/** Substitution value for the const */
|
|
19
|
+
variableName: string;
|
|
20
|
+
/** GLSL type of the const */
|
|
21
|
+
variableType: string;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Union type for shader imports - either ShaderData or plain string (for backward compatibility)
|
|
26
|
+
*/
|
|
27
|
+
export type ShaderSource = ShaderData | string;
|
|
28
|
+
/**
|
|
29
|
+
* Helper to normalize shader source to ShaderData format
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeShaderData(source: ShaderSource): ShaderData;
|
|
32
|
+
/**
|
|
33
|
+
* Extract just the source code from ShaderSource
|
|
34
|
+
*/
|
|
35
|
+
export declare function getShaderCode(source: ShaderSource): string;
|
|
@@ -3,8 +3,8 @@ import { TextmodeFont } from './font';
|
|
|
3
3
|
import { TextmodeGrid } from './Grid';
|
|
4
4
|
import { TextmodeCanvas } from './Canvas';
|
|
5
5
|
import { AnimationController } from './AnimationController';
|
|
6
|
-
import { MouseManager } from './
|
|
7
|
-
import { KeyboardManager } from './
|
|
6
|
+
import { MouseManager } from './managers';
|
|
7
|
+
import { KeyboardManager } from './managers';
|
|
8
8
|
import { type TextmodifierContext } from './mixins';
|
|
9
9
|
import type { RenderingCapabilities } from './mixins/RenderingMixin';
|
|
10
10
|
import type { ExportCapabilities } from './mixins/ExportMixin';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { KeyboardManager } from '../managers/KeyboardManager';
|
|
2
|
+
export type { KeyboardEventData, KeyboardEventHandler, KeyState } from '../managers/KeyboardManager';
|
|
3
|
+
export { MouseManager } from '../managers/MouseManager';
|
|
4
|
+
export type { MousePosition, MouseEventData, MouseEventHandler } from '../managers/MouseManager';
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Mixin } from './TextmodifierMixin';
|
|
2
2
|
import type { GLShader } from '../../rendering/webgl/Shader';
|
|
3
|
+
import type { GLFramebuffer } from '../../rendering';
|
|
4
|
+
export interface UserFramebufferOptions {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
3
8
|
/**
|
|
4
9
|
* Supported uniform value types for shader parameters
|
|
5
10
|
*/
|
|
@@ -39,6 +44,86 @@ export interface RenderingCapabilities {
|
|
|
39
44
|
* ```
|
|
40
45
|
*/
|
|
41
46
|
shader(shader: GLShader): void;
|
|
47
|
+
/**
|
|
48
|
+
* Create a new framebuffer for offscreen rendering.
|
|
49
|
+
*
|
|
50
|
+
* The framebuffer uses the same 5-attachment MRT structure as the main
|
|
51
|
+
* rendering pipeline, allowing all standard drawing operations to work
|
|
52
|
+
* seamlessly when rendering to the framebuffer.
|
|
53
|
+
*
|
|
54
|
+
* @param options Configuration options for the framebuffer
|
|
55
|
+
* @returns A new UserFramebuffer instance
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```javascript
|
|
59
|
+
* const t = textmode.create({
|
|
60
|
+
* width: 800,
|
|
61
|
+
* height: 600,
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* // Create a framebuffer with 50x30 grid cells
|
|
65
|
+
* const fb = t.createFramebuffer({
|
|
66
|
+
* width: 50,
|
|
67
|
+
* height: 30
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* t.draw(() => {
|
|
71
|
+
* // Render to framebuffer
|
|
72
|
+
* fb.begin();
|
|
73
|
+
* t.background(255, 0, 0);
|
|
74
|
+
* t.charColor(255);
|
|
75
|
+
* t.rect(10, 10, 20, 10);
|
|
76
|
+
* fb.end();
|
|
77
|
+
*
|
|
78
|
+
* // Render framebuffer to main canvas
|
|
79
|
+
* t.background(0);
|
|
80
|
+
* t.image(fb, 0, 0);
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
createFramebuffer(options: UserFramebufferOptions): GLFramebuffer;
|
|
85
|
+
/**
|
|
86
|
+
* Render a framebuffer to the current render target.
|
|
87
|
+
*
|
|
88
|
+
* This method takes the 5 MRT attachments from the source framebuffer
|
|
89
|
+
* and renders them as a textmode rectangle at the specified position.
|
|
90
|
+
* The framebuffer content will be processed through the same rendering
|
|
91
|
+
* pipeline as normal drawing operations.
|
|
92
|
+
*
|
|
93
|
+
* @param framebuffer The framebuffer to render
|
|
94
|
+
* @param x X position on the grid where to place the framebuffer content
|
|
95
|
+
* @param y Y position on the grid where to place the framebuffer content
|
|
96
|
+
* @param width Optional width to scale the framebuffer content (defaults to framebuffer width)
|
|
97
|
+
* @param height Optional height to scale the framebuffer content (defaults to framebuffer height)
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```javascript
|
|
101
|
+
* const t = textmode.create({
|
|
102
|
+
* width: 800,
|
|
103
|
+
* height: 600,
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* const fb = t.createFramebuffer({width: 30, height: 20});
|
|
107
|
+
*
|
|
108
|
+
* t.draw(() => {
|
|
109
|
+
* // Draw something to the framebuffer
|
|
110
|
+
* fb.begin();
|
|
111
|
+
* t.charColor(255, 0, 0);
|
|
112
|
+
* t.rect(5, 5, 20, 10);
|
|
113
|
+
* fb.end();
|
|
114
|
+
*
|
|
115
|
+
* // Clear main canvas and render framebuffer content
|
|
116
|
+
* t.background(0);
|
|
117
|
+
*
|
|
118
|
+
* // Render at original size
|
|
119
|
+
* t.image(fb, 10, 10);
|
|
120
|
+
*
|
|
121
|
+
* // Render scaled version
|
|
122
|
+
* t.image(fb, 50, 10, 60, 40);
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
image(framebuffer: GLFramebuffer, x: number, y: number, width?: number, height?: number): void;
|
|
42
127
|
/**
|
|
43
128
|
* Set a uniform value for the current custom shader.
|
|
44
129
|
* @param name The name of the uniform variable
|
|
@@ -7,8 +7,8 @@ import type { TextmodeCanvas } from '../Canvas';
|
|
|
7
7
|
import type { TextmodeGrid } from '../Grid';
|
|
8
8
|
import type { AnimationController } from '../AnimationController';
|
|
9
9
|
import type { GLFramebuffer, Shader } from '../../rendering';
|
|
10
|
-
import type { MouseManager } from '../
|
|
11
|
-
import type { KeyboardManager } from '../
|
|
10
|
+
import type { MouseManager } from '../managers';
|
|
11
|
+
import type { KeyboardManager } from '../managers';
|
|
12
12
|
/**
|
|
13
13
|
* Constructor type for mixin pattern
|
|
14
14
|
*/
|
|
@@ -5,5 +5,5 @@ export { FontMixin, type FontCapabilities } from './FontMixin';
|
|
|
5
5
|
export { AnimationMixin, type AnimationCapabilities } from './AnimationMixin';
|
|
6
6
|
export { MouseMixin, type MouseCapabilities } from './MouseMixin';
|
|
7
7
|
export { KeyboardMixin, type KeyboardCapabilities } from './KeyboardMixin';
|
|
8
|
-
export type { MousePosition, MouseEventData, MouseEventHandler } from '../
|
|
9
|
-
export type { KeyboardEventData, KeyboardEventHandler, KeyState } from '../
|
|
8
|
+
export type { MousePosition, MouseEventData, MouseEventHandler } from '../managers';
|
|
9
|
+
export type { KeyboardEventData, KeyboardEventHandler, KeyState } from '../managers';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textmode.js",
|
|
3
|
-
"version": "0.2.1-beta.
|
|
3
|
+
"version": "0.2.1-beta.2",
|
|
4
4
|
"description": "textmode.js is a lightweight creative coding library for creating real-time ASCII art on the web.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"test:coverage": "vitest --coverage"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
+
"@mapwhit/glsl-minify": "^1.0.0",
|
|
35
36
|
"@rollup/plugin-terser": "^0.4.4",
|
|
36
37
|
"@types/jsdom": "^21.1.7",
|
|
37
38
|
"@types/node": "^24.0.13",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"tslib": "^2.8.1",
|
|
42
43
|
"typedoc": "^0.28.7",
|
|
43
44
|
"typedoc-plugin-markdown": "^4.7.0",
|
|
44
|
-
"typescript": "^5.
|
|
45
|
+
"typescript": "^5.9.2",
|
|
45
46
|
"vite": "^6.3.4",
|
|
46
47
|
"vite-plugin-glsl": "^1.5.1",
|
|
47
48
|
"vitest": "^3.1.2"
|
|
File without changes
|
|
File without changes
|