textmode.js 0.4.0 → 0.6.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/dist/textmode.esm.js +2868 -2164
- package/dist/textmode.esm.min.js +2863 -2159
- package/dist/textmode.umd.js +11 -8
- package/dist/textmode.umd.min.js +11 -8
- package/dist/types/Textmode.d.ts +13 -22
- package/dist/types/index.d.ts +8 -6
- package/dist/types/rendering/index.d.ts +3 -3
- package/dist/types/rendering/webgl/batching/DrawQueue.d.ts +89 -0
- package/dist/types/rendering/webgl/{VAOManager.d.ts → batching/GeometryAttributeCache.d.ts} +4 -4
- package/dist/types/rendering/webgl/batching/InstanceAttributeBinder.d.ts +87 -0
- package/dist/types/rendering/webgl/{InstanceBatch.d.ts → batching/InstanceBatch.d.ts} +25 -34
- package/dist/types/rendering/webgl/batching/InstanceBuffer.d.ts +78 -0
- package/dist/types/rendering/webgl/{InstanceData.d.ts → batching/InstanceData.d.ts} +11 -18
- package/dist/types/rendering/webgl/batching/InstanceWriter.d.ts +70 -0
- package/dist/types/rendering/webgl/{Framebuffer.d.ts → core/Framebuffer.d.ts} +37 -39
- package/dist/types/rendering/webgl/core/Renderer.d.ts +64 -0
- package/dist/types/rendering/webgl/{Shader.d.ts → core/Shader.d.ts} +2 -23
- package/dist/types/rendering/webgl/core/interfaces/IFramebuffer.d.ts +103 -0
- package/dist/types/rendering/webgl/core/interfaces/IRenderer.d.ts +210 -0
- package/dist/types/rendering/webgl/geometries/{Arc.d.ts → 2d/Arc.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{BezierCurve.d.ts → 2d/BezierCurve.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Ellipse.d.ts → 2d/Ellipse.d.ts} +6 -5
- package/dist/types/rendering/webgl/geometries/{Line.d.ts → 2d/Line.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Rectangle.d.ts → 2d/Rectangle.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Triangle.d.ts → 2d/Triangle.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +30 -26
- package/dist/types/rendering/webgl/geometries/immediate/ImmediateQuad.d.ts +33 -0
- package/dist/types/rendering/webgl/geometries/index.d.ts +6 -6
- package/dist/types/rendering/webgl/geometries/utils/GeometryDescriptors.d.ts +31 -0
- package/dist/types/rendering/webgl/geometries/utils/GeometryGenerator.d.ts +16 -0
- package/dist/types/rendering/webgl/index.d.ts +15 -14
- package/dist/types/rendering/webgl/materials/Material.d.ts +26 -0
- package/dist/types/rendering/webgl/materials/MaterialManager.d.ts +63 -0
- package/dist/types/rendering/webgl/materials/index.d.ts +2 -0
- package/dist/types/rendering/webgl/pipeline/MaterialBatchPipeline.d.ts +63 -0
- package/dist/types/rendering/webgl/pipeline/index.d.ts +7 -0
- package/dist/types/rendering/webgl/state/RenderState.d.ts +143 -0
- package/dist/types/rendering/webgl/types/DrawCommand.d.ts +5 -3
- package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +10 -10
- package/dist/types/rendering/webgl/types/RenderTypes.d.ts +1 -1
- package/dist/types/rendering/webgl/utils/GLUtils.d.ts +45 -0
- package/dist/types/rendering/webgl/utils/hash.d.ts +118 -0
- package/dist/types/textmode/AnimationController.d.ts +11 -21
- package/dist/types/textmode/Canvas.d.ts +10 -2
- package/dist/types/textmode/Grid.d.ts +2 -0
- package/dist/types/textmode/TextmodeColor.d.ts +57 -0
- package/dist/types/textmode/Textmodifier.d.ts +40 -212
- package/dist/types/textmode/interfaces/ITextmodifier.d.ts +272 -0
- package/dist/types/textmode/interfaces/index.d.ts +1 -0
- package/dist/types/textmode/loadables/TextmodeImage.d.ts +21 -0
- package/dist/types/textmode/loadables/TextmodeSource.d.ts +130 -0
- package/dist/types/textmode/loadables/TextmodeVideo.d.ts +237 -0
- package/dist/types/textmode/{font → loadables/font}/CharacterColorMapper.d.ts +1 -1
- package/dist/types/textmode/{font → loadables/font}/CharacterExtractor.d.ts +0 -10
- package/dist/types/textmode/{font → loadables/font}/TextmodeFont.d.ts +6 -3
- package/dist/types/textmode/{font → loadables/font}/TextureAtlas.d.ts +4 -11
- package/dist/types/textmode/{font → loadables/font}/typr/types.d.ts +0 -6
- package/dist/types/textmode/loadables/index.d.ts +5 -0
- package/dist/types/textmode/loading/LoadingPhaseTracker.d.ts +20 -0
- package/dist/types/textmode/loading/LoadingScreenManager.d.ts +170 -0
- package/dist/types/textmode/loading/LoadingScreenState.d.ts +22 -0
- package/dist/types/textmode/loading/LoadingScreenTheme.d.ts +26 -0
- package/dist/types/textmode/loading/LoadingScreenTransition.d.ts +17 -0
- package/dist/types/textmode/loading/index.d.ts +6 -0
- package/dist/types/textmode/loading/templates/SpinnerTemplate.d.ts +2 -0
- package/dist/types/textmode/loading/templates/index.d.ts +1 -0
- package/dist/types/textmode/loading/types.d.ts +251 -0
- package/dist/types/textmode/managers/KeyboardManager.d.ts +2 -3
- package/dist/types/textmode/managers/MouseManager.d.ts +1 -1
- package/dist/types/textmode/{plugins → managers}/PluginManager.d.ts +12 -15
- package/dist/types/textmode/managers/TouchManager.d.ts +0 -2
- package/dist/types/textmode/mixins/AnimationMixin.d.ts +2 -122
- package/dist/types/textmode/mixins/FontMixin.d.ts +2 -77
- package/dist/types/textmode/mixins/KeyboardMixin.d.ts +3 -85
- package/dist/types/textmode/mixins/MouseMixin.d.ts +3 -130
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +2 -749
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +2 -44
- package/dist/types/textmode/mixins/TouchMixin.d.ts +2 -187
- package/dist/types/textmode/mixins/index.d.ts +8 -8
- package/dist/types/textmode/mixins/interfaces/IAnimationMixin.d.ts +167 -0
- package/dist/types/textmode/mixins/interfaces/IFontMixin.d.ts +46 -0
- package/dist/types/textmode/mixins/interfaces/IKeyboardMixin.d.ts +235 -0
- package/dist/types/textmode/mixins/interfaces/IMouseMixin.d.ts +457 -0
- package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +1085 -0
- package/dist/types/textmode/mixins/interfaces/ITouchMixin.d.ts +186 -0
- package/dist/types/textmode/types.d.ts +49 -0
- package/dist/types/textmode/utils/cssColor.d.ts +8 -0
- package/dist/types/utils/array.d.ts +34 -0
- package/dist/types/utils/math.d.ts +69 -0
- package/package.json +1 -1
- package/dist/types/rendering/webgl/DrawQueue.d.ts +0 -30
- package/dist/types/rendering/webgl/RenderPipeline.d.ts +0 -30
- package/dist/types/rendering/webgl/RenderState.d.ts +0 -73
- package/dist/types/rendering/webgl/Renderer.d.ts +0 -158
- package/dist/types/rendering/webgl/ShaderManager.d.ts +0 -66
- package/dist/types/rendering/webgl/geometries/NoiseGrid.d.ts +0 -1
- package/dist/types/textmode/TextmodeImage.d.ts +0 -161
- package/dist/types/textmode/mixins/ShaderMixin.d.ts +0 -1
- /package/dist/types/rendering/webgl/{StateCache.d.ts → utils/ViewportCache.d.ts} +0 -0
- /package/dist/types/textmode/{font → loadables/font}/MetricsCalculator.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/index.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/types.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/typr/Typr.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/utils/FontTableReader.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/utils/index.d.ts +0 -0
|
@@ -1,128 +1,8 @@
|
|
|
1
1
|
import type { Mixin } from './TextmodifierMixin';
|
|
2
|
-
|
|
3
|
-
* Interface for animation capabilities that will be mixed into Textmodifier
|
|
4
|
-
*/
|
|
5
|
-
export interface AnimationCapabilities {
|
|
6
|
-
/**
|
|
7
|
-
* Set the maximum frame rate. If called without arguments, returns the current measured frame rate.
|
|
8
|
-
* @param fps The maximum frames per second for rendering.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```javascript
|
|
12
|
-
* // Create a Textmodifier instance
|
|
13
|
-
* const textmodifier = textmode.create();
|
|
14
|
-
*
|
|
15
|
-
* // Set the maximum frame rate to 30 FPS
|
|
16
|
-
* textmodifier.frameRate(30);
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
frameRate(fps?: number): number | void;
|
|
20
|
-
/**
|
|
21
|
-
* Stop the automatic rendering loop.
|
|
22
|
-
*
|
|
23
|
-
* This method pauses the render loop without, allowing
|
|
24
|
-
* it to be resumed later with {@link loop}. This is useful for temporarily pausing
|
|
25
|
-
* animation while maintaining the ability to continue it.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```javascript
|
|
29
|
-
* // Create a textmodifier instance in auto mode
|
|
30
|
-
* const textmodifier = textmode.create();
|
|
31
|
-
*
|
|
32
|
-
* // The render loop is running by default
|
|
33
|
-
* console.log(textmodifier.isLooping()); // true
|
|
34
|
-
*
|
|
35
|
-
* // Stop the automatic rendering loop
|
|
36
|
-
* textmodifier.noLoop();
|
|
37
|
-
* console.log(textmodifier.isLooping()); // false
|
|
38
|
-
*
|
|
39
|
-
* // Resume the rendering loop
|
|
40
|
-
* textmodifier.loop();
|
|
41
|
-
* console.log(textmodifier.isLooping()); // true
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
noLoop(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Resume the rendering loop if it was stopped by {@link noLoop}.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```javascript
|
|
50
|
-
* // Create a textmodifier instance
|
|
51
|
-
* const textmodifier = textmode.create();
|
|
52
|
-
*
|
|
53
|
-
* // Stop the loop
|
|
54
|
-
* textmodifier.noLoop();
|
|
55
|
-
*
|
|
56
|
-
* // Resume the loop
|
|
57
|
-
* textmodifier.loop();
|
|
58
|
-
*
|
|
59
|
-
* // You can also use this pattern for conditional animation
|
|
60
|
-
* if (someCondition) {
|
|
61
|
-
* textmodifier.loop();
|
|
62
|
-
* } else {
|
|
63
|
-
* textmodifier.noLoop();
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
loop(): void;
|
|
68
|
-
/**
|
|
69
|
-
* Execute the render function a specified number of times.
|
|
70
|
-
*
|
|
71
|
-
* This method is useful when the render loop has been stopped with {@link noLoop},
|
|
72
|
-
* allowing you to trigger rendering on demand.
|
|
73
|
-
*
|
|
74
|
-
* @param n The number of times to execute the render function. Defaults to 1.
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```javascript
|
|
78
|
-
* // Create a textmodifier instance
|
|
79
|
-
* const textmodifier = textmode.create();
|
|
80
|
-
*
|
|
81
|
-
* // Set up drawing
|
|
82
|
-
* textmodifier.draw(() => {
|
|
83
|
-
* textmodifier.background(0);
|
|
84
|
-
*
|
|
85
|
-
* textmodifier.char("A");
|
|
86
|
-
* textmodifier.charColor(255, 0, 0);
|
|
87
|
-
* textmodifier.rect(10, 10, 50, 50);
|
|
88
|
-
* });
|
|
89
|
-
*
|
|
90
|
-
* textmodifier.noLoop();
|
|
91
|
-
* textmodifier.redraw(3); // Render 3 times despite loop being stopped
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
redraw(n?: number): void;
|
|
95
|
-
/**
|
|
96
|
-
* Check whether the textmodifier is currently running the automatic render loop.
|
|
97
|
-
* @returns True if the render loop is currently active, false otherwise.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```javascript
|
|
101
|
-
* const textmodifier = textmode.create(canvas);
|
|
102
|
-
*
|
|
103
|
-
* // Check loop status in different states
|
|
104
|
-
* console.log(textmodifier.isLooping()); // true (looping)
|
|
105
|
-
*
|
|
106
|
-
* textmodifier.noLoop();
|
|
107
|
-
* console.log(textmodifier.isLooping()); // false (not looping)
|
|
108
|
-
*
|
|
109
|
-
* textmodifier.loop();
|
|
110
|
-
* console.log(textmodifier.isLooping()); // true (alooping)
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
isLooping(): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Get the current frame count.
|
|
116
|
-
*/
|
|
117
|
-
get frameCount(): number;
|
|
118
|
-
/**
|
|
119
|
-
* Set the current frame count.
|
|
120
|
-
*/
|
|
121
|
-
set frameCount(value: number);
|
|
122
|
-
}
|
|
2
|
+
import type { IAnimationMixin } from './interfaces/IAnimationMixin';
|
|
123
3
|
/**
|
|
124
4
|
* Mixin that adds animation capabilities to a class
|
|
125
5
|
* @param Base The base class to extend
|
|
126
6
|
* @returns Extended class with animation capabilities
|
|
127
7
|
*/
|
|
128
|
-
export declare const AnimationMixin: Mixin<
|
|
8
|
+
export declare const AnimationMixin: Mixin<IAnimationMixin>;
|
|
@@ -1,83 +1,8 @@
|
|
|
1
1
|
import type { Mixin } from './TextmodifierMixin';
|
|
2
|
-
|
|
3
|
-
* Interface for font capabilities that will be mixed into Textmodifier
|
|
4
|
-
*/
|
|
5
|
-
export interface FontCapabilities {
|
|
6
|
-
/**
|
|
7
|
-
* Update the font used for rendering.
|
|
8
|
-
* @param fontSource The URL of the font to load.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```javascript
|
|
12
|
-
* // Create a Textmodifier instance
|
|
13
|
-
* const textmodifier = textmode.create();
|
|
14
|
-
*
|
|
15
|
-
* // Load a custom font from a URL
|
|
16
|
-
* await textmodifier.loadFont('https://example.com/fonts/myfont.ttf');
|
|
17
|
-
*
|
|
18
|
-
* // Local font example
|
|
19
|
-
* // await textmodifier.loadFont('./fonts/myfont.ttf');
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
loadFont(fontSource: string): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Set the font size used for rendering.
|
|
25
|
-
* @param size The font size to set.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```javascript
|
|
29
|
-
* // Create a Textmodifier instance
|
|
30
|
-
* const textmodifier = textmode.create();
|
|
31
|
-
*
|
|
32
|
-
* // Set the font size to 32
|
|
33
|
-
* textmodifier.fontSize(32);
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
fontSize(size: number): void;
|
|
37
|
-
/**
|
|
38
|
-
* Get the RGB shader color of a specific character in the current font.
|
|
39
|
-
*
|
|
40
|
-
* Useful for custom shaders to control the character to render.
|
|
41
|
-
*
|
|
42
|
-
* @param char The character to get the color for.
|
|
43
|
-
* @returns An array representing the RGB color, or null if the character is not found.
|
|
44
|
-
* @example
|
|
45
|
-
* ```javascript
|
|
46
|
-
* // Create a Textmodifier instance
|
|
47
|
-
* const textmodifier = textmode.create();
|
|
48
|
-
*
|
|
49
|
-
* // Get the color of the character 'A'
|
|
50
|
-
* textmodifier.setup(() => {
|
|
51
|
-
* const color = textmodifier.glyphColor('A');
|
|
52
|
-
* console.log(color); // e.g., [1, 0, 0] for red
|
|
53
|
-
* });
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
glyphColor(char: string): [number, number, number] | null;
|
|
57
|
-
/**
|
|
58
|
-
* Get the RGB shader colors of all characters in a string for the current font.
|
|
59
|
-
*
|
|
60
|
-
* Useful for custom shaders to control the characters to render.
|
|
61
|
-
*
|
|
62
|
-
* @param str The string to get the colors for.
|
|
63
|
-
* @returns An array of RGB color arrays, or null if a character is not found.
|
|
64
|
-
* @example
|
|
65
|
-
* ```javascript
|
|
66
|
-
* // Create a Textmodifier instance
|
|
67
|
-
* const textmodifier = textmode.create();
|
|
68
|
-
*
|
|
69
|
-
* // Get the colors of the string 'Hello'
|
|
70
|
-
* textmodifier.setup(() => {
|
|
71
|
-
* const colors = textmodifier.glyphColors('Hello');
|
|
72
|
-
* console.log(colors); // e.g., [[0.1, 0, 0], ...]
|
|
73
|
-
* });
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
glyphColors(str: string): ([number, number, number] | null)[];
|
|
77
|
-
}
|
|
2
|
+
import type { IFontMixin } from './interfaces/IFontMixin';
|
|
78
3
|
/**
|
|
79
4
|
* Mixin that adds font capabilities to a class
|
|
80
5
|
* @param Base The base class to extend
|
|
81
6
|
* @returns Extended class with font capabilities
|
|
82
7
|
*/
|
|
83
|
-
export declare const FontMixin: Mixin<
|
|
8
|
+
export declare const FontMixin: Mixin<IFontMixin>;
|
|
@@ -1,95 +1,13 @@
|
|
|
1
1
|
import type { Mixin } from './TextmodifierMixin';
|
|
2
|
-
import type {
|
|
3
|
-
/**
|
|
4
|
-
* Capabilities provided by the KeyboardMixin
|
|
5
|
-
*/
|
|
6
|
-
export interface KeyboardCapabilities {
|
|
7
|
-
/**
|
|
8
|
-
* Check if a specific key is currently being pressed.
|
|
9
|
-
*
|
|
10
|
-
* @param key The key to check (e.g., 'a', 'Enter', 'ArrowLeft')
|
|
11
|
-
* @returns true if the key is currently pressed, false otherwise
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```javascript
|
|
15
|
-
* const t = textmode.create({ width: 800, height: 600 });
|
|
16
|
-
*
|
|
17
|
-
* let playerX = 0;
|
|
18
|
-
* let playerY = 0;
|
|
19
|
-
*
|
|
20
|
-
* t.draw(() => {
|
|
21
|
-
* t.background(0);
|
|
22
|
-
*
|
|
23
|
-
* // Check for arrow keys to move a character
|
|
24
|
-
* if (t.isKeyPressed('ArrowUp')) {
|
|
25
|
-
* playerY -= 1;
|
|
26
|
-
* }
|
|
27
|
-
* if (t.isKeyPressed('ArrowDown')) {
|
|
28
|
-
* playerY += 1;
|
|
29
|
-
* }
|
|
30
|
-
* if (t.isKeyPressed('ArrowLeft')) {
|
|
31
|
-
* playerX -= 1;
|
|
32
|
-
* }
|
|
33
|
-
* if (t.isKeyPressed('ArrowRight')) {
|
|
34
|
-
* playerX += 1;
|
|
35
|
-
* }
|
|
36
|
-
*
|
|
37
|
-
* // Draw player character
|
|
38
|
-
* t.char('@');
|
|
39
|
-
* t.charColor(255, 255, 0);
|
|
40
|
-
* t.point(playerX, playerY);
|
|
41
|
-
* });
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
isKeyPressed(key: string): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Set a callback function that will be called when a key is pressed down.
|
|
47
|
-
*
|
|
48
|
-
* @param callback The function to call when a key is pressed
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```javascript
|
|
52
|
-
* const t = textmode.create({ width: 800, height: 600 });
|
|
53
|
-
*
|
|
54
|
-
* t.keyPressed((data) => {
|
|
55
|
-
* console.log(`Key pressed: ${data.key}`);
|
|
56
|
-
* if (data.key === 'Enter') {
|
|
57
|
-
* console.log('Enter key was pressed!');
|
|
58
|
-
* }
|
|
59
|
-
* if (data.ctrlKey && data.key === 's') {
|
|
60
|
-
* console.log('Ctrl+S was pressed!');
|
|
61
|
-
* }
|
|
62
|
-
* });
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
keyPressed(callback: KeyboardEventHandler): void;
|
|
66
|
-
/**
|
|
67
|
-
* Set a callback function that will be called when a key is released.
|
|
68
|
-
*
|
|
69
|
-
* @param callback The function to call when a key is released
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```javascript
|
|
73
|
-
* const t = textmode.create({ width: 800, height: 600 });
|
|
74
|
-
*
|
|
75
|
-
* t.keyReleased((data) => {
|
|
76
|
-
* console.log(`Key released: ${data.key}`);
|
|
77
|
-
* if (data.key === ' ') {
|
|
78
|
-
* console.log('Spacebar was released!');
|
|
79
|
-
* }
|
|
80
|
-
* });
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
keyReleased(callback: KeyboardEventHandler): void;
|
|
84
|
-
}
|
|
2
|
+
import type { IKeyboardMixin } from './interfaces/IKeyboardMixin';
|
|
85
3
|
/**
|
|
86
4
|
* Mixin that adds keyboard interaction capabilities to Textmodifier.
|
|
87
5
|
*
|
|
88
6
|
* This is a thin wrapper around KeyboardManager that provides the public API
|
|
89
7
|
* for keyboard interaction. All the actual implementation is handled by the
|
|
90
|
-
* KeyboardManager instance in the
|
|
8
|
+
* KeyboardManager instance in the ITextmodifier.
|
|
91
9
|
*
|
|
92
10
|
* Provides p5.js-like keyboard functionality including key state tracking,
|
|
93
11
|
* event callbacks, and special key handling.
|
|
94
12
|
*/
|
|
95
|
-
export declare const KeyboardMixin: Mixin<
|
|
13
|
+
export declare const KeyboardMixin: Mixin<IKeyboardMixin>;
|
|
@@ -1,137 +1,10 @@
|
|
|
1
1
|
import type { Mixin } from './TextmodifierMixin';
|
|
2
|
-
import type {
|
|
3
|
-
/**
|
|
4
|
-
* Capabilities provided by the MouseMixin
|
|
5
|
-
*/
|
|
6
|
-
export interface MouseCapabilities {
|
|
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
|
-
*/
|
|
22
|
-
mouseClicked(callback: MouseEventHandler): void;
|
|
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
|
-
*/
|
|
37
|
-
mousePressed(callback: MouseEventHandler): void;
|
|
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
|
-
*/
|
|
52
|
-
mouseReleased(callback: MouseEventHandler): void;
|
|
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
|
-
*/
|
|
70
|
-
mouseMoved(callback: MouseEventHandler): void;
|
|
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
|
-
*/
|
|
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;
|
|
112
|
-
/**
|
|
113
|
-
* Set the mouse cursor for the textmode canvas.
|
|
114
|
-
*
|
|
115
|
-
* Provide any valid CSS cursor value (e.g. 'default', 'pointer', 'crosshair', 'move', 'text', 'grab', 'grabbing',
|
|
116
|
-
* 'none', 'zoom-in', 'zoom-out', 'ns-resize', 'ew-resize', 'nwse-resize', 'nesw-resize', etc.),
|
|
117
|
-
* or a CSS `url(...)` cursor. Call with no argument or an empty string to reset to default.
|
|
118
|
-
*
|
|
119
|
-
* See MDN for all options: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```javascript
|
|
123
|
-
* t.cursor('crosshair');
|
|
124
|
-
* // ... later, reset:
|
|
125
|
-
* t.cursor();
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
cursor(cursor?: string): void;
|
|
129
|
-
}
|
|
2
|
+
import type { IMouseMixin } from './interfaces/IMouseMixin';
|
|
130
3
|
/**
|
|
131
4
|
* Mixin that adds mouse tracking capabilities to Textmodifier.
|
|
132
5
|
*
|
|
133
6
|
* This is a thin wrapper around MouseManager that provides the public API
|
|
134
7
|
* for mouse interaction. All the actual implementation is handled by the
|
|
135
|
-
* MouseManager instance in the
|
|
8
|
+
* MouseManager instance in the ITextmodifier.
|
|
136
9
|
*/
|
|
137
|
-
export declare const MouseMixin: Mixin<
|
|
10
|
+
export declare const MouseMixin: Mixin<IMouseMixin>;
|