textmode.js 0.2.1-beta.2 → 0.2.1-beta.3
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 +282 -287
- package/dist/textmode.esm.min.js +373 -378
- package/dist/textmode.umd.js +5 -5
- package/dist/textmode.umd.min.js +6 -6
- package/dist/types/index.d.ts +2 -2
- package/dist/types/rendering/webgl/Framebuffer.d.ts +23 -12
- package/dist/types/rendering/webgl/Shader.d.ts +1 -1
- package/dist/types/textmode/mixins/AnimationMixin.d.ts +0 -4
- package/dist/types/textmode/mixins/KeyboardMixin.d.ts +74 -18
- package/dist/types/textmode/mixins/MouseMixin.d.ts +100 -7
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +51 -44
- package/package.json +2 -2
|
@@ -4,18 +4,111 @@ import type { MousePosition, MouseEventHandler } from '../managers';
|
|
|
4
4
|
* Capabilities provided by the MouseMixin
|
|
5
5
|
*/
|
|
6
6
|
export interface MouseCapabilities {
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Set a callback function that will be called when the mouse is clicked.
|
|
9
|
+
*
|
|
10
|
+
* @param callback The function to call when the mouse is clicked
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```javascript
|
|
14
|
+
* const t = textmode.create({ width: 800, height: 600 });
|
|
15
|
+
*
|
|
16
|
+
* t.mouseClicked((data) => {
|
|
17
|
+
* console.log(`Clicked at grid position: ${data.position.x}, ${data.position.y}`);
|
|
18
|
+
* console.log(`Button: ${data.button}`); // 0=left, 1=middle, 2=right
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
10
22
|
mouseClicked(callback: MouseEventHandler): void;
|
|
11
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Set a callback function that will be called when the mouse is pressed down.
|
|
25
|
+
*
|
|
26
|
+
* @param callback The function to call when the mouse is pressed
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```javascript
|
|
30
|
+
* const t = textmode.create({ width: 800, height: 600 });
|
|
31
|
+
*
|
|
32
|
+
* t.mousePressed((data) => {
|
|
33
|
+
* console.log(`Mouse pressed at: ${data.position.x}, ${data.position.y}`);
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
12
37
|
mousePressed(callback: MouseEventHandler): void;
|
|
13
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Set a callback function that will be called when the mouse is released.
|
|
40
|
+
*
|
|
41
|
+
* @param callback The function to call when the mouse is released
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```javascript
|
|
45
|
+
* const t = textmode.create({ width: 800, height: 600 });
|
|
46
|
+
*
|
|
47
|
+
* t.mouseReleased((data) => {
|
|
48
|
+
* console.log(`Mouse released at: ${data.position.x}, ${data.position.y}`);
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
14
52
|
mouseReleased(callback: MouseEventHandler): void;
|
|
15
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Set a callback function that will be called when the mouse moves.
|
|
55
|
+
*
|
|
56
|
+
* @param callback The function to call when the mouse moves
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```javascript
|
|
60
|
+
* const t = textmode.create({ width: 800, height: 600 });
|
|
61
|
+
*
|
|
62
|
+
* t.mouseMoved((data) => {
|
|
63
|
+
* if (data.position.x !== -1 && data.position.y !== -1) {
|
|
64
|
+
* console.log(`Mouse moved to: ${data.position.x}, ${data.position.y}`);
|
|
65
|
+
* console.log(`Previous position: ${data.previousPosition.x}, ${data.previousPosition.y}`);
|
|
66
|
+
* }
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
16
70
|
mouseMoved(callback: MouseEventHandler): void;
|
|
17
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Set a callback function that will be called when the mouse wheel is scrolled.
|
|
73
|
+
*
|
|
74
|
+
* @param callback The function to call when the mouse wheel is scrolled
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```javascript
|
|
78
|
+
* const t = textmode.create({ width: 800, height: 600 });
|
|
79
|
+
*
|
|
80
|
+
* t.mouseScrolled((data) => {
|
|
81
|
+
* console.log(`Mouse scrolled at: ${data.position.x}, ${data.position.y}`);
|
|
82
|
+
* console.log(`Scroll delta: ${data.delta?.x}, ${data.delta?.y}`);
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
18
86
|
mouseScrolled(callback: MouseEventHandler): void;
|
|
87
|
+
/**
|
|
88
|
+
* Get the current mouse position in grid coordinates.
|
|
89
|
+
*
|
|
90
|
+
* Returns the mouse position as grid cell coordinates *(column, row)*.
|
|
91
|
+
*
|
|
92
|
+
* If the mouse is outside the grid or the instance is not ready,
|
|
93
|
+
* it returns `{ x: -1, y: -1 }`.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```javascript
|
|
97
|
+
* const t = textmode.create({ width: 800, height: 600 });
|
|
98
|
+
*
|
|
99
|
+
* t.draw(() => {
|
|
100
|
+
* const mousePos = t.mouse;
|
|
101
|
+
*
|
|
102
|
+
* if (mousePos.x !== -1 && mousePos.y !== -1) {
|
|
103
|
+
* // Mouse is over the grid
|
|
104
|
+
* t.char('*');
|
|
105
|
+
* t.charColor(255, 0, 0);
|
|
106
|
+
* t.point(mousePos.x, mousePos.y);
|
|
107
|
+
* }
|
|
108
|
+
* });
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
get mouse(): MousePosition;
|
|
19
112
|
}
|
|
20
113
|
/**
|
|
21
114
|
* Mixin that adds mouse tracking capabilities to Textmodifier.
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { Mixin } from './TextmodifierMixin';
|
|
2
2
|
import type { GLShader } from '../../rendering/webgl/Shader';
|
|
3
3
|
import type { GLFramebuffer } from '../../rendering';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Options for creating a framebuffer.
|
|
6
|
+
*/
|
|
7
|
+
export type TextmodeFramebufferOptions = {
|
|
8
|
+
/** Width of the framebuffer in grid cells */
|
|
5
9
|
width: number;
|
|
10
|
+
/** Height of the framebuffer in grid cells */
|
|
6
11
|
height: number;
|
|
7
|
-
}
|
|
12
|
+
};
|
|
8
13
|
/**
|
|
9
14
|
* Supported uniform value types for shader parameters
|
|
10
15
|
*/
|
|
@@ -45,56 +50,56 @@ export interface RenderingCapabilities {
|
|
|
45
50
|
*/
|
|
46
51
|
shader(shader: GLShader): void;
|
|
47
52
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
createFramebuffer(options:
|
|
53
|
+
* Create a new framebuffer for offscreen rendering.
|
|
54
|
+
*
|
|
55
|
+
* The framebuffer uses the same 5-attachment MRT structure as the main
|
|
56
|
+
* rendering pipeline, allowing all standard drawing operations to work
|
|
57
|
+
* seamlessly when rendering to the framebuffer.
|
|
58
|
+
*
|
|
59
|
+
* @param options Configuration options for the framebuffer.
|
|
60
|
+
* @returns A new Framebuffer instance.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```javascript
|
|
64
|
+
* const t = textmode.create({
|
|
65
|
+
* width: 800,
|
|
66
|
+
* height: 600,
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // Create a framebuffer with 50x30 grid cells
|
|
70
|
+
* const fb = t.createFramebuffer({
|
|
71
|
+
* width: 50,
|
|
72
|
+
* height: 30
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* t.draw(() => {
|
|
76
|
+
* // Render to framebuffer
|
|
77
|
+
* fb.begin();
|
|
78
|
+
* t.background(255, 0, 0);
|
|
79
|
+
* t.charColor(255);
|
|
80
|
+
* t.rect(10, 10, 20, 10);
|
|
81
|
+
* fb.end();
|
|
82
|
+
*
|
|
83
|
+
* // Render framebuffer to main canvas
|
|
84
|
+
* t.background(0);
|
|
85
|
+
* t.image(fb, 0, 0);
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
createFramebuffer(options: TextmodeFramebufferOptions): GLFramebuffer;
|
|
85
90
|
/**
|
|
86
91
|
* Render a framebuffer to the current render target.
|
|
87
92
|
*
|
|
88
93
|
* This method takes the 5 MRT attachments from the source framebuffer
|
|
89
|
-
* and renders them
|
|
94
|
+
* and renders them at the specified position.
|
|
90
95
|
* The framebuffer content will be processed through the same rendering
|
|
91
96
|
* pipeline as normal drawing operations.
|
|
92
97
|
*
|
|
93
98
|
* @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)
|
|
99
|
+
* @param x X position on the grid where to place the framebuffer content *(top-left corner)*
|
|
100
|
+
* @param y Y position on the grid where to place the framebuffer content *(top-left corner)*
|
|
101
|
+
* @param width Optional width to scale the framebuffer content *(defaults to framebuffer width)*
|
|
102
|
+
* @param height Optional height to scale the framebuffer content *(defaults to framebuffer height)*
|
|
98
103
|
*
|
|
99
104
|
* @example
|
|
100
105
|
* ```javascript
|
|
@@ -403,6 +408,8 @@ export interface RenderingCapabilities {
|
|
|
403
408
|
*
|
|
404
409
|
* t.draw(() => {
|
|
405
410
|
* t.background(0);
|
|
411
|
+
*
|
|
412
|
+
* t.char('*');
|
|
406
413
|
* t.point(10, 10);
|
|
407
414
|
* });
|
|
408
415
|
* ```
|
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.3",
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"jsdom": "^26.1.0",
|
|
41
41
|
"terser": "^5.43.1",
|
|
42
42
|
"tslib": "^2.8.1",
|
|
43
|
-
"typedoc": "^0.28.
|
|
43
|
+
"typedoc": "^0.28.13",
|
|
44
44
|
"typedoc-plugin-markdown": "^4.7.0",
|
|
45
45
|
"typescript": "^5.9.2",
|
|
46
46
|
"vite": "^6.3.4",
|