textmode.js 0.7.0 → 0.7.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -60
- package/dist/textmode.esm.js +819 -814
- package/dist/textmode.umd.js +15 -16
- package/dist/types/textmode/layers/Layer2DCompositor.d.ts +19 -7
- package/dist/types/textmode/layers/TextmodeLayer.d.ts +3 -0
- package/dist/types/textmode/layers/interfaces/ITextmodeLayer.d.ts +32 -0
- package/dist/types/textmode/layers/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { GLRenderer, GLFramebuffer } from '../../rendering';
|
|
2
|
-
import type { TextmodeGrid } from '../Grid';
|
|
3
2
|
import type { TextmodeLayer } from './TextmodeLayer';
|
|
4
3
|
/**
|
|
5
4
|
* Parameters for the composite operation.
|
|
@@ -15,6 +14,18 @@ export interface CompositeParams {
|
|
|
15
14
|
baseLayer: TextmodeLayer;
|
|
16
15
|
/** The array of user layers to composite on top of the base. */
|
|
17
16
|
layers: readonly TextmodeLayer[];
|
|
17
|
+
/** Canvas width in pixels. */
|
|
18
|
+
canvasWidth: number;
|
|
19
|
+
/** Canvas height in pixels. */
|
|
20
|
+
canvasHeight: number;
|
|
21
|
+
/** Grid width in pixels (layer size). */
|
|
22
|
+
gridWidth: number;
|
|
23
|
+
/** Grid height in pixels (layer size). */
|
|
24
|
+
gridHeight: number;
|
|
25
|
+
/** X offset to center the grid within the canvas. */
|
|
26
|
+
baseOffsetX: number;
|
|
27
|
+
/** Y offset to center the grid within the canvas. */
|
|
28
|
+
baseOffsetY: number;
|
|
18
29
|
}
|
|
19
30
|
/**
|
|
20
31
|
* Handles the compositing of multiple layers using shader-based blending.
|
|
@@ -42,16 +53,16 @@ export declare class Layer2DCompositor {
|
|
|
42
53
|
constructor(renderer: GLRenderer);
|
|
43
54
|
/**
|
|
44
55
|
* Initialize the compositor's framebuffers.
|
|
45
|
-
* @param
|
|
56
|
+
* @param canvasWidth The canvas width in pixels.
|
|
57
|
+
* @param canvasHeight The canvas height in pixels.
|
|
46
58
|
* @ignore
|
|
47
59
|
*/
|
|
48
|
-
$initialize(
|
|
60
|
+
$initialize(canvasWidth: number, canvasHeight: number): void;
|
|
49
61
|
/**
|
|
50
62
|
* Composite all layers onto the target framebuffer.
|
|
51
63
|
* @param params The composite parameters.
|
|
52
|
-
* @param grid The grid defining render dimensions.
|
|
53
64
|
*/
|
|
54
|
-
$composite(params: CompositeParams
|
|
65
|
+
$composite(params: CompositeParams): void;
|
|
55
66
|
/**
|
|
56
67
|
* Blend a single layer onto the current composite.
|
|
57
68
|
*/
|
|
@@ -62,10 +73,11 @@ export declare class Layer2DCompositor {
|
|
|
62
73
|
private _copyToTarget;
|
|
63
74
|
/**
|
|
64
75
|
* Resize the compositor's framebuffers.
|
|
65
|
-
* @param
|
|
76
|
+
* @param canvasWidth The canvas width in pixels.
|
|
77
|
+
* @param canvasHeight The canvas height in pixels.
|
|
66
78
|
* @ignore
|
|
67
79
|
*/
|
|
68
|
-
$resize(
|
|
80
|
+
$resize(canvasWidth: number, canvasHeight: number): void;
|
|
69
81
|
/**
|
|
70
82
|
* Dispose of all compositor resources.
|
|
71
83
|
* @ignore
|
|
@@ -25,6 +25,8 @@ export declare class TextmodeLayer implements ITextmodeLayer {
|
|
|
25
25
|
$offsetX: number;
|
|
26
26
|
/** @ignore */
|
|
27
27
|
$offsetY: number;
|
|
28
|
+
/** @ignore */
|
|
29
|
+
$rotation: number;
|
|
28
30
|
private _deps?;
|
|
29
31
|
private _drawFramebuffer?;
|
|
30
32
|
private _asciiFramebuffer?;
|
|
@@ -66,6 +68,7 @@ export declare class TextmodeLayer implements ITextmodeLayer {
|
|
|
66
68
|
x: number;
|
|
67
69
|
y: number;
|
|
68
70
|
} | void;
|
|
71
|
+
rotateZ(z?: number): number | void;
|
|
69
72
|
filter<T extends BuiltInFilterName>(name: T, params?: BuiltInFilterParams[T]): void;
|
|
70
73
|
filter(name: FilterName, params?: unknown): void;
|
|
71
74
|
/**
|
|
@@ -269,6 +269,38 @@ export interface ITextmodeLayer {
|
|
|
269
269
|
x: number;
|
|
270
270
|
y: number;
|
|
271
271
|
} | void;
|
|
272
|
+
/**
|
|
273
|
+
* Set or get the layer's rotation in degrees around its center.
|
|
274
|
+
*
|
|
275
|
+
* The rotation is applied during compositing around the center of the layer's
|
|
276
|
+
* rectangular bounds. The rotation origin remains at the center even when
|
|
277
|
+
* an offset is applied.
|
|
278
|
+
*
|
|
279
|
+
* @param z The rotation angle in degrees. Positive values rotate clockwise.
|
|
280
|
+
* @returns The current rotation in degrees if no parameter is provided.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const t = textmode.create();
|
|
285
|
+
*
|
|
286
|
+
* const rotatingLayer = t.layers.add({ blendMode: 'normal', opacity: 1.0 });
|
|
287
|
+
*
|
|
288
|
+
* rotatingLayer.draw(() => {
|
|
289
|
+
* t.clear();
|
|
290
|
+
* t.charColor(255, 200, 100);
|
|
291
|
+
* t.char('#');
|
|
292
|
+
* t.rect(10, 5);
|
|
293
|
+
* });
|
|
294
|
+
*
|
|
295
|
+
* t.draw(() => {
|
|
296
|
+
* t.background(20, 20, 40);
|
|
297
|
+
*
|
|
298
|
+
* // Rotate the layer over time
|
|
299
|
+
* rotatingLayer.rotate(t.frameCount * 2);
|
|
300
|
+
* });
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
rotateZ(z?: number): number | void;
|
|
272
304
|
/**
|
|
273
305
|
* Apply a post-processing filter to this layer's rendered output.
|
|
274
306
|
*
|
|
@@ -46,6 +46,10 @@ export interface TextmodeLayerOptions {
|
|
|
46
46
|
* The vertical offset of the layer in pixels. Default is `0`.
|
|
47
47
|
*/
|
|
48
48
|
offsetY?: number;
|
|
49
|
+
/**
|
|
50
|
+
* The rotation of the layer in degrees around its center. Default is `0`.
|
|
51
|
+
*/
|
|
52
|
+
rotation?: number;
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Dependencies required by a TextmodeLayer to function.
|
package/package.json
CHANGED