textmode.js 0.2.0-beta.5 → 0.2.1-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 +114 -63
- package/dist/textmode.esm.js +1141 -903
- package/dist/textmode.esm.min.js +1387 -1149
- package/dist/textmode.umd.js +20 -20
- package/dist/textmode.umd.min.js +18 -18
- package/dist/types/Textmode.d.ts +2 -6
- package/dist/types/textmode/Textmodifier.d.ts +16 -8
- package/dist/types/textmode/keyboard/KeyboardManager.d.ts +123 -0
- package/dist/types/textmode/keyboard/index.d.ts +2 -0
- package/dist/types/textmode/mixins/AnimationMixin.d.ts +10 -6
- package/dist/types/textmode/mixins/ExportMixin.d.ts +5 -5
- package/dist/types/textmode/mixins/FontMixin.d.ts +1 -1
- package/dist/types/textmode/mixins/KeyboardMixin.d.ts +39 -0
- package/dist/types/textmode/mixins/MouseMixin.d.ts +27 -0
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +70 -39
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +6 -0
- package/dist/types/textmode/mixins/index.d.ts +4 -0
- package/dist/types/textmode/mouse/MouseManager.d.ts +130 -0
- package/dist/types/textmode/mouse/index.d.ts +2 -0
- package/package.json +8 -4
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key event data passed to event handlers
|
|
3
|
+
*/
|
|
4
|
+
export interface KeyboardEventData {
|
|
5
|
+
/** The key that was pressed/released (e.g., 'a', 'Enter', 'ArrowLeft') */
|
|
6
|
+
key: string;
|
|
7
|
+
/** The key code (for compatibility) */
|
|
8
|
+
keyCode: number;
|
|
9
|
+
/** Whether Ctrl key is held down */
|
|
10
|
+
ctrlKey: boolean;
|
|
11
|
+
/** Whether Shift key is held down */
|
|
12
|
+
shiftKey: boolean;
|
|
13
|
+
/** Whether Alt key is held down */
|
|
14
|
+
altKey: boolean;
|
|
15
|
+
/** Whether Meta key (Windows/Cmd) is held down */
|
|
16
|
+
metaKey: boolean;
|
|
17
|
+
/** Whether this key is currently being held down (for keyPressed) or was released (for keyReleased) */
|
|
18
|
+
isPressed: boolean;
|
|
19
|
+
/** Original DOM keyboard event */
|
|
20
|
+
originalEvent: KeyboardEvent;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Keyboard event handler function type
|
|
24
|
+
*/
|
|
25
|
+
export type KeyboardEventHandler = (data: KeyboardEventData) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Key state information
|
|
28
|
+
*/
|
|
29
|
+
export interface KeyState {
|
|
30
|
+
/** Whether the key is currently pressed */
|
|
31
|
+
isPressed: boolean;
|
|
32
|
+
/** Timestamp when the key was last pressed */
|
|
33
|
+
lastPressTime: number;
|
|
34
|
+
/** Timestamp when the key was last released */
|
|
35
|
+
lastReleaseTime: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Manages all keyboard interaction for a Textmodifier instance.
|
|
39
|
+
* Handles event listeners, key state tracking, and event dispatching.
|
|
40
|
+
*
|
|
41
|
+
* Provides p5.js-like keyboard functionality including:
|
|
42
|
+
* - keyPressed() and keyReleased() callbacks
|
|
43
|
+
* - Current key state tracking
|
|
44
|
+
* - Special key handling (arrows, function keys, etc.)
|
|
45
|
+
* - Modifier key support (Ctrl, Shift, Alt, Meta)
|
|
46
|
+
*/
|
|
47
|
+
export declare class KeyboardManager {
|
|
48
|
+
private _keyStates;
|
|
49
|
+
private _lastKeyPressed;
|
|
50
|
+
private _lastKeyReleased;
|
|
51
|
+
private _keyDownListener;
|
|
52
|
+
private _keyUpListener;
|
|
53
|
+
private _areListenersSetup;
|
|
54
|
+
private _keyPressedCallback?;
|
|
55
|
+
private _keyReleasedCallback?;
|
|
56
|
+
private readonly _specialKeyMap;
|
|
57
|
+
constructor();
|
|
58
|
+
/**
|
|
59
|
+
* Setup keyboard event listeners.
|
|
60
|
+
*/
|
|
61
|
+
$setupListeners(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Remove keyboard event listeners.
|
|
64
|
+
*/
|
|
65
|
+
$cleanupListeners(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Set a callback function that will be called when a key is pressed down.
|
|
68
|
+
* @param callback The function to call when a key is pressed
|
|
69
|
+
*/
|
|
70
|
+
$setPressedCallback(callback: KeyboardEventHandler): void;
|
|
71
|
+
/**
|
|
72
|
+
* Set a callback function that will be called when a key is released.
|
|
73
|
+
* @param callback The function to call when a key is released
|
|
74
|
+
*/
|
|
75
|
+
$setReleasedCallback(callback: KeyboardEventHandler): void;
|
|
76
|
+
/**
|
|
77
|
+
* Check if a specific key is currently being pressed.
|
|
78
|
+
* @param key The key to check (e.g., 'a', 'Enter', 'ArrowLeft', or special constants like 'SPACE')
|
|
79
|
+
* @returns true if the key is currently pressed, false otherwise
|
|
80
|
+
*/
|
|
81
|
+
$isKeyPressed(key: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Get the last key that was pressed.
|
|
84
|
+
* @returns The key string of the last pressed key, or null if no key has been pressed
|
|
85
|
+
*/
|
|
86
|
+
$getLastKeyPressed(): string | null;
|
|
87
|
+
/**
|
|
88
|
+
* Get the last key that was released.
|
|
89
|
+
* @returns The key string of the last released key, or null if no key has been released
|
|
90
|
+
*/
|
|
91
|
+
$getLastKeyReleased(): string | null;
|
|
92
|
+
/**
|
|
93
|
+
* Get all currently pressed keys.
|
|
94
|
+
* @returns Array of key strings that are currently pressed
|
|
95
|
+
*/
|
|
96
|
+
$getPressedKeys(): string[];
|
|
97
|
+
/**
|
|
98
|
+
* Check if any modifier key is currently pressed.
|
|
99
|
+
* @returns Object with boolean properties for each modifier key
|
|
100
|
+
*/
|
|
101
|
+
$getModifierState(): {
|
|
102
|
+
ctrl: boolean;
|
|
103
|
+
shift: boolean;
|
|
104
|
+
alt: boolean;
|
|
105
|
+
meta: boolean;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Clear all key states (useful for focus loss scenarios).
|
|
109
|
+
*/
|
|
110
|
+
$clearKeyStates(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Handle key down events
|
|
113
|
+
*/
|
|
114
|
+
private _handleKeyDown;
|
|
115
|
+
/**
|
|
116
|
+
* Handle key up events
|
|
117
|
+
*/
|
|
118
|
+
private _handleKeyUp;
|
|
119
|
+
/**
|
|
120
|
+
* Normalize key names for consistency (map to p5.js-like constants where applicable)
|
|
121
|
+
*/
|
|
122
|
+
private _normalizeKey;
|
|
123
|
+
}
|
|
@@ -14,7 +14,7 @@ export interface AnimationCapabilities {
|
|
|
14
14
|
* @example
|
|
15
15
|
* ```javascript
|
|
16
16
|
* // Create a Textmodifier instance
|
|
17
|
-
* const textmodifier =
|
|
17
|
+
* const textmodifier = textmode.create();
|
|
18
18
|
*
|
|
19
19
|
* // Set the maximum frame rate to 30 FPS
|
|
20
20
|
* textmodifier.frameRate(30);
|
|
@@ -31,7 +31,7 @@ export interface AnimationCapabilities {
|
|
|
31
31
|
* @example
|
|
32
32
|
* ```javascript
|
|
33
33
|
* // Create a textmodifier instance in auto mode
|
|
34
|
-
* const textmodifier =
|
|
34
|
+
* const textmodifier = textmode.create();
|
|
35
35
|
*
|
|
36
36
|
* // The render loop is running by default
|
|
37
37
|
* console.log(textmodifier.isLooping()); // true
|
|
@@ -52,7 +52,7 @@ export interface AnimationCapabilities {
|
|
|
52
52
|
* @example
|
|
53
53
|
* ```javascript
|
|
54
54
|
* // Create a textmodifier instance
|
|
55
|
-
* const textmodifier =
|
|
55
|
+
* const textmodifier = textmode.create();
|
|
56
56
|
*
|
|
57
57
|
* // Stop the loop
|
|
58
58
|
* textmodifier.noLoop();
|
|
@@ -80,11 +80,15 @@ export interface AnimationCapabilities {
|
|
|
80
80
|
* @example
|
|
81
81
|
* ```javascript
|
|
82
82
|
* // Create a textmodifier instance
|
|
83
|
-
* const textmodifier =
|
|
83
|
+
* const textmodifier = textmode.create();
|
|
84
84
|
*
|
|
85
85
|
* // Set up drawing
|
|
86
86
|
* textmodifier.draw(() => {
|
|
87
|
-
*
|
|
87
|
+
* textmodifier.background(0);
|
|
88
|
+
*
|
|
89
|
+
* textmodifier.char("A");
|
|
90
|
+
* textmodifier.charColor(255, 0, 0);
|
|
91
|
+
* textmodifier.rect(10, 10, 50, 50);
|
|
88
92
|
* });
|
|
89
93
|
*
|
|
90
94
|
* textmodifier.noLoop();
|
|
@@ -98,7 +102,7 @@ export interface AnimationCapabilities {
|
|
|
98
102
|
*
|
|
99
103
|
* @example
|
|
100
104
|
* ```javascript
|
|
101
|
-
* const textmodifier =
|
|
105
|
+
* const textmodifier = textmode.create(canvas);
|
|
102
106
|
*
|
|
103
107
|
* // Check loop status in different states
|
|
104
108
|
* console.log(textmodifier.isLooping()); // true (looping)
|
|
@@ -17,7 +17,7 @@ export interface ExportCapabilities {
|
|
|
17
17
|
* const canvas = document.querySelector('canvas#myCanvas');
|
|
18
18
|
*
|
|
19
19
|
* // Create a Textmodifier instance
|
|
20
|
-
* const textmodifier =
|
|
20
|
+
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
21
21
|
*
|
|
22
22
|
* // Render a single frame
|
|
23
23
|
* textmodifier.render();
|
|
@@ -43,7 +43,7 @@ export interface ExportCapabilities {
|
|
|
43
43
|
* const canvas = document.querySelector('canvas#myCanvas');
|
|
44
44
|
*
|
|
45
45
|
* // Create a Textmodifier instance
|
|
46
|
-
* const textmodifier =
|
|
46
|
+
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
47
47
|
*
|
|
48
48
|
* // Render a single frame
|
|
49
49
|
* textmodifier.render();
|
|
@@ -67,7 +67,7 @@ export interface ExportCapabilities {
|
|
|
67
67
|
* const canvas = document.querySelector('canvas#myCanvas');
|
|
68
68
|
*
|
|
69
69
|
* // Create a Textmodifier instance
|
|
70
|
-
* const textmodifier =
|
|
70
|
+
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
71
71
|
*
|
|
72
72
|
* // Render a single frame
|
|
73
73
|
* textmodifier.render();
|
|
@@ -93,7 +93,7 @@ export interface ExportCapabilities {
|
|
|
93
93
|
* const canvas = document.querySelector('canvas#myCanvas');
|
|
94
94
|
*
|
|
95
95
|
* // Create a Textmodifier instance
|
|
96
|
-
* const textmodifier =
|
|
96
|
+
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
97
97
|
*
|
|
98
98
|
* // Render a single frame
|
|
99
99
|
* textmodifier.render();
|
|
@@ -115,7 +115,7 @@ export interface ExportCapabilities {
|
|
|
115
115
|
* const canvas = document.querySelector('canvas#myCanvas');
|
|
116
116
|
*
|
|
117
117
|
* // Create a Textmodifier instance
|
|
118
|
-
* const textmodifier =
|
|
118
|
+
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
119
119
|
*
|
|
120
120
|
* // Render a single frame
|
|
121
121
|
* textmodifier.render();
|
|
@@ -10,7 +10,7 @@ export interface FontCapabilities {
|
|
|
10
10
|
* @example
|
|
11
11
|
* ```javascript
|
|
12
12
|
* // Create a Textmodifier instance
|
|
13
|
-
* const textmodifier =
|
|
13
|
+
* const textmodifier = textmode.create();
|
|
14
14
|
*
|
|
15
15
|
* // Load a custom font from a URL
|
|
16
16
|
* await textmodifier.loadFont('https://example.com/fonts/myfont.ttf');
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Mixin } from './TextmodifierMixin';
|
|
2
|
+
import type { KeyboardEventHandler } from '../keyboard';
|
|
3
|
+
/**
|
|
4
|
+
* Capabilities provided by the KeyboardMixin
|
|
5
|
+
*/
|
|
6
|
+
export interface KeyboardCapabilities {
|
|
7
|
+
/** Check if a specific key is currently pressed */
|
|
8
|
+
isKeyPressed(key: string): boolean;
|
|
9
|
+
/** Get the last key that was pressed */
|
|
10
|
+
readonly lastKeyPressed: string | null;
|
|
11
|
+
/** Get the last key that was released */
|
|
12
|
+
readonly lastKeyReleased: string | null;
|
|
13
|
+
/** Get all currently pressed keys */
|
|
14
|
+
readonly pressedKeys: string[];
|
|
15
|
+
/** Get current modifier key states */
|
|
16
|
+
readonly modifierState: {
|
|
17
|
+
ctrl: boolean;
|
|
18
|
+
shift: boolean;
|
|
19
|
+
alt: boolean;
|
|
20
|
+
meta: boolean;
|
|
21
|
+
};
|
|
22
|
+
/** Set a callback for when a key is pressed down */
|
|
23
|
+
keyPressed(callback: KeyboardEventHandler): void;
|
|
24
|
+
/** Set a callback for when a key is released */
|
|
25
|
+
keyReleased(callback: KeyboardEventHandler): void;
|
|
26
|
+
/** Clear all key states */
|
|
27
|
+
clearKeyStates(): void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Mixin that adds keyboard interaction capabilities to Textmodifier.
|
|
31
|
+
*
|
|
32
|
+
* This is a thin wrapper around KeyboardManager that provides the public API
|
|
33
|
+
* for keyboard interaction. All the actual implementation is handled by the
|
|
34
|
+
* KeyboardManager instance in the TextmodifierContext.
|
|
35
|
+
*
|
|
36
|
+
* Provides p5.js-like keyboard functionality including key state tracking,
|
|
37
|
+
* event callbacks, and special key handling.
|
|
38
|
+
*/
|
|
39
|
+
export declare const KeyboardMixin: Mixin<KeyboardCapabilities>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Mixin } from './TextmodifierMixin';
|
|
2
|
+
import type { MousePosition, MouseEventHandler } from '../mouse';
|
|
3
|
+
/**
|
|
4
|
+
* Capabilities provided by the MouseMixin
|
|
5
|
+
*/
|
|
6
|
+
export interface MouseCapabilities {
|
|
7
|
+
/** Get the current mouse position in grid coordinates */
|
|
8
|
+
readonly mouse: MousePosition;
|
|
9
|
+
/** Set a callback for when the mouse is clicked */
|
|
10
|
+
mouseClicked(callback: MouseEventHandler): void;
|
|
11
|
+
/** Set a callback for when the mouse is pressed down */
|
|
12
|
+
mousePressed(callback: MouseEventHandler): void;
|
|
13
|
+
/** Set a callback for when the mouse is released */
|
|
14
|
+
mouseReleased(callback: MouseEventHandler): void;
|
|
15
|
+
/** Set a callback for when the mouse moves */
|
|
16
|
+
mouseMoved(callback: MouseEventHandler): void;
|
|
17
|
+
/** Set a callback for when the mouse wheel is scrolled */
|
|
18
|
+
mouseScrolled(callback: MouseEventHandler): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Mixin that adds mouse tracking capabilities to Textmodifier.
|
|
22
|
+
*
|
|
23
|
+
* This is a thin wrapper around MouseManager that provides the public API
|
|
24
|
+
* for mouse interaction. All the actual implementation is handled by the
|
|
25
|
+
* MouseManager instance in the TextmodifierContext.
|
|
26
|
+
*/
|
|
27
|
+
export declare const MouseMixin: Mixin<MouseCapabilities>;
|
|
@@ -11,11 +11,11 @@ export interface RenderingCapabilities {
|
|
|
11
11
|
/**
|
|
12
12
|
* Set a custom shader for subsequent rendering operations.
|
|
13
13
|
* Pass null to return to the default shader.
|
|
14
|
-
* @param shader The custom shader to use
|
|
14
|
+
* @param shader The custom shader to use
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```javascript
|
|
18
|
-
* const t =
|
|
18
|
+
* const t = textmode.create({
|
|
19
19
|
* width: 800,
|
|
20
20
|
* height: 600,
|
|
21
21
|
* })
|
|
@@ -38,7 +38,7 @@ export interface RenderingCapabilities {
|
|
|
38
38
|
* });
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
shader(shader: GLShader
|
|
41
|
+
shader(shader: GLShader): void;
|
|
42
42
|
/**
|
|
43
43
|
* Set a uniform value for the current custom shader.
|
|
44
44
|
* @param name The name of the uniform variable
|
|
@@ -46,7 +46,7 @@ export interface RenderingCapabilities {
|
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* ```javascript
|
|
49
|
-
* const t =
|
|
49
|
+
* const t = textmode.create({
|
|
50
50
|
* width: 800,
|
|
51
51
|
* height: 600,
|
|
52
52
|
* })
|
|
@@ -70,7 +70,7 @@ export interface RenderingCapabilities {
|
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```javascript
|
|
73
|
-
* const t =
|
|
73
|
+
* const t = textmode.create({
|
|
74
74
|
* width: 800,
|
|
75
75
|
* height: 600,
|
|
76
76
|
* })
|
|
@@ -97,11 +97,11 @@ export interface RenderingCapabilities {
|
|
|
97
97
|
* The fragment shader will automatically receive the standard vertex shader inputs
|
|
98
98
|
* and must output to all 5 MRT attachments.
|
|
99
99
|
* @param fragmentSource The fragment shader source code
|
|
100
|
-
* @returns A compiled shader ready for use with shader
|
|
100
|
+
* @returns A compiled shader ready for use with {@link shader}
|
|
101
101
|
*
|
|
102
102
|
* @example
|
|
103
103
|
* ```javascript
|
|
104
|
-
* const t =
|
|
104
|
+
* const t = textmode.create({
|
|
105
105
|
* width: 800,
|
|
106
106
|
* height: 600,
|
|
107
107
|
* })
|
|
@@ -157,7 +157,7 @@ export interface RenderingCapabilities {
|
|
|
157
157
|
*
|
|
158
158
|
* @example
|
|
159
159
|
* ```javascript
|
|
160
|
-
* const t =
|
|
160
|
+
* const t = textmode.create({
|
|
161
161
|
* width: 800,
|
|
162
162
|
* height: 600,
|
|
163
163
|
* })
|
|
@@ -182,7 +182,7 @@ export interface RenderingCapabilities {
|
|
|
182
182
|
*
|
|
183
183
|
* @example
|
|
184
184
|
* ```javascript
|
|
185
|
-
* const t =
|
|
185
|
+
* const t = textmode.create({
|
|
186
186
|
* width: 800,
|
|
187
187
|
* height: 600,
|
|
188
188
|
* })
|
|
@@ -201,7 +201,7 @@ export interface RenderingCapabilities {
|
|
|
201
201
|
*
|
|
202
202
|
* @example
|
|
203
203
|
* ```javascript
|
|
204
|
-
* const t =
|
|
204
|
+
* const t = textmode.create({
|
|
205
205
|
* width: 800,
|
|
206
206
|
* height: 600,
|
|
207
207
|
* })
|
|
@@ -220,7 +220,7 @@ export interface RenderingCapabilities {
|
|
|
220
220
|
*
|
|
221
221
|
* @example
|
|
222
222
|
* ```javascript
|
|
223
|
-
* const t =
|
|
223
|
+
* const t = textmode.create({
|
|
224
224
|
* width: 800,
|
|
225
225
|
* height: 600,
|
|
226
226
|
* })
|
|
@@ -239,7 +239,7 @@ export interface RenderingCapabilities {
|
|
|
239
239
|
*
|
|
240
240
|
* @example
|
|
241
241
|
* ```javascript
|
|
242
|
-
* const t =
|
|
242
|
+
* const t = textmode.create({
|
|
243
243
|
* width: 800,
|
|
244
244
|
* height: 600,
|
|
245
245
|
* })
|
|
@@ -248,7 +248,8 @@ export interface RenderingCapabilities {
|
|
|
248
248
|
* t.background(0);
|
|
249
249
|
*
|
|
250
250
|
* t.push(); // Save current state
|
|
251
|
-
* //
|
|
251
|
+
* t.charColor(255, 0, 0); // Red characters
|
|
252
|
+
* t.rect(10, 10, 5, 5);
|
|
252
253
|
* t.pop(); // Restore previous state
|
|
253
254
|
* });
|
|
254
255
|
* ```
|
|
@@ -260,7 +261,7 @@ export interface RenderingCapabilities {
|
|
|
260
261
|
*
|
|
261
262
|
* @example
|
|
262
263
|
* ```javascript
|
|
263
|
-
* const t =
|
|
264
|
+
* const t = textmode.create({
|
|
264
265
|
* width: 800,
|
|
265
266
|
* height: 600,
|
|
266
267
|
* })
|
|
@@ -269,7 +270,9 @@ export interface RenderingCapabilities {
|
|
|
269
270
|
* t.background(0);
|
|
270
271
|
*
|
|
271
272
|
* t.push(); // Save current state
|
|
272
|
-
* //
|
|
273
|
+
* t.charColor(0, 255, 0); // Green characters
|
|
274
|
+
* t.char('█');
|
|
275
|
+
* t.rect(5, 5, 3, 3);
|
|
273
276
|
* t.pop(); // Restore previous state
|
|
274
277
|
* });
|
|
275
278
|
* ```
|
|
@@ -277,14 +280,14 @@ export interface RenderingCapabilities {
|
|
|
277
280
|
pop(): void;
|
|
278
281
|
/**
|
|
279
282
|
* Draw a rectangle with the current settings.
|
|
280
|
-
* @param x X-coordinate of the rectangle
|
|
281
|
-
* @param y Y-coordinate of the rectangle
|
|
283
|
+
* @param x X-coordinate of the rectangle *(top-left corner)*
|
|
284
|
+
* @param y Y-coordinate of the rectangle *(top-left corner)*
|
|
282
285
|
* @param width Width of the rectangle
|
|
283
286
|
* @param height Height of the rectangle
|
|
284
287
|
*
|
|
285
288
|
* @example
|
|
286
289
|
* ```javascript
|
|
287
|
-
* const t =
|
|
290
|
+
* const t = textmode.create({
|
|
288
291
|
* width: 800,
|
|
289
292
|
* height: 600,
|
|
290
293
|
* })
|
|
@@ -293,11 +296,33 @@ export interface RenderingCapabilities {
|
|
|
293
296
|
* // Set the background color to black
|
|
294
297
|
* t.background(0);
|
|
295
298
|
*
|
|
296
|
-
* //
|
|
299
|
+
* // Draw a filled rectangle with default character
|
|
300
|
+
* t.char('█');
|
|
301
|
+
* t.charColor(255, 255, 255); // White
|
|
302
|
+
* t.rect(10, 10, 15, 8);
|
|
297
303
|
* });
|
|
298
304
|
* ```
|
|
299
305
|
*/
|
|
300
306
|
rect(x: number, y: number, width?: number, height?: number): void;
|
|
307
|
+
/**
|
|
308
|
+
* Draw a single point at (x, y) with the current settings.
|
|
309
|
+
* @param x X-coordinate of the point
|
|
310
|
+
* @param y Y-coordinate of the point
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```javascript
|
|
314
|
+
* const t = textmode.create({
|
|
315
|
+
* width: 800,
|
|
316
|
+
* height: 600,
|
|
317
|
+
* })
|
|
318
|
+
*
|
|
319
|
+
* t.draw(() => {
|
|
320
|
+
* t.background(0);
|
|
321
|
+
* t.point(10, 10);
|
|
322
|
+
* });
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
point(x: number, y: number): void;
|
|
301
326
|
/**
|
|
302
327
|
* Draw a line from point (x1, y1) to point (x2, y2) with the settings.
|
|
303
328
|
* @param x1 X-coordinate of the line start point
|
|
@@ -307,7 +332,7 @@ export interface RenderingCapabilities {
|
|
|
307
332
|
*
|
|
308
333
|
* @example
|
|
309
334
|
* ```javascript
|
|
310
|
-
* const t =
|
|
335
|
+
* const t = textmode.create({
|
|
311
336
|
* width: 800,
|
|
312
337
|
* height: 600,
|
|
313
338
|
* })
|
|
@@ -316,7 +341,11 @@ export interface RenderingCapabilities {
|
|
|
316
341
|
* // Set the background color to black
|
|
317
342
|
* t.background(0);
|
|
318
343
|
*
|
|
319
|
-
* //
|
|
344
|
+
* // Draw a diagonal line
|
|
345
|
+
* t.char('-');
|
|
346
|
+
* t.charColor(0, 255, 255); // Cyan
|
|
347
|
+
* t.lineWeight(1);
|
|
348
|
+
* t.line(5, 5, 25, 15);
|
|
320
349
|
* });
|
|
321
350
|
* ```
|
|
322
351
|
*/
|
|
@@ -330,7 +359,7 @@ export interface RenderingCapabilities {
|
|
|
330
359
|
*
|
|
331
360
|
* @example
|
|
332
361
|
* ```javascript
|
|
333
|
-
* const t =
|
|
362
|
+
* const t = textmode.create({
|
|
334
363
|
* width: 800,
|
|
335
364
|
* height: 600,
|
|
336
365
|
* })
|
|
@@ -347,7 +376,7 @@ export interface RenderingCapabilities {
|
|
|
347
376
|
*
|
|
348
377
|
* @example
|
|
349
378
|
* ```javascript
|
|
350
|
-
* const t =
|
|
379
|
+
* const t = textmode.create({
|
|
351
380
|
* width: 800,
|
|
352
381
|
* height: 600,
|
|
353
382
|
* })
|
|
@@ -365,7 +394,7 @@ export interface RenderingCapabilities {
|
|
|
365
394
|
*
|
|
366
395
|
* @example
|
|
367
396
|
* ```javascript
|
|
368
|
-
* const t =
|
|
397
|
+
* const t = textmode.create({
|
|
369
398
|
* width: 800,
|
|
370
399
|
* height: 600,
|
|
371
400
|
* })
|
|
@@ -392,7 +421,7 @@ export interface RenderingCapabilities {
|
|
|
392
421
|
*
|
|
393
422
|
* @example
|
|
394
423
|
* ```javascript
|
|
395
|
-
* const t =
|
|
424
|
+
* const t = textmode.create({
|
|
396
425
|
* width: 800,
|
|
397
426
|
* height: 600,
|
|
398
427
|
* })
|
|
@@ -400,7 +429,11 @@ export interface RenderingCapabilities {
|
|
|
400
429
|
* t.draw(() => {
|
|
401
430
|
* t.background(0);
|
|
402
431
|
*
|
|
403
|
-
* //
|
|
432
|
+
* // Draw a smooth S-curve
|
|
433
|
+
* t.char('*');
|
|
434
|
+
* t.charColor(255, 100, 255); // Magenta
|
|
435
|
+
* t.lineWeight(2);
|
|
436
|
+
* t.bezierCurve(5, 20, 15, 5, 25, 35, 35, 20);
|
|
404
437
|
* });
|
|
405
438
|
* ```
|
|
406
439
|
*/
|
|
@@ -411,7 +444,7 @@ export interface RenderingCapabilities {
|
|
|
411
444
|
*
|
|
412
445
|
* @example
|
|
413
446
|
* ```javascript
|
|
414
|
-
* const t =
|
|
447
|
+
* const t = textmode.create({
|
|
415
448
|
* width: 800,
|
|
416
449
|
* height: 600,
|
|
417
450
|
* })
|
|
@@ -429,11 +462,10 @@ export interface RenderingCapabilities {
|
|
|
429
462
|
* @param r Red component (0-255)
|
|
430
463
|
* @param g Green component (0-255)
|
|
431
464
|
* @param b Blue component (0-255)
|
|
432
|
-
* @param a Alpha component (0-255)
|
|
433
465
|
*
|
|
434
466
|
* @example
|
|
435
467
|
* ```javascript
|
|
436
|
-
* const t =
|
|
468
|
+
* const t = textmode.create({
|
|
437
469
|
* width: 800,
|
|
438
470
|
* height: 600,
|
|
439
471
|
* })
|
|
@@ -451,11 +483,10 @@ export interface RenderingCapabilities {
|
|
|
451
483
|
* @param r Red component (0-255)
|
|
452
484
|
* @param g Green component (0-255)
|
|
453
485
|
* @param b Blue component (0-255)
|
|
454
|
-
* @param a Alpha component (0-255)
|
|
455
486
|
*
|
|
456
487
|
* @example
|
|
457
488
|
* ```javascript
|
|
458
|
-
* const t =
|
|
489
|
+
* const t = textmode.create({
|
|
459
490
|
* width: 800,
|
|
460
491
|
* height: 600,
|
|
461
492
|
* })
|
|
@@ -474,7 +505,7 @@ export interface RenderingCapabilities {
|
|
|
474
505
|
*
|
|
475
506
|
* @example
|
|
476
507
|
* ```javascript
|
|
477
|
-
* const t =
|
|
508
|
+
* const t = textmode.create({
|
|
478
509
|
* width: 800,
|
|
479
510
|
* height: 600,
|
|
480
511
|
* })
|
|
@@ -493,7 +524,7 @@ export interface RenderingCapabilities {
|
|
|
493
524
|
*
|
|
494
525
|
* @example
|
|
495
526
|
* ```javascript
|
|
496
|
-
* const t =
|
|
527
|
+
* const t = textmode.create({
|
|
497
528
|
* width: 800,
|
|
498
529
|
* height: 600,
|
|
499
530
|
* })
|
|
@@ -512,14 +543,14 @@ export interface RenderingCapabilities {
|
|
|
512
543
|
*
|
|
513
544
|
* @example
|
|
514
545
|
* ```javascript
|
|
515
|
-
* const t =
|
|
546
|
+
* const t = textmode.create({
|
|
516
547
|
* width: 800,
|
|
517
548
|
* height: 600,
|
|
518
549
|
* })
|
|
519
550
|
*
|
|
520
551
|
* t.draw(() => {
|
|
521
552
|
* t.background(0);
|
|
522
|
-
* t.charRotation(
|
|
553
|
+
* t.charRotation(90); // Rotate character 90 degrees
|
|
523
554
|
* t.rect(10, 10, 5, 5);
|
|
524
555
|
* });
|
|
525
556
|
* ```
|
|
@@ -531,7 +562,7 @@ export interface RenderingCapabilities {
|
|
|
531
562
|
*
|
|
532
563
|
* @example
|
|
533
564
|
* ```javascript
|
|
534
|
-
* const t =
|
|
565
|
+
* const t = textmode.create({
|
|
535
566
|
* width: 800,
|
|
536
567
|
* height: 600,
|
|
537
568
|
* })
|
|
@@ -553,7 +584,7 @@ export interface RenderingCapabilities {
|
|
|
553
584
|
*
|
|
554
585
|
* @example
|
|
555
586
|
* ```javascript
|
|
556
|
-
* const t =
|
|
587
|
+
* const t = textmode.create({
|
|
557
588
|
* width: 800,
|
|
558
589
|
* height: 600,
|
|
559
590
|
* })
|
|
@@ -576,7 +607,7 @@ export interface RenderingCapabilities {
|
|
|
576
607
|
*
|
|
577
608
|
* @example
|
|
578
609
|
* ```javascript
|
|
579
|
-
* const t =
|
|
610
|
+
* const t = textmode.create({
|
|
580
611
|
* width: 800,
|
|
581
612
|
* height: 600,
|
|
582
613
|
* })
|
|
@@ -599,7 +630,7 @@ export interface RenderingCapabilities {
|
|
|
599
630
|
*
|
|
600
631
|
* @example
|
|
601
632
|
* ```javascript
|
|
602
|
-
* const t =
|
|
633
|
+
* const t = textmode.create({
|
|
603
634
|
* width: 800,
|
|
604
635
|
* height: 600,
|
|
605
636
|
* })
|
|
@@ -7,6 +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 '../mouse';
|
|
11
|
+
import type { KeyboardManager } from '../keyboard';
|
|
10
12
|
/**
|
|
11
13
|
* Constructor type for mixin pattern
|
|
12
14
|
*/
|
|
@@ -30,6 +32,10 @@ export interface TextmodifierContext {
|
|
|
30
32
|
readonly _grid: TextmodeGrid;
|
|
31
33
|
/** Animation controller for managing rendering loop @ignore */
|
|
32
34
|
readonly _animationController: AnimationController;
|
|
35
|
+
/** Mouse interaction manager @ignore */
|
|
36
|
+
readonly _mouseManager: MouseManager;
|
|
37
|
+
/** Keyboard interaction manager @ignore */
|
|
38
|
+
readonly _keyboardManager: KeyboardManager;
|
|
33
39
|
/** Draw shader that contains content drawn by the user @ignore */
|
|
34
40
|
readonly _textmodeDrawShader: Shader;
|
|
35
41
|
/** Framebuffer used for offscreen rendering @ignore */
|
|
@@ -3,3 +3,7 @@ export { RenderingMixin, type RenderingCapabilities } from './RenderingMixin';
|
|
|
3
3
|
export { ExportMixin, type ExportCapabilities } from './ExportMixin';
|
|
4
4
|
export { FontMixin, type FontCapabilities } from './FontMixin';
|
|
5
5
|
export { AnimationMixin, type AnimationCapabilities } from './AnimationMixin';
|
|
6
|
+
export { MouseMixin, type MouseCapabilities } from './MouseMixin';
|
|
7
|
+
export { KeyboardMixin, type KeyboardCapabilities } from './KeyboardMixin';
|
|
8
|
+
export type { MousePosition, MouseEventData, MouseEventHandler } from '../mouse';
|
|
9
|
+
export type { KeyboardEventData, KeyboardEventHandler, KeyState } from '../keyboard';
|