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,755 +1,8 @@
|
|
|
1
1
|
import type { Mixin } from './TextmodifierMixin';
|
|
2
|
-
import type {
|
|
3
|
-
import type { GLFramebuffer } from '../../rendering';
|
|
4
|
-
import { TextmodeImage } from '../TextmodeImage';
|
|
5
|
-
/**
|
|
6
|
-
* Options for creating a framebuffer.
|
|
7
|
-
*/
|
|
8
|
-
export type TextmodeFramebufferOptions = {
|
|
9
|
-
/** Width of the framebuffer in grid cells */
|
|
10
|
-
width: number;
|
|
11
|
-
/** Height of the framebuffer in grid cells */
|
|
12
|
-
height: number;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Supported uniform value types for shader parameters
|
|
16
|
-
*/
|
|
17
|
-
type UniformValue = number | boolean | number[] | Float32Array | Int32Array | WebGLTexture;
|
|
18
|
-
/**
|
|
19
|
-
* Interface for rendering capabilities that will be mixed into Textmodifier
|
|
20
|
-
*/
|
|
21
|
-
export interface RenderingCapabilities {
|
|
22
|
-
/**
|
|
23
|
-
* Set a custom shader for subsequent rendering operations.
|
|
24
|
-
* @param shader The custom shader to use
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```javascript
|
|
28
|
-
* const t = textmode.create({
|
|
29
|
-
* width: 800,
|
|
30
|
-
* height: 600,
|
|
31
|
-
* })
|
|
32
|
-
*
|
|
33
|
-
* // Create a custom filter shader
|
|
34
|
-
* const customShader = t.createFilterShader(`
|
|
35
|
-
* // ... fragment shader code ...
|
|
36
|
-
* `);
|
|
37
|
-
*
|
|
38
|
-
* t.draw(() => {
|
|
39
|
-
* t.background(0);
|
|
40
|
-
*
|
|
41
|
-
* // Use custom shader
|
|
42
|
-
* t.shader(customShader);
|
|
43
|
-
* t.setUniform('u_frameCount', t.frameCount);
|
|
44
|
-
* t.rect(0, 0, t.grid.cols, t.grid.rows);
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
shader(shader: GLShader): void;
|
|
49
|
-
/**
|
|
50
|
-
* Create a new framebuffer for offscreen rendering.
|
|
51
|
-
*
|
|
52
|
-
* The framebuffer uses the same 5-attachment MRT structure as the main
|
|
53
|
-
* rendering pipeline, allowing all standard drawing operations to work
|
|
54
|
-
* seamlessly when rendering to the framebuffer.
|
|
55
|
-
*
|
|
56
|
-
* @param options Configuration options for the framebuffer.
|
|
57
|
-
* @returns A new Framebuffer instance.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```javascript
|
|
61
|
-
* const t = textmode.create({
|
|
62
|
-
* width: 800,
|
|
63
|
-
* height: 600,
|
|
64
|
-
* });
|
|
65
|
-
*
|
|
66
|
-
* // Create a framebuffer with 50x30 grid cells
|
|
67
|
-
* const fb = t.createFramebuffer({
|
|
68
|
-
* width: 50,
|
|
69
|
-
* height: 30
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* t.draw(() => {
|
|
73
|
-
* // Render to framebuffer
|
|
74
|
-
* fb.begin();
|
|
75
|
-
* t.background(255, 0, 0);
|
|
76
|
-
* t.charColor(255);
|
|
77
|
-
* t.rect(10, 10, 20, 10);
|
|
78
|
-
* fb.end();
|
|
79
|
-
*
|
|
80
|
-
* // Render framebuffer to main canvas
|
|
81
|
-
* t.background(0);
|
|
82
|
-
* t.image(fb, 0, 0);
|
|
83
|
-
* });
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
createFramebuffer(options: TextmodeFramebufferOptions): GLFramebuffer;
|
|
87
|
-
/**
|
|
88
|
-
* Draw a TextmodeFramebuffer or TextmodeImage to the current render target.
|
|
89
|
-
*
|
|
90
|
-
* @param source The TextmodeFramebuffer or TextmodeImage to render
|
|
91
|
-
* @param x X position on the grid where to place the content *(top-left corner)*
|
|
92
|
-
* @param y Y position on the grid where to place the content *(top-left corner)*
|
|
93
|
-
* @param width Width to scale the content
|
|
94
|
-
* @param height Height to scale the content
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```javascript
|
|
98
|
-
* const t = textmode.create({
|
|
99
|
-
* width: 800,
|
|
100
|
-
* height: 600,
|
|
101
|
-
* });
|
|
102
|
-
*
|
|
103
|
-
* const fb = t.createFramebuffer({width: 30, height: 20});
|
|
104
|
-
*
|
|
105
|
-
* t.draw(() => {
|
|
106
|
-
* // Draw something to the framebuffer
|
|
107
|
-
* fb.begin();
|
|
108
|
-
* t.charColor(255, 0, 0);
|
|
109
|
-
* t.rect(5, 5, 20, 10);
|
|
110
|
-
* fb.end();
|
|
111
|
-
*
|
|
112
|
-
* // Clear main canvas and render framebuffer content
|
|
113
|
-
* t.background(0);
|
|
114
|
-
*
|
|
115
|
-
* // Render at original size
|
|
116
|
-
* t.image(fb, 10, 10);
|
|
117
|
-
*
|
|
118
|
-
* // Render scaled version
|
|
119
|
-
* t.image(fb, 50, 10, 60, 40);
|
|
120
|
-
* });
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
image(source: GLFramebuffer | TextmodeImage, x: number, y: number, width?: number, height?: number): void;
|
|
124
|
-
/**
|
|
125
|
-
* Load an image and return a TextmodeImage that can be drawn with image().
|
|
126
|
-
* @param src URL or existing HTMLImageElement
|
|
127
|
-
*/
|
|
128
|
-
loadImage(src: string | HTMLImageElement): Promise<TextmodeImage>;
|
|
129
|
-
/**
|
|
130
|
-
* Set a uniform value for the current custom shader.
|
|
131
|
-
* @param name The name of the uniform variable
|
|
132
|
-
* @param value The value to set
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* ```javascript
|
|
136
|
-
* const t = textmode.create({
|
|
137
|
-
* width: 800,
|
|
138
|
-
* height: 600,
|
|
139
|
-
* })
|
|
140
|
-
*
|
|
141
|
-
* const shader = t.createFilterShader(`
|
|
142
|
-
* uniform float u_time;
|
|
143
|
-
* // ... rest of shader ...
|
|
144
|
-
* `);
|
|
145
|
-
*
|
|
146
|
-
* t.draw(() => {
|
|
147
|
-
* t.shader(shader);
|
|
148
|
-
* t.setUniform('u_time', t.frameCount * 0.02);
|
|
149
|
-
* t.rect(0, 0, t.grid.cols, t.grid.rows);
|
|
150
|
-
* });
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
setUniform(name: string, value: UniformValue): void;
|
|
154
|
-
/**
|
|
155
|
-
* Set multiple uniform values for the current custom shader.
|
|
156
|
-
* @param uniforms Object containing uniform name-value pairs
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* ```javascript
|
|
160
|
-
* const t = textmode.create({
|
|
161
|
-
* width: 800,
|
|
162
|
-
* height: 600,
|
|
163
|
-
* })
|
|
164
|
-
*
|
|
165
|
-
* const shader = t.createFilterShader(`
|
|
166
|
-
* uniform float u_time;
|
|
167
|
-
* uniform vec2 u_resolution;
|
|
168
|
-
* // ... rest of shader ...
|
|
169
|
-
* `);
|
|
170
|
-
*
|
|
171
|
-
* t.draw(() => {
|
|
172
|
-
* t.shader(shader);
|
|
173
|
-
* t.setUniforms({
|
|
174
|
-
* u_time: t.frameCount * 0.02,
|
|
175
|
-
* u_resolution: [t.grid.cols, t.grid.rows]
|
|
176
|
-
* });
|
|
177
|
-
* t.rect(0, 0, t.grid.cols, t.grid.rows);
|
|
178
|
-
* });
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
182
|
-
/**
|
|
183
|
-
* Create a custom filter shader from fragment shader source code.
|
|
184
|
-
* The fragment shader will automatically receive the standard vertex shader inputs
|
|
185
|
-
* and must output to all 5 MRT attachments.
|
|
186
|
-
* @param fragmentSource The fragment shader source code
|
|
187
|
-
* @returns A compiled shader ready for use with {@link shader}
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```javascript
|
|
191
|
-
* const t = textmode.create({
|
|
192
|
-
* width: 800,
|
|
193
|
-
* height: 600,
|
|
194
|
-
* })
|
|
195
|
-
*
|
|
196
|
-
* const noiseShader = t.createFilterShader(`
|
|
197
|
-
* #version 300 es
|
|
198
|
-
* precision highp float;
|
|
199
|
-
*
|
|
200
|
-
* in vec2 v_uv;
|
|
201
|
-
* in vec3 v_character;
|
|
202
|
-
* in vec4 v_primaryColor;
|
|
203
|
-
* in vec4 v_secondaryColor;
|
|
204
|
-
* in vec2 v_rotation;
|
|
205
|
-
* in vec3 v_transform;
|
|
206
|
-
*
|
|
207
|
-
* uniform float u_frameCount;
|
|
208
|
-
*
|
|
209
|
-
* layout(location = 0) out vec4 o_character;
|
|
210
|
-
* layout(location = 1) out vec4 o_primaryColor;
|
|
211
|
-
* layout(location = 2) out vec4 o_secondaryColor;
|
|
212
|
-
* layout(location = 3) out vec4 o_rotation;
|
|
213
|
-
* layout(location = 4) out vec4 o_transform;
|
|
214
|
-
*
|
|
215
|
-
* float random(vec2 st) {
|
|
216
|
-
* return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);
|
|
217
|
-
* }
|
|
218
|
-
*
|
|
219
|
-
* void main() {
|
|
220
|
-
* vec2 gridPos = floor(gl_FragCoord.xy);
|
|
221
|
-
* float noise = random(gridPos + u_frameCount * 0.1);
|
|
222
|
-
*
|
|
223
|
-
* o_character = vec4(noise, 0.0, 0.0, 1.0);
|
|
224
|
-
* o_primaryColor = vec4(vec3(noise), 1.0);
|
|
225
|
-
* o_secondaryColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
226
|
-
* o_rotation = vec4(0.0, 0.0, 0.0, 1.0);
|
|
227
|
-
* o_transform = vec4(0.0, 0.0, 0.0, 1.0);
|
|
228
|
-
* }
|
|
229
|
-
* `);
|
|
230
|
-
*
|
|
231
|
-
* t.draw(() => {
|
|
232
|
-
* t.shader(noiseShader);
|
|
233
|
-
* t.setUniform('u_frameCount', t.frameCount);
|
|
234
|
-
* t.rect(0, 0, t.grid.cols, t.grid.rows);
|
|
235
|
-
* });
|
|
236
|
-
* ```
|
|
237
|
-
*/
|
|
238
|
-
createFilterShader(fragmentSource: string): GLShader;
|
|
239
|
-
/**
|
|
240
|
-
* Sets the rotation angles for subsequent shape rendering operations.
|
|
241
|
-
*
|
|
242
|
-
* All geometries rotate around the center of the shape.
|
|
243
|
-
*
|
|
244
|
-
* @param degreesX The rotation angle in degrees around the X-axis (optional, defaults to 0)
|
|
245
|
-
* @param degreesY The rotation angle in degrees around the Y-axis (optional, defaults to 0)
|
|
246
|
-
* @param degreesZ The rotation angle in degrees around the Z-axis (optional, defaults to 0)
|
|
247
|
-
*
|
|
248
|
-
* @example
|
|
249
|
-
* ```javascript
|
|
250
|
-
* const t = textmode.create({
|
|
251
|
-
* width: 800,
|
|
252
|
-
* height: 600,
|
|
253
|
-
* })
|
|
254
|
-
*
|
|
255
|
-
* t.draw(() => {
|
|
256
|
-
* t.background(0);
|
|
257
|
-
*
|
|
258
|
-
* // Rotate only around Z-axis (backward compatible)
|
|
259
|
-
* t.rotate(0, 0, 45);
|
|
260
|
-
*
|
|
261
|
-
* // Rotate around all three axes
|
|
262
|
-
* t.rotate(30, 45, 60);
|
|
263
|
-
*
|
|
264
|
-
* t.rect(10, 10, 5, 5);
|
|
265
|
-
* });
|
|
266
|
-
* ```
|
|
267
|
-
*/
|
|
268
|
-
rotate(degreesX?: number, degreesY?: number, degreesZ?: number): void;
|
|
269
|
-
/**
|
|
270
|
-
* Sets the X-axis rotation angle for subsequent shape rendering operations.
|
|
271
|
-
*
|
|
272
|
-
* All geometries rotate around the center of the shape.
|
|
273
|
-
*
|
|
274
|
-
* @param degrees The rotation angle in degrees around the X-axis
|
|
275
|
-
*
|
|
276
|
-
* @example
|
|
277
|
-
* ```javascript
|
|
278
|
-
* const t = textmode.create({
|
|
279
|
-
* width: 800,
|
|
280
|
-
* height: 600,
|
|
281
|
-
* })
|
|
282
|
-
*
|
|
283
|
-
* t.draw(() => {
|
|
284
|
-
* t.background(0);
|
|
285
|
-
* t.rotateX(45); // Rotate around X-axis
|
|
286
|
-
* t.rect(10, 10, 5, 5);
|
|
287
|
-
* });
|
|
288
|
-
* ```
|
|
289
|
-
*/
|
|
290
|
-
rotateX(degrees: number): void;
|
|
291
|
-
/**
|
|
292
|
-
* Sets the Y-axis rotation angle for subsequent shape rendering operations.
|
|
293
|
-
*
|
|
294
|
-
* All geometries rotate around the center of the shape.
|
|
295
|
-
*
|
|
296
|
-
* @param degrees The rotation angle in degrees around the Y-axis
|
|
297
|
-
*
|
|
298
|
-
* @example
|
|
299
|
-
* ```javascript
|
|
300
|
-
* const t = textmode.create({
|
|
301
|
-
* width: 800,
|
|
302
|
-
* height: 600,
|
|
303
|
-
* })
|
|
304
|
-
*
|
|
305
|
-
* t.draw(() => {
|
|
306
|
-
* t.background(0);
|
|
307
|
-
* t.rotateY(45); // Rotate around Y-axis
|
|
308
|
-
* t.rect(10, 10, 5, 5);
|
|
309
|
-
* });
|
|
310
|
-
* ```
|
|
311
|
-
*/
|
|
312
|
-
rotateY(degrees: number): void;
|
|
313
|
-
/**
|
|
314
|
-
* Sets the Z-axis rotation angle for subsequent shape rendering operations.
|
|
315
|
-
*
|
|
316
|
-
* All geometries rotate around the center of the shape.
|
|
317
|
-
*
|
|
318
|
-
* @param degrees The rotation angle in degrees around the Z-axis
|
|
319
|
-
*
|
|
320
|
-
* @example
|
|
321
|
-
* ```javascript
|
|
322
|
-
* const t = textmode.create({
|
|
323
|
-
* width: 800,
|
|
324
|
-
* height: 600,
|
|
325
|
-
* })
|
|
326
|
-
*
|
|
327
|
-
* t.draw(() => {
|
|
328
|
-
* t.background(0);
|
|
329
|
-
* t.rotateZ(45); // Rotate around Z-axis
|
|
330
|
-
* t.rect(10, 10, 5, 5);
|
|
331
|
-
* });
|
|
332
|
-
* ```
|
|
333
|
-
*/
|
|
334
|
-
rotateZ(degrees: number): void;
|
|
335
|
-
/**
|
|
336
|
-
* Save the current rendering state to the state stack.
|
|
337
|
-
* Use with {@link pop} to isolate style changes within a block.
|
|
338
|
-
*
|
|
339
|
-
* @example
|
|
340
|
-
* ```javascript
|
|
341
|
-
* const t = textmode.create({
|
|
342
|
-
* width: 800,
|
|
343
|
-
* height: 600,
|
|
344
|
-
* })
|
|
345
|
-
*
|
|
346
|
-
* t.draw(() => {
|
|
347
|
-
* t.background(0);
|
|
348
|
-
*
|
|
349
|
-
* t.push(); // Save current state
|
|
350
|
-
* t.charColor(255, 0, 0); // Red characters
|
|
351
|
-
* t.rect(10, 10, 5, 5);
|
|
352
|
-
* t.pop(); // Restore previous state
|
|
353
|
-
* });
|
|
354
|
-
* ```
|
|
355
|
-
*/
|
|
356
|
-
push(): void;
|
|
357
|
-
/**
|
|
358
|
-
* Restore the most recently saved rendering state from the state stack.
|
|
359
|
-
* Use with {@link push} to isolate style changes within a block.
|
|
360
|
-
*
|
|
361
|
-
* @example
|
|
362
|
-
* ```javascript
|
|
363
|
-
* const t = textmode.create({
|
|
364
|
-
* width: 800,
|
|
365
|
-
* height: 600,
|
|
366
|
-
* })
|
|
367
|
-
*
|
|
368
|
-
* t.draw(() => {
|
|
369
|
-
* t.background(0);
|
|
370
|
-
*
|
|
371
|
-
* t.push(); // Save current state
|
|
372
|
-
* t.charColor(0, 255, 0); // Green characters
|
|
373
|
-
* t.char('█');
|
|
374
|
-
* t.rect(5, 5, 3, 3);
|
|
375
|
-
* t.pop(); // Restore previous state
|
|
376
|
-
* });
|
|
377
|
-
* ```
|
|
378
|
-
*/
|
|
379
|
-
pop(): void;
|
|
380
|
-
/**
|
|
381
|
-
* Draw a rectangle with the current settings.
|
|
382
|
-
* @param x X-coordinate of the rectangle *(top-left corner)*
|
|
383
|
-
* @param y Y-coordinate of the rectangle *(top-left corner)*
|
|
384
|
-
* @param width Width of the rectangle
|
|
385
|
-
* @param height Height of the rectangle
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* ```javascript
|
|
389
|
-
* const t = textmode.create({
|
|
390
|
-
* width: 800,
|
|
391
|
-
* height: 600,
|
|
392
|
-
* })
|
|
393
|
-
*
|
|
394
|
-
* t.draw(() => {
|
|
395
|
-
* // Set the background color to black
|
|
396
|
-
* t.background(0);
|
|
397
|
-
*
|
|
398
|
-
* // Draw a filled rectangle with default character
|
|
399
|
-
* t.char('█');
|
|
400
|
-
* t.charColor(255, 255, 255); // White
|
|
401
|
-
* t.rect(10, 10, 15, 8);
|
|
402
|
-
* });
|
|
403
|
-
* ```
|
|
404
|
-
*/
|
|
405
|
-
rect(x: number, y: number, width?: number, height?: number): void;
|
|
406
|
-
/**
|
|
407
|
-
* Draw a single point at (x, y) with the current settings.
|
|
408
|
-
* @param x X-coordinate of the point
|
|
409
|
-
* @param y Y-coordinate of the point
|
|
410
|
-
*
|
|
411
|
-
* @example
|
|
412
|
-
* ```javascript
|
|
413
|
-
* const t = textmode.create({
|
|
414
|
-
* width: 800,
|
|
415
|
-
* height: 600,
|
|
416
|
-
* })
|
|
417
|
-
*
|
|
418
|
-
* t.draw(() => {
|
|
419
|
-
* t.background(0);
|
|
420
|
-
*
|
|
421
|
-
* t.char('*');
|
|
422
|
-
* t.point(10, 10);
|
|
423
|
-
* });
|
|
424
|
-
* ```
|
|
425
|
-
*/
|
|
426
|
-
point(x: number, y: number): void;
|
|
427
|
-
/**
|
|
428
|
-
* Draw a line from point (x1, y1) to point (x2, y2) with the settings.
|
|
429
|
-
* @param x1 X-coordinate of the line start point
|
|
430
|
-
* @param y1 Y-coordinate of the line start point
|
|
431
|
-
* @param x2 X-coordinate of the line end point
|
|
432
|
-
* @param y2 Y-coordinate of the line end point
|
|
433
|
-
*
|
|
434
|
-
* @example
|
|
435
|
-
* ```javascript
|
|
436
|
-
* const t = textmode.create({
|
|
437
|
-
* width: 800,
|
|
438
|
-
* height: 600,
|
|
439
|
-
* })
|
|
440
|
-
*
|
|
441
|
-
* t.draw(() => {
|
|
442
|
-
* // Set the background color to black
|
|
443
|
-
* t.background(0);
|
|
444
|
-
*
|
|
445
|
-
* // Draw a diagonal line
|
|
446
|
-
* t.char('-');
|
|
447
|
-
* t.charColor(0, 255, 255); // Cyan
|
|
448
|
-
* t.lineWeight(1);
|
|
449
|
-
* t.line(5, 5, 25, 15);
|
|
450
|
-
* });
|
|
451
|
-
* ```
|
|
452
|
-
*/
|
|
453
|
-
line(x1: number, y1: number, x2: number, y2: number): void;
|
|
454
|
-
/**
|
|
455
|
-
* Set the background color for the canvas.
|
|
456
|
-
* @param r Red component (0-255)
|
|
457
|
-
* @param g Green component (0-255)
|
|
458
|
-
* @param b Blue component (0-255)
|
|
459
|
-
* @param a Alpha component (0-255)
|
|
460
|
-
*
|
|
461
|
-
* @example
|
|
462
|
-
* ```javascript
|
|
463
|
-
* const t = textmode.create({
|
|
464
|
-
* width: 800,
|
|
465
|
-
* height: 600,
|
|
466
|
-
* })
|
|
467
|
-
*
|
|
468
|
-
* t.draw(() => {
|
|
469
|
-
* // Set the background color to white
|
|
470
|
-
* t.background(255);
|
|
471
|
-
* });
|
|
472
|
-
* ```
|
|
473
|
-
*/
|
|
474
|
-
background(r: number, g?: number, b?: number, a?: number): void;
|
|
475
|
-
/**
|
|
476
|
-
* Clear the canvas.
|
|
477
|
-
*
|
|
478
|
-
* @example
|
|
479
|
-
* ```javascript
|
|
480
|
-
* const t = textmode.create({
|
|
481
|
-
* width: 800,
|
|
482
|
-
* height: 600,
|
|
483
|
-
* })
|
|
484
|
-
*
|
|
485
|
-
* t.draw(() => {
|
|
486
|
-
* // Clear the canvas
|
|
487
|
-
* t.clear();
|
|
488
|
-
* });
|
|
489
|
-
* ```
|
|
490
|
-
*/
|
|
491
|
-
clear(): void;
|
|
492
|
-
/**
|
|
493
|
-
* Update the line weight (thickness) for subsequent {@link line} and {@link bezierCurve} calls.
|
|
494
|
-
* @param weight The line weight (thickness) to set.
|
|
495
|
-
*
|
|
496
|
-
* @example
|
|
497
|
-
* ```javascript
|
|
498
|
-
* const t = textmode.create({
|
|
499
|
-
* width: 800,
|
|
500
|
-
* height: 600,
|
|
501
|
-
* })
|
|
502
|
-
*
|
|
503
|
-
* t.draw(() => {
|
|
504
|
-
* t.background(0);
|
|
505
|
-
* t.lineWeight(1); // Thin line
|
|
506
|
-
* t.line(0, 0, t.grid.cols, t.grid.rows);
|
|
507
|
-
* });
|
|
508
|
-
* ```
|
|
509
|
-
*/
|
|
510
|
-
lineWeight(weight: number): void;
|
|
511
|
-
/**
|
|
512
|
-
* Draw a smooth cubic bezier curve between two points with two control points.
|
|
513
|
-
* The curve thickness is controlled by the current {@link lineWeight} setting.
|
|
514
|
-
* @param x1 Start point X coordinate
|
|
515
|
-
* @param y1 Start point Y coordinate
|
|
516
|
-
* @param cp1x First control point X coordinate
|
|
517
|
-
* @param cp1y First control point Y coordinate
|
|
518
|
-
* @param cp2x Second control point X coordinate
|
|
519
|
-
* @param cp2y Second control point Y coordinate
|
|
520
|
-
* @param x2 End point X coordinate
|
|
521
|
-
* @param y2 End point Y coordinate
|
|
522
|
-
*
|
|
523
|
-
* @example
|
|
524
|
-
* ```javascript
|
|
525
|
-
* const t = textmode.create({
|
|
526
|
-
* width: 800,
|
|
527
|
-
* height: 600,
|
|
528
|
-
* })
|
|
529
|
-
*
|
|
530
|
-
* t.draw(() => {
|
|
531
|
-
* t.background(0);
|
|
532
|
-
*
|
|
533
|
-
* // Draw a smooth S-curve
|
|
534
|
-
* t.char('*');
|
|
535
|
-
* t.charColor(255, 100, 255); // Magenta
|
|
536
|
-
* t.lineWeight(2);
|
|
537
|
-
* t.bezierCurve(5, 20, 15, 5, 25, 35, 35, 20);
|
|
538
|
-
* });
|
|
539
|
-
* ```
|
|
540
|
-
*/
|
|
541
|
-
bezierCurve(x1: number, y1: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): void;
|
|
542
|
-
/**
|
|
543
|
-
* Set the character to be used for subsequent rendering operations.
|
|
544
|
-
* @param character The character to set
|
|
545
|
-
*
|
|
546
|
-
* @example
|
|
547
|
-
* ```javascript
|
|
548
|
-
* const t = textmode.create({
|
|
549
|
-
* width: 800,
|
|
550
|
-
* height: 600,
|
|
551
|
-
* })
|
|
552
|
-
*
|
|
553
|
-
* t.draw(() => {
|
|
554
|
-
* t.background(0);
|
|
555
|
-
* t.char('█');
|
|
556
|
-
* t.rect(10, 10, 5, 5);
|
|
557
|
-
* });
|
|
558
|
-
* ```
|
|
559
|
-
*/
|
|
560
|
-
char(character: string): void;
|
|
561
|
-
/**
|
|
562
|
-
* Set the character color for subsequent rendering operations.
|
|
563
|
-
* @param r Red component (0-255)
|
|
564
|
-
* @param g Green component (0-255)
|
|
565
|
-
* @param b Blue component (0-255)
|
|
566
|
-
* @param a Alpha component (0-255, optional, defaults to 255)
|
|
567
|
-
*
|
|
568
|
-
* @example
|
|
569
|
-
* ```javascript
|
|
570
|
-
* const t = textmode.create({
|
|
571
|
-
* width: 800,
|
|
572
|
-
* height: 600,
|
|
573
|
-
* })
|
|
574
|
-
*
|
|
575
|
-
* t.draw(() => {
|
|
576
|
-
* t.background(0);
|
|
577
|
-
* t.charColor(255, 0, 0, 255); // Red character
|
|
578
|
-
* t.rect(10, 10, 5, 5);
|
|
579
|
-
* });
|
|
580
|
-
* ```
|
|
581
|
-
*/
|
|
582
|
-
charColor(r: number, g: number, b: number, a?: number): void;
|
|
583
|
-
/**
|
|
584
|
-
* Set the cell background color for subsequent rendering operations.
|
|
585
|
-
* @param r Red component (0-255)
|
|
586
|
-
* @param g Green component (0-255)
|
|
587
|
-
* @param b Blue component (0-255)
|
|
588
|
-
* @param a Alpha component (0-255, optional, defaults to 255)
|
|
589
|
-
*
|
|
590
|
-
* @example
|
|
591
|
-
* ```javascript
|
|
592
|
-
* const t = textmode.create({
|
|
593
|
-
* width: 800,
|
|
594
|
-
* height: 600,
|
|
595
|
-
* })
|
|
596
|
-
*
|
|
597
|
-
* t.draw(() => {
|
|
598
|
-
* t.background(0);
|
|
599
|
-
* t.cellColor(0, 255, 0, 255); // Green cell background
|
|
600
|
-
* t.rect(10, 10, 5, 5);
|
|
601
|
-
* });
|
|
602
|
-
* ```
|
|
603
|
-
*/
|
|
604
|
-
cellColor(r: number, g: number, b: number, a: number): void;
|
|
605
|
-
/**
|
|
606
|
-
* Toggle horizontal flipping for subsequent character rendering.
|
|
607
|
-
* @param toggle Whether to flip horizontally
|
|
608
|
-
*
|
|
609
|
-
* @example
|
|
610
|
-
* ```javascript
|
|
611
|
-
* const t = textmode.create({
|
|
612
|
-
* width: 800,
|
|
613
|
-
* height: 600,
|
|
614
|
-
* })
|
|
615
|
-
*
|
|
616
|
-
* t.draw(() => {
|
|
617
|
-
* t.background(0);
|
|
618
|
-
* t.flipX(true);
|
|
619
|
-
* t.rect(10, 10, 5, 5);
|
|
620
|
-
* });
|
|
621
|
-
* ```
|
|
622
|
-
*/
|
|
623
|
-
flipX(toggle: boolean): void;
|
|
624
|
-
/**
|
|
625
|
-
* Toggle vertical flipping for subsequent character rendering.
|
|
626
|
-
* @param toggle Whether to flip vertically
|
|
627
|
-
*
|
|
628
|
-
* @example
|
|
629
|
-
* ```javascript
|
|
630
|
-
* const t = textmode.create({
|
|
631
|
-
* width: 800,
|
|
632
|
-
* height: 600,
|
|
633
|
-
* })
|
|
634
|
-
*
|
|
635
|
-
* t.draw(() => {
|
|
636
|
-
* t.background(0);
|
|
637
|
-
* t.flipY(true);
|
|
638
|
-
* t.rect(10, 10, 5, 5);
|
|
639
|
-
* });
|
|
640
|
-
* ```
|
|
641
|
-
*/
|
|
642
|
-
flipY(toggle: boolean): void;
|
|
643
|
-
/**
|
|
644
|
-
* Set the character rotation angle for subsequent character rendering.
|
|
645
|
-
* @param degrees The rotation angle in degrees
|
|
646
|
-
*
|
|
647
|
-
* @example
|
|
648
|
-
* ```javascript
|
|
649
|
-
* const t = textmode.create({
|
|
650
|
-
* width: 800,
|
|
651
|
-
* height: 600,
|
|
652
|
-
* })
|
|
653
|
-
*
|
|
654
|
-
* t.draw(() => {
|
|
655
|
-
* t.background(0);
|
|
656
|
-
* t.charRotation(90); // Rotate character 90 degrees
|
|
657
|
-
* t.rect(10, 10, 5, 5);
|
|
658
|
-
* });
|
|
659
|
-
* ```
|
|
660
|
-
*/
|
|
661
|
-
charRotation(degrees: number): void;
|
|
662
|
-
/**
|
|
663
|
-
* Toggle color inversion for subsequent character rendering.
|
|
664
|
-
* @param toggle Whether to invert colors
|
|
665
|
-
*
|
|
666
|
-
* @example
|
|
667
|
-
* ```javascript
|
|
668
|
-
* const t = textmode.create({
|
|
669
|
-
* width: 800,
|
|
670
|
-
* height: 600,
|
|
671
|
-
* })
|
|
672
|
-
*
|
|
673
|
-
* t.draw(() => {
|
|
674
|
-
* t.background(0);
|
|
675
|
-
* t.invert(true);
|
|
676
|
-
* t.rect(10, 10, 5, 5);
|
|
677
|
-
* });
|
|
678
|
-
* ```
|
|
679
|
-
*/
|
|
680
|
-
invert(toggle: boolean): void;
|
|
681
|
-
/**
|
|
682
|
-
* Draw an ellipse with the current settings.
|
|
683
|
-
* @param x X-coordinate of the ellipse center
|
|
684
|
-
* @param y Y-coordinate of the ellipse center
|
|
685
|
-
* @param width Width of the ellipse
|
|
686
|
-
* @param height Height of the ellipse
|
|
687
|
-
*
|
|
688
|
-
* @example
|
|
689
|
-
* ```javascript
|
|
690
|
-
* const t = textmode.create({
|
|
691
|
-
* width: 800,
|
|
692
|
-
* height: 600,
|
|
693
|
-
* })
|
|
694
|
-
*
|
|
695
|
-
* t.draw(() => {
|
|
696
|
-
* t.background(0);
|
|
697
|
-
* t.ellipse(20, 15, 10, 8);
|
|
698
|
-
* });
|
|
699
|
-
* ```
|
|
700
|
-
*/
|
|
701
|
-
ellipse(x: number, y: number, width: number, height: number): void;
|
|
702
|
-
/**
|
|
703
|
-
* Draw a triangle with the current settings.
|
|
704
|
-
* @param x1 X-coordinate of the first vertex
|
|
705
|
-
* @param y1 Y-coordinate of the first vertex
|
|
706
|
-
* @param x2 X-coordinate of the second vertex
|
|
707
|
-
* @param y2 Y-coordinate of the second vertex
|
|
708
|
-
* @param x3 X-coordinate of the third vertex
|
|
709
|
-
* @param y3 Y-coordinate of the third vertex
|
|
710
|
-
*
|
|
711
|
-
* @example
|
|
712
|
-
* ```javascript
|
|
713
|
-
* const t = textmode.create({
|
|
714
|
-
* width: 800,
|
|
715
|
-
* height: 600,
|
|
716
|
-
* })
|
|
717
|
-
*
|
|
718
|
-
* t.draw(() => {
|
|
719
|
-
* t.background(0);
|
|
720
|
-
* t.triangle(10, 10, 20, 10, 15, 20);
|
|
721
|
-
* });
|
|
722
|
-
* ```
|
|
723
|
-
*/
|
|
724
|
-
triangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
|
|
725
|
-
/**
|
|
726
|
-
* Draw an arc with the current settings.
|
|
727
|
-
* @param x X-coordinate of the arc center
|
|
728
|
-
* @param y Y-coordinate of the arc center
|
|
729
|
-
* @param width Width of the arc
|
|
730
|
-
* @param height Height of the arc
|
|
731
|
-
* @param startAngle Starting angle in radians
|
|
732
|
-
* @param endAngle Ending angle in radians
|
|
733
|
-
*
|
|
734
|
-
* @example
|
|
735
|
-
* ```javascript
|
|
736
|
-
* const t = textmode.create({
|
|
737
|
-
* width: 800,
|
|
738
|
-
* height: 600,
|
|
739
|
-
* })
|
|
740
|
-
*
|
|
741
|
-
* t.draw(() => {
|
|
742
|
-
* t.background(0);
|
|
743
|
-
* t.arc(20, 15, 10, 10, 0, Math.PI);
|
|
744
|
-
* });
|
|
745
|
-
* ```
|
|
746
|
-
*/
|
|
747
|
-
arc(x: number, y: number, width: number, height: number, startAngle: number, endAngle: number): void;
|
|
748
|
-
}
|
|
2
|
+
import type { IRenderingMixin } from './interfaces/IRenderingMixin';
|
|
749
3
|
/**
|
|
750
4
|
* Mixin that adds rendering capabilities to a class by delegating to GLRenderer
|
|
751
5
|
* @param Base The base class to extend
|
|
752
6
|
* @returns Extended class with rendering capabilities
|
|
753
7
|
*/
|
|
754
|
-
export declare const RenderingMixin: Mixin<
|
|
755
|
-
export {};
|
|
8
|
+
export declare const RenderingMixin: Mixin<IRenderingMixin>;
|