@nmmty/lazycanvas 0.6.5 → 1.0.0-dev.10
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/dist/core/Interpolation.d.ts +30 -0
- package/dist/core/Interpolation.js +200 -0
- package/dist/core/Scene.d.ts +94 -0
- package/dist/core/Scene.js +157 -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/core/index.d.ts +5 -0
- package/dist/core/index.js +21 -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 +25 -36
- package/dist/helpers/index.d.ts +3 -3
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/jsx-runtime.d.ts +17 -0
- package/dist/jsx-runtime.js +111 -0
- package/dist/structures/LazyCanvas.d.ts +10 -48
- package/dist/structures/LazyCanvas.js +17 -78
- package/dist/structures/components/BaseLayer.d.ts +78 -32
- package/dist/structures/components/BaseLayer.js +106 -37
- package/dist/structures/components/BezierLayer.d.ts +25 -38
- package/dist/structures/components/BezierLayer.js +88 -53
- package/dist/structures/components/{Group.d.ts → Div.d.ts} +37 -18
- package/dist/structures/components/Div.js +202 -0
- package/dist/structures/components/ImageLayer.d.ts +1 -1
- package/dist/structures/components/ImageLayer.js +28 -29
- package/dist/structures/components/LineLayer.d.ts +18 -36
- package/dist/structures/components/LineLayer.js +43 -45
- package/dist/structures/components/MorphLayer.d.ts +4 -33
- package/dist/structures/components/MorphLayer.js +37 -51
- package/dist/structures/components/Path2DLayer.d.ts +7 -35
- package/dist/structures/components/Path2DLayer.js +32 -41
- package/dist/structures/components/PolygonLayer.d.ts +3 -32
- package/dist/structures/components/PolygonLayer.js +37 -42
- package/dist/structures/components/QuadraticLayer.d.ts +25 -34
- package/dist/structures/components/QuadraticLayer.js +83 -47
- package/dist/structures/components/TextLayer.d.ts +5 -34
- package/dist/structures/components/TextLayer.js +88 -71
- 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 +82 -46
- package/dist/structures/helpers/Font.js +1 -17
- package/dist/structures/helpers/Gradient.js +35 -49
- package/dist/structures/helpers/Link.js +2 -14
- package/dist/structures/helpers/Pattern.js +10 -18
- 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 +44 -48
- package/dist/structures/helpers/readers/YAMLReader.js +11 -11
- 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/LayoutManager.d.ts +23 -0
- package/dist/structures/managers/LayoutManager.js +409 -0
- package/dist/structures/managers/index.d.ts +3 -5
- package/dist/structures/managers/index.js +1 -3
- package/dist/structures/managers/{RenderManager.d.ts → piplines/ClassicRenderPipeline.d.ts} +4 -30
- package/dist/structures/managers/piplines/ClassicRenderPipeline.js +90 -0
- package/dist/structures/managers/piplines/ModernRenderPipeline.d.ts +44 -0
- package/dist/structures/managers/piplines/ModernRenderPipeline.js +123 -0
- package/dist/structures/managers/piplines/index.d.ts +24 -0
- package/dist/structures/managers/piplines/index.js +18 -0
- 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/types/types.d.ts +257 -107
- 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/index.d.ts +4 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/utils.d.ts +4 -7
- package/dist/utils/utils.js +140 -78
- package/package.json +61 -59
- package/dist/structures/components/ClearLayer.d.ts +0 -147
- package/dist/structures/components/ClearLayer.js +0 -158
- package/dist/structures/components/Group.js +0 -153
- 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/structures/managers/RenderManager.js +0 -183
|
@@ -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,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Group = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
|
-
const utils_1 = require("../../utils/utils");
|
|
6
|
-
const LazyUtil_1 = require("../../utils/LazyUtil");
|
|
7
|
-
/**
|
|
8
|
-
* Class representing a group of layer's.
|
|
9
|
-
*/
|
|
10
|
-
class Group {
|
|
11
|
-
/**
|
|
12
|
-
* The unique identifier of the group.
|
|
13
|
-
*/
|
|
14
|
-
id;
|
|
15
|
-
/**
|
|
16
|
-
* The type of the group, which is `Group`.
|
|
17
|
-
*/
|
|
18
|
-
type = types_1.LayerType.Group;
|
|
19
|
-
/**
|
|
20
|
-
* The visibility of the group.
|
|
21
|
-
*/
|
|
22
|
-
visible;
|
|
23
|
-
/**
|
|
24
|
-
* The z-index of the group, determining its stacking order.
|
|
25
|
-
*/
|
|
26
|
-
zIndex;
|
|
27
|
-
/**
|
|
28
|
-
* The layer's contained within the group.
|
|
29
|
-
*/
|
|
30
|
-
layers;
|
|
31
|
-
props;
|
|
32
|
-
/**
|
|
33
|
-
* Constructs a new Group instance.
|
|
34
|
-
* @param {string} [opts.id] - The unique identifier of the group.
|
|
35
|
-
* @param {boolean} [opts.visible] - The visibility of the group.
|
|
36
|
-
* @param {number} [opts.zIndex] - The z-index of the group.
|
|
37
|
-
*/
|
|
38
|
-
constructor(opts) {
|
|
39
|
-
this.id = opts?.id || (0, utils_1.generateID)(types_1.LayerType.Group);
|
|
40
|
-
this.visible = opts?.visible || true;
|
|
41
|
-
this.zIndex = opts?.zIndex || 1;
|
|
42
|
-
this.layers = [];
|
|
43
|
-
this.props = {};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Sets the ID of the group.
|
|
47
|
-
* @param {string} [id] - The unique identifier of the group.
|
|
48
|
-
* @returns {this} The current instance for chaining.
|
|
49
|
-
*/
|
|
50
|
-
setID(id) {
|
|
51
|
-
this.id = id;
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Sets the visibility of the group.
|
|
56
|
-
* @param {boolean} [visible] - The visibility state of the group.
|
|
57
|
-
* @returns {this} The current instance for chaining.
|
|
58
|
-
*/
|
|
59
|
-
setVisible(visible) {
|
|
60
|
-
this.visible = visible;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Sets the z-index of the group.
|
|
65
|
-
* @param {number} [zIndex] - The z-index value of the group.
|
|
66
|
-
* @returns {this} The current instance for chaining.
|
|
67
|
-
*/
|
|
68
|
-
setZIndex(zIndex) {
|
|
69
|
-
this.zIndex = zIndex;
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Adds components to the group.
|
|
74
|
-
* @param {AnyLayer[]} [components] - The components to add to the group.
|
|
75
|
-
* @returns {this} The current instance for chaining.
|
|
76
|
-
*/
|
|
77
|
-
add(...components) {
|
|
78
|
-
let layersArray = components.flat();
|
|
79
|
-
layersArray = layersArray.filter(l => l !== undefined);
|
|
80
|
-
layersArray = layersArray.sort((a, b) => a.zIndex - b.zIndex);
|
|
81
|
-
this.layers.push(...layersArray);
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Removes a component from the group by its ID.
|
|
86
|
-
* @param {string} [id] - The unique identifier of the component to remove.
|
|
87
|
-
* @returns {this} The current instance for chaining.
|
|
88
|
-
*/
|
|
89
|
-
remove(id) {
|
|
90
|
-
this.layers = this.layers.filter(c => c.id !== id);
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Clears all components from the group.
|
|
95
|
-
* @returns {this} The current instance for chaining.
|
|
96
|
-
*/
|
|
97
|
-
clear() {
|
|
98
|
-
this.layers = [];
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Retrieves a component from the group by its ID.
|
|
103
|
-
* @param {string} [id] - The unique identifier of the component to retrieve.
|
|
104
|
-
* @returns {AnyLayer | undefined} The component with the specified ID, or undefined if not found.
|
|
105
|
-
*/
|
|
106
|
-
get(id) {
|
|
107
|
-
return this.layers.find(c => c.id === id);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Retrieves all components from the group.
|
|
111
|
-
* @returns {AnyLayer[]} An array of all components in the group.
|
|
112
|
-
*/
|
|
113
|
-
getAll() {
|
|
114
|
-
return this.layers;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Gets the number of components in the group.
|
|
118
|
-
* @returns {number} The number of components in the group.
|
|
119
|
-
*/
|
|
120
|
-
get length() {
|
|
121
|
-
return this.layers.length;
|
|
122
|
-
}
|
|
123
|
-
async draw(ctx, canvas, manager, debug) {
|
|
124
|
-
for (const subLayer of this.layers) {
|
|
125
|
-
if (debug)
|
|
126
|
-
LazyUtil_1.LazyLog.log('info', `Rendering ${subLayer.id}...\nData:`, subLayer.toJSON());
|
|
127
|
-
if (subLayer.visible) {
|
|
128
|
-
if ('globalComposite' in subLayer.props && subLayer.props.globalComposite) {
|
|
129
|
-
ctx.globalCompositeOperation = subLayer.props.globalComposite;
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
ctx.globalCompositeOperation = 'source-over';
|
|
133
|
-
}
|
|
134
|
-
await subLayer.draw(ctx, canvas, manager, debug);
|
|
135
|
-
ctx.shadowColor = 'transparent';
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Converts the group to a JSON representation.
|
|
141
|
-
* @returns {IGroup} The JSON representation of the group.
|
|
142
|
-
*/
|
|
143
|
-
toJSON() {
|
|
144
|
-
return {
|
|
145
|
-
id: this.id,
|
|
146
|
-
type: this.type,
|
|
147
|
-
visible: this.visible,
|
|
148
|
-
zIndex: this.zIndex,
|
|
149
|
-
layers: this.layers.map(c => c.toJSON())
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
exports.Group = Group;
|
|
@@ -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;
|