@nmmty/lazycanvas 0.6.5 → 1.0.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReadMe.md +1 -1
- package/biome.json +41 -0
- package/dist/core/Interpolation.d.ts +30 -0
- package/dist/core/Interpolation.js +200 -0
- package/dist/core/Scene.d.ts +96 -0
- package/dist/core/Scene.js +172 -0
- package/dist/core/Signal.d.ts +133 -0
- package/dist/core/Signal.js +255 -0
- package/dist/core/SignalUtils.d.ts +133 -0
- package/dist/core/SignalUtils.js +333 -0
- package/dist/core/ThreadScheduler.d.ts +38 -0
- package/dist/core/ThreadScheduler.js +74 -0
- package/dist/helpers/Filters.js +1 -1
- package/dist/helpers/FontsList.js +18 -18
- package/dist/helpers/Utlis.d.ts +3 -3
- package/dist/helpers/Utlis.js +15 -18
- package/dist/helpers/index.d.ts +3 -3
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/jsx-runtime.d.ts +17 -0
- package/dist/jsx-runtime.js +111 -0
- package/dist/structures/LazyCanvas.d.ts +3 -45
- package/dist/structures/LazyCanvas.js +11 -74
- package/dist/structures/components/BaseLayer.d.ts +34 -12
- package/dist/structures/components/BaseLayer.js +68 -35
- package/dist/structures/components/BezierLayer.d.ts +16 -37
- package/dist/structures/components/BezierLayer.js +83 -46
- package/dist/structures/components/{Group.d.ts → Div.d.ts} +22 -16
- package/dist/structures/components/{Group.js → Div.js} +38 -39
- package/dist/structures/components/ImageLayer.d.ts +1 -1
- package/dist/structures/components/ImageLayer.js +24 -25
- package/dist/structures/components/LineLayer.d.ts +11 -37
- package/dist/structures/components/LineLayer.js +42 -42
- package/dist/structures/components/MorphLayer.d.ts +3 -32
- package/dist/structures/components/MorphLayer.js +32 -46
- package/dist/structures/components/Path2DLayer.d.ts +4 -32
- package/dist/structures/components/Path2DLayer.js +28 -33
- package/dist/structures/components/PolygonLayer.d.ts +2 -31
- package/dist/structures/components/PolygonLayer.js +35 -38
- package/dist/structures/components/QuadraticLayer.d.ts +16 -33
- package/dist/structures/components/QuadraticLayer.js +80 -42
- package/dist/structures/components/TextLayer.d.ts +4 -33
- package/dist/structures/components/TextLayer.js +60 -62
- package/dist/structures/components/index.d.ts +10 -11
- package/dist/structures/components/index.js +1 -2
- package/dist/structures/helpers/Exporter.d.ts +13 -4
- package/dist/structures/helpers/Exporter.js +79 -42
- package/dist/structures/helpers/Font.js +1 -17
- package/dist/structures/helpers/Gradient.js +32 -45
- package/dist/structures/helpers/Link.js +2 -14
- package/dist/structures/helpers/Pattern.js +9 -17
- package/dist/structures/helpers/index.d.ts +7 -7
- package/dist/structures/helpers/readers/JSONReader.d.ts +4 -4
- package/dist/structures/helpers/readers/JSONReader.js +32 -40
- package/dist/structures/helpers/readers/YAMLReader.js +5 -5
- package/dist/structures/managers/FontsManager.js +9 -18
- package/dist/structures/managers/LayersManager.d.ts +18 -28
- package/dist/structures/managers/LayersManager.js +14 -36
- package/dist/structures/managers/RenderManager.d.ts +1 -15
- package/dist/structures/managers/RenderManager.js +17 -110
- package/dist/structures/managers/index.d.ts +3 -5
- package/dist/structures/managers/index.js +0 -2
- package/dist/types/enum.d.ts +1 -2
- package/dist/types/enum.js +1 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/APNGEncoder.d.ts +67 -0
- package/dist/utils/APNGEncoder.js +205 -0
- package/dist/utils/DrawUtils.d.ts +9 -0
- package/dist/utils/DrawUtils.js +42 -0
- package/dist/utils/LazyUtil.js +1 -2
- package/dist/utils/utils.d.ts +4 -7
- package/dist/utils/utils.js +133 -76
- package/package.json +62 -59
- package/dist/structures/components/ClearLayer.d.ts +0 -147
- package/dist/structures/components/ClearLayer.js +0 -158
- package/dist/structures/managers/AnimationManager.d.ts +0 -120
- package/dist/structures/managers/AnimationManager.js +0 -99
- package/dist/structures/managers/PluginManager.d.ts +0 -230
- package/dist/structures/managers/PluginManager.js +0 -182
- package/dist/types/types.d.ts +0 -107
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { ScaleType, LayerType, AnyCentring, AnyGlobalCompositeOperation } from "../../types";
|
|
2
|
-
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
|
|
3
|
-
import { LayersManager } from "../managers";
|
|
4
|
-
import { IBaseLayerMisc } from "./BaseLayer";
|
|
5
|
-
/**
|
|
6
|
-
* Interface representing a Clear Layer.
|
|
7
|
-
*/
|
|
8
|
-
export interface IClearLayer {
|
|
9
|
-
/**
|
|
10
|
-
* The unique identifier of the layer.
|
|
11
|
-
*/
|
|
12
|
-
id: string;
|
|
13
|
-
/**
|
|
14
|
-
* The type of the layer, which is `Clear`.
|
|
15
|
-
*/
|
|
16
|
-
type: LayerType.Clear;
|
|
17
|
-
/**
|
|
18
|
-
* The z-index of the layer, determining its stacking order.
|
|
19
|
-
*/
|
|
20
|
-
zIndex: number;
|
|
21
|
-
/**
|
|
22
|
-
* The visibility of the layer.
|
|
23
|
-
*/
|
|
24
|
-
visible: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* The properties of the Clear Layer.
|
|
27
|
-
*/
|
|
28
|
-
props: IClearLayerProps;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Interface representing the properties of a Clear Layer.
|
|
32
|
-
*/
|
|
33
|
-
export interface IClearLayerProps {
|
|
34
|
-
/**
|
|
35
|
-
* The x-coordinate of the layer.
|
|
36
|
-
*/
|
|
37
|
-
x: ScaleType;
|
|
38
|
-
/**
|
|
39
|
-
* The y-coordinate of the layer.
|
|
40
|
-
*/
|
|
41
|
-
y: ScaleType;
|
|
42
|
-
/**
|
|
43
|
-
* The size of the layer, including width and height.
|
|
44
|
-
*/
|
|
45
|
-
size: {
|
|
46
|
-
/**
|
|
47
|
-
* The width of the layer.
|
|
48
|
-
*/
|
|
49
|
-
width: ScaleType;
|
|
50
|
-
/**
|
|
51
|
-
* The height of the layer.
|
|
52
|
-
*/
|
|
53
|
-
height: ScaleType;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* The centring type of the layer.
|
|
57
|
-
*/
|
|
58
|
-
centring: AnyCentring;
|
|
59
|
-
/**
|
|
60
|
-
* Don't use, this is just for compatibility.
|
|
61
|
-
*/
|
|
62
|
-
globalComposite: AnyGlobalCompositeOperation;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Class representing a Clear Layer.
|
|
66
|
-
*/
|
|
67
|
-
export declare class ClearLayer implements IClearLayer {
|
|
68
|
-
/**
|
|
69
|
-
* The unique identifier of the layer.
|
|
70
|
-
*/
|
|
71
|
-
id: string;
|
|
72
|
-
/**
|
|
73
|
-
* The type of the layer, which is `Clear`.
|
|
74
|
-
*/
|
|
75
|
-
type: LayerType.Clear;
|
|
76
|
-
/**
|
|
77
|
-
* The z-index of the layer, determining its stacking order.
|
|
78
|
-
*/
|
|
79
|
-
zIndex: number;
|
|
80
|
-
/**
|
|
81
|
-
* The visibility of the layer.
|
|
82
|
-
*/
|
|
83
|
-
visible: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* The properties of the Clear Layer.
|
|
86
|
-
*/
|
|
87
|
-
props: IClearLayerProps;
|
|
88
|
-
/**
|
|
89
|
-
* Constructs a new ClearLayer instance.
|
|
90
|
-
* @param {IClearLayerProps} [props] - The properties of the Clear Layer.
|
|
91
|
-
* @param {IBaseLayerMisc} [misc] - Miscellaneous options for the layer.
|
|
92
|
-
*/
|
|
93
|
-
constructor(props?: IClearLayerProps, misc?: IBaseLayerMisc);
|
|
94
|
-
/**
|
|
95
|
-
* Sets the position of the layer in the 2D plane.
|
|
96
|
-
* @param {ScaleType} [x] - The x-coordinate of the layer.
|
|
97
|
-
* @param {ScaleType} [y] - The y-coordinate of the layer.
|
|
98
|
-
* @returns {this} The current instance for chaining.
|
|
99
|
-
*/
|
|
100
|
-
setPosition(x: ScaleType, y: ScaleType): this;
|
|
101
|
-
/**
|
|
102
|
-
* Sets the size of the layer.
|
|
103
|
-
* @param {ScaleType} [width] - The width of the layer.
|
|
104
|
-
* @param {ScaleType} [height] - The height of the layer.
|
|
105
|
-
* @returns {this} The current instance for chaining.
|
|
106
|
-
*/
|
|
107
|
-
setSize(width: ScaleType, height: ScaleType): this;
|
|
108
|
-
/**
|
|
109
|
-
* Sets the unique identifier of the layer.
|
|
110
|
-
*
|
|
111
|
-
* @param {string} [id] - The unique identifier.
|
|
112
|
-
* @returns {this} The current instance for chaining.
|
|
113
|
-
*/
|
|
114
|
-
setID(id: string): this;
|
|
115
|
-
/**
|
|
116
|
-
* Sets the centring type of the layer.
|
|
117
|
-
* @param {AnyCentring} [centring] - The centring type of the layer.
|
|
118
|
-
* @returns {this} The current instance for chaining.
|
|
119
|
-
*/
|
|
120
|
-
setCentring(centring: AnyCentring): this;
|
|
121
|
-
/**
|
|
122
|
-
* Sets the visibility of the layer.
|
|
123
|
-
* @param {boolean} [visible] - The visibility state of the layer.
|
|
124
|
-
* @returns {this} The current instance for chaining.
|
|
125
|
-
*/
|
|
126
|
-
setVisible(visible: boolean): this;
|
|
127
|
-
/**
|
|
128
|
-
* Sets the z-index of the layer.
|
|
129
|
-
* @param {number} [zIndex] - The z-index value of the layer.
|
|
130
|
-
* @returns {this} The current instance for chaining.
|
|
131
|
-
*/
|
|
132
|
-
setZIndex(zIndex: number): this;
|
|
133
|
-
/**
|
|
134
|
-
* Draws the Clear Layer on the canvas.
|
|
135
|
-
* @param {SKRSContext2D} [ctx] - The canvas rendering context.
|
|
136
|
-
* @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
|
|
137
|
-
* @param {LayersManager} [manager] - The layer's manager.
|
|
138
|
-
* @param {boolean} [debug] - Whether to enable debug logging.
|
|
139
|
-
*/
|
|
140
|
-
draw(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager, debug: boolean): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* Converts the Clear Layer to a JSON representation.
|
|
143
|
-
* @returns {IClearLayer} The JSON representation of the Clear Layer.
|
|
144
|
-
*/
|
|
145
|
-
toJSON(): IClearLayer;
|
|
146
|
-
protected validateProps(props: IClearLayerProps): IClearLayerProps;
|
|
147
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClearLayer = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
|
-
const utils_1 = require("../../utils/utils");
|
|
6
|
-
const LazyUtil_1 = require("../../utils/LazyUtil");
|
|
7
|
-
const utils_2 = require("../../utils/utils");
|
|
8
|
-
/**
|
|
9
|
-
* Class representing a Clear Layer.
|
|
10
|
-
*/
|
|
11
|
-
class ClearLayer {
|
|
12
|
-
/**
|
|
13
|
-
* The unique identifier of the layer.
|
|
14
|
-
*/
|
|
15
|
-
id;
|
|
16
|
-
/**
|
|
17
|
-
* The type of the layer, which is `Clear`.
|
|
18
|
-
*/
|
|
19
|
-
type = types_1.LayerType.Clear;
|
|
20
|
-
/**
|
|
21
|
-
* The z-index of the layer, determining its stacking order.
|
|
22
|
-
*/
|
|
23
|
-
zIndex;
|
|
24
|
-
/**
|
|
25
|
-
* The visibility of the layer.
|
|
26
|
-
*/
|
|
27
|
-
visible;
|
|
28
|
-
/**
|
|
29
|
-
* The properties of the Clear Layer.
|
|
30
|
-
*/
|
|
31
|
-
props;
|
|
32
|
-
/**
|
|
33
|
-
* Constructs a new ClearLayer instance.
|
|
34
|
-
* @param {IClearLayerProps} [props] - The properties of the Clear Layer.
|
|
35
|
-
* @param {IBaseLayerMisc} [misc] - Miscellaneous options for the layer.
|
|
36
|
-
*/
|
|
37
|
-
constructor(props, misc) {
|
|
38
|
-
this.id = misc?.id || (0, utils_2.generateID)(types_1.LayerType.Clear);
|
|
39
|
-
this.type = types_1.LayerType.Clear;
|
|
40
|
-
this.zIndex = misc?.zIndex || 1;
|
|
41
|
-
this.visible = misc?.visible || true;
|
|
42
|
-
this.props = props ? props : {};
|
|
43
|
-
this.props = this.validateProps(this.props);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Sets the position of the layer in the 2D plane.
|
|
47
|
-
* @param {ScaleType} [x] - The x-coordinate of the layer.
|
|
48
|
-
* @param {ScaleType} [y] - The y-coordinate of the layer.
|
|
49
|
-
* @returns {this} The current instance for chaining.
|
|
50
|
-
*/
|
|
51
|
-
setPosition(x, y) {
|
|
52
|
-
this.props.x = x;
|
|
53
|
-
this.props.y = y;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Sets the size of the layer.
|
|
58
|
-
* @param {ScaleType} [width] - The width of the layer.
|
|
59
|
-
* @param {ScaleType} [height] - The height of the layer.
|
|
60
|
-
* @returns {this} The current instance for chaining.
|
|
61
|
-
*/
|
|
62
|
-
setSize(width, height) {
|
|
63
|
-
this.props.size = {
|
|
64
|
-
width,
|
|
65
|
-
height
|
|
66
|
-
};
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Sets the unique identifier of the layer.
|
|
71
|
-
*
|
|
72
|
-
* @param {string} [id] - The unique identifier.
|
|
73
|
-
* @returns {this} The current instance for chaining.
|
|
74
|
-
*/
|
|
75
|
-
setID(id) {
|
|
76
|
-
this.id = id;
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Sets the centring type of the layer.
|
|
81
|
-
* @param {AnyCentring} [centring] - The centring type of the layer.
|
|
82
|
-
* @returns {this} The current instance for chaining.
|
|
83
|
-
*/
|
|
84
|
-
setCentring(centring) {
|
|
85
|
-
this.props.centring = centring;
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Sets the visibility of the layer.
|
|
90
|
-
* @param {boolean} [visible] - The visibility state of the layer.
|
|
91
|
-
* @returns {this} The current instance for chaining.
|
|
92
|
-
*/
|
|
93
|
-
setVisible(visible) {
|
|
94
|
-
this.visible = visible;
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Sets the z-index of the layer.
|
|
99
|
-
* @param {number} [zIndex] - The z-index value of the layer.
|
|
100
|
-
* @returns {this} The current instance for chaining.
|
|
101
|
-
*/
|
|
102
|
-
setZIndex(zIndex) {
|
|
103
|
-
this.zIndex = zIndex;
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Draws the Clear Layer on the canvas.
|
|
108
|
-
* @param {SKRSContext2D} [ctx] - The canvas rendering context.
|
|
109
|
-
* @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
|
|
110
|
-
* @param {LayersManager} [manager] - The layer's manager.
|
|
111
|
-
* @param {boolean} [debug] - Whether to enable debug logging.
|
|
112
|
-
*/
|
|
113
|
-
async draw(ctx, canvas, manager, debug) {
|
|
114
|
-
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
115
|
-
const { xs, ys, w } = parcer.parseBatch({
|
|
116
|
-
xs: { v: this.props.x },
|
|
117
|
-
ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
118
|
-
w: { v: this.props.size.width },
|
|
119
|
-
});
|
|
120
|
-
const h = parcer.parse(this.props.size.height, LazyUtil_1.defaultArg.wh(w), LazyUtil_1.defaultArg.vl(true));
|
|
121
|
-
let { x, y } = (0, utils_1.centring)(this.props.centring, this.type, w, h, xs, ys);
|
|
122
|
-
if (debug)
|
|
123
|
-
LazyUtil_1.LazyLog.log('none', `ClearLayer:`, { x, y, w, h });
|
|
124
|
-
ctx.clearRect(x, y, w, h);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Converts the Clear Layer to a JSON representation.
|
|
128
|
-
* @returns {IClearLayer} The JSON representation of the Clear Layer.
|
|
129
|
-
*/
|
|
130
|
-
toJSON() {
|
|
131
|
-
let copy = { ...this.props };
|
|
132
|
-
for (const key of ['x', 'y', 'size.width', 'size.height']) {
|
|
133
|
-
if (copy[key] && typeof copy[key] === 'object' && 'toJSON' in copy[key]) {
|
|
134
|
-
copy[key] = copy[key].toJSON();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
id: this.id,
|
|
139
|
-
type: this.type,
|
|
140
|
-
zIndex: this.zIndex,
|
|
141
|
-
visible: this.visible,
|
|
142
|
-
props: copy,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
validateProps(props) {
|
|
146
|
-
return {
|
|
147
|
-
x: props.x || 0,
|
|
148
|
-
y: props.y || 0,
|
|
149
|
-
size: {
|
|
150
|
-
width: props.size?.width || 0,
|
|
151
|
-
height: props.size?.height || 0
|
|
152
|
-
},
|
|
153
|
-
centring: props.centring || 'none',
|
|
154
|
-
globalComposite: props.globalComposite || 'source-over'
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
exports.ClearLayer = ClearLayer;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { AnyColorSpace } from "../../types";
|
|
2
|
-
/**
|
|
3
|
-
* Interface representing the animation manager.
|
|
4
|
-
*/
|
|
5
|
-
export interface IAnimationManager {
|
|
6
|
-
/**
|
|
7
|
-
* The options for the animation manager.
|
|
8
|
-
*/
|
|
9
|
-
options: IAnimationOptions;
|
|
10
|
-
/**
|
|
11
|
-
* Whether debugging is enabled.
|
|
12
|
-
*/
|
|
13
|
-
debug: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Interface representing the animation options.
|
|
17
|
-
*/
|
|
18
|
-
export interface IAnimationOptions {
|
|
19
|
-
/**
|
|
20
|
-
* The frame rate of the animation.
|
|
21
|
-
*/
|
|
22
|
-
frameRate: number;
|
|
23
|
-
/**
|
|
24
|
-
* The maximum number of colors in the animation.
|
|
25
|
-
*/
|
|
26
|
-
maxColors: number;
|
|
27
|
-
/**
|
|
28
|
-
* The color space used in the animation.
|
|
29
|
-
*/
|
|
30
|
-
colorSpace: AnyColorSpace;
|
|
31
|
-
/**
|
|
32
|
-
* Whether the animation should loop.
|
|
33
|
-
*/
|
|
34
|
-
loop: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Whether the animation should have transparency.
|
|
37
|
-
*/
|
|
38
|
-
transparency: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Utility options for the animation.
|
|
41
|
-
*/
|
|
42
|
-
utils: {
|
|
43
|
-
/**
|
|
44
|
-
* Whether to clear the content of previous frames.
|
|
45
|
-
*/
|
|
46
|
-
clear: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Buffer-related options.
|
|
49
|
-
*/
|
|
50
|
-
buffer: {
|
|
51
|
-
/**
|
|
52
|
-
* The size of the frame buffer.
|
|
53
|
-
*/
|
|
54
|
-
size: number;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Class representing the animation manager, which handles animation settings and options.
|
|
60
|
-
*/
|
|
61
|
-
export declare class AnimationManager implements IAnimationManager {
|
|
62
|
-
/**
|
|
63
|
-
* The options for the animation manager.
|
|
64
|
-
*/
|
|
65
|
-
options: IAnimationOptions;
|
|
66
|
-
/**
|
|
67
|
-
* Whether debugging is enabled.
|
|
68
|
-
*/
|
|
69
|
-
debug: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Constructs a new AnimationManager instance.
|
|
72
|
-
* @param {Object} [opts] - Optional settings for the animation manager.
|
|
73
|
-
* @param {boolean} [opts.debug] - Whether debugging is enabled.
|
|
74
|
-
* @param {Object} [opts.settings] - Additional settings for the animation manager.
|
|
75
|
-
* @param {IAnimationOptions} [opts.settings.options] - The animation options.
|
|
76
|
-
*/
|
|
77
|
-
constructor(opts?: {
|
|
78
|
-
debug?: boolean;
|
|
79
|
-
settings?: {
|
|
80
|
-
options?: IAnimationOptions;
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
/**
|
|
84
|
-
* Sets the frame rate of the animation.
|
|
85
|
-
* @param {number} [frameRate] - The frame rate of the animation (default is 30).
|
|
86
|
-
* @returns {this} The current instance for chaining.
|
|
87
|
-
*/
|
|
88
|
-
setFrameRate(frameRate: number): this;
|
|
89
|
-
/**
|
|
90
|
-
* Sets whether the animation should loop.
|
|
91
|
-
* @param {boolean} [loop] - Whether the animation should loop (default is true).
|
|
92
|
-
* @returns {this} The current instance for chaining.
|
|
93
|
-
*/
|
|
94
|
-
setLoop(loop: boolean): this;
|
|
95
|
-
/**
|
|
96
|
-
* Sets whether the animation should have transparency.
|
|
97
|
-
* @param {boolean} [transparency] - Whether the animation should have transparency (default is true).
|
|
98
|
-
* @returns {this} The current instance for chaining.
|
|
99
|
-
*/
|
|
100
|
-
setTransparent(transparency: boolean): this;
|
|
101
|
-
/**
|
|
102
|
-
* Sets the RGB format of the animation.
|
|
103
|
-
* @param {ColorSpace} [rgb] - The RGB format of the animation (default is RGB565).
|
|
104
|
-
* @returns {this} The current instance for chaining.
|
|
105
|
-
*/
|
|
106
|
-
setRGBFormat(rgb: AnyColorSpace): this;
|
|
107
|
-
/**
|
|
108
|
-
* Sets the maximum number of colors in the animation.
|
|
109
|
-
* @param {number} [maxColors] - The maximum number of colors (default is 256).
|
|
110
|
-
* @returns {this} The current instance for chaining.
|
|
111
|
-
*/
|
|
112
|
-
setMaxColors(maxColors: number): this;
|
|
113
|
-
/**
|
|
114
|
-
* Sets whether the content of previous frames will be cleared.
|
|
115
|
-
* @param {boolean} [clear] - Whether to clear the content of previous frames (default is true).
|
|
116
|
-
* @param {number} [bufferSize] - The size of the frame buffer (default is 0).
|
|
117
|
-
* @returns {this} The current instance for chaining.
|
|
118
|
-
*/
|
|
119
|
-
setClear(clear: boolean, bufferSize?: number): this;
|
|
120
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AnimationManager = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
|
-
/**
|
|
6
|
-
* Class representing the animation manager, which handles animation settings and options.
|
|
7
|
-
*/
|
|
8
|
-
class AnimationManager {
|
|
9
|
-
/**
|
|
10
|
-
* The options for the animation manager.
|
|
11
|
-
*/
|
|
12
|
-
options;
|
|
13
|
-
/**
|
|
14
|
-
* Whether debugging is enabled.
|
|
15
|
-
*/
|
|
16
|
-
debug;
|
|
17
|
-
/**
|
|
18
|
-
* Constructs a new AnimationManager instance.
|
|
19
|
-
* @param {Object} [opts] - Optional settings for the animation manager.
|
|
20
|
-
* @param {boolean} [opts.debug] - Whether debugging is enabled.
|
|
21
|
-
* @param {Object} [opts.settings] - Additional settings for the animation manager.
|
|
22
|
-
* @param {IAnimationOptions} [opts.settings.options] - The animation options.
|
|
23
|
-
*/
|
|
24
|
-
constructor(opts) {
|
|
25
|
-
this.options = opts?.settings?.options || {
|
|
26
|
-
frameRate: 30,
|
|
27
|
-
maxColors: 256,
|
|
28
|
-
colorSpace: types_1.ColorSpace.RGB565,
|
|
29
|
-
loop: true,
|
|
30
|
-
transparency: true,
|
|
31
|
-
utils: {
|
|
32
|
-
clear: true,
|
|
33
|
-
buffer: {
|
|
34
|
-
size: 0
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
this.debug = opts?.debug || false;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Sets the frame rate of the animation.
|
|
42
|
-
* @param {number} [frameRate] - The frame rate of the animation (default is 30).
|
|
43
|
-
* @returns {this} The current instance for chaining.
|
|
44
|
-
*/
|
|
45
|
-
setFrameRate(frameRate) {
|
|
46
|
-
this.options.frameRate = frameRate;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Sets whether the animation should loop.
|
|
51
|
-
* @param {boolean} [loop] - Whether the animation should loop (default is true).
|
|
52
|
-
* @returns {this} The current instance for chaining.
|
|
53
|
-
*/
|
|
54
|
-
setLoop(loop) {
|
|
55
|
-
this.options.loop = loop;
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Sets whether the animation should have transparency.
|
|
60
|
-
* @param {boolean} [transparency] - Whether the animation should have transparency (default is true).
|
|
61
|
-
* @returns {this} The current instance for chaining.
|
|
62
|
-
*/
|
|
63
|
-
setTransparent(transparency) {
|
|
64
|
-
this.options.transparency = transparency;
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Sets the RGB format of the animation.
|
|
69
|
-
* @param {ColorSpace} [rgb] - The RGB format of the animation (default is RGB565).
|
|
70
|
-
* @returns {this} The current instance for chaining.
|
|
71
|
-
*/
|
|
72
|
-
setRGBFormat(rgb) {
|
|
73
|
-
this.options.colorSpace = rgb;
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Sets the maximum number of colors in the animation.
|
|
78
|
-
* @param {number} [maxColors] - The maximum number of colors (default is 256).
|
|
79
|
-
* @returns {this} The current instance for chaining.
|
|
80
|
-
*/
|
|
81
|
-
setMaxColors(maxColors) {
|
|
82
|
-
this.options.maxColors = maxColors;
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Sets whether the content of previous frames will be cleared.
|
|
87
|
-
* @param {boolean} [clear] - Whether to clear the content of previous frames (default is true).
|
|
88
|
-
* @param {number} [bufferSize] - The size of the frame buffer (default is 0).
|
|
89
|
-
* @returns {this} The current instance for chaining.
|
|
90
|
-
*/
|
|
91
|
-
setClear(clear, bufferSize) {
|
|
92
|
-
this.options.utils.clear = clear;
|
|
93
|
-
if (bufferSize) {
|
|
94
|
-
this.options.utils.buffer.size = bufferSize;
|
|
95
|
-
}
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.AnimationManager = AnimationManager;
|