@nmmty/lazycanvas 0.3.6 → 0.5.0

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.
Files changed (68) hide show
  1. package/dist/helpers/Filters.d.ts +10 -10
  2. package/dist/helpers/Fonts.d.ts +1 -1
  3. package/dist/helpers/FontsList.d.ts +1 -1
  4. package/dist/helpers/FontsList.js +19 -19
  5. package/dist/index.d.ts +11 -20
  6. package/dist/index.js +40 -45
  7. package/dist/structures/LazyCanvas.d.ts +126 -17
  8. package/dist/structures/LazyCanvas.js +101 -33
  9. package/dist/structures/components/BaseLayer.d.ts +188 -38
  10. package/dist/structures/components/BaseLayer.js +88 -41
  11. package/dist/structures/components/BezierLayer.d.ts +108 -21
  12. package/dist/structures/components/BezierLayer.js +73 -24
  13. package/dist/structures/components/ClearLayer.d.ts +142 -0
  14. package/dist/structures/components/ClearLayer.js +152 -0
  15. package/dist/structures/components/Group.d.ts +86 -18
  16. package/dist/structures/components/Group.js +69 -29
  17. package/dist/structures/components/ImageLayer.d.ts +85 -12
  18. package/dist/structures/components/ImageLayer.js +55 -42
  19. package/dist/structures/components/LineLayer.d.ts +111 -18
  20. package/dist/structures/components/LineLayer.js +58 -21
  21. package/dist/structures/components/MorphLayer.d.ts +109 -21
  22. package/dist/structures/components/MorphLayer.js +55 -27
  23. package/dist/structures/components/Path2DLayer.d.ts +191 -0
  24. package/dist/structures/components/Path2DLayer.js +318 -0
  25. package/dist/structures/components/QuadraticLayer.d.ts +108 -22
  26. package/dist/structures/components/QuadraticLayer.js +65 -30
  27. package/dist/structures/components/TextLayer.d.ts +201 -40
  28. package/dist/structures/components/TextLayer.js +101 -49
  29. package/dist/structures/components/index.d.ts +10 -0
  30. package/dist/structures/components/index.js +26 -0
  31. package/dist/structures/helpers/Exporter.d.ts +52 -0
  32. package/dist/structures/helpers/Exporter.js +168 -0
  33. package/dist/structures/helpers/Font.d.ts +64 -10
  34. package/dist/structures/helpers/Font.js +38 -11
  35. package/dist/structures/helpers/Gradient.d.ts +96 -9
  36. package/dist/structures/helpers/Gradient.js +48 -17
  37. package/dist/structures/helpers/Link.d.ts +52 -8
  38. package/dist/structures/helpers/Link.js +42 -11
  39. package/dist/structures/helpers/Pattern.d.ts +52 -7
  40. package/dist/structures/helpers/Pattern.js +45 -40
  41. package/dist/structures/helpers/index.d.ts +6 -0
  42. package/dist/structures/helpers/index.js +22 -0
  43. package/dist/structures/helpers/readers/JSONReader.d.ts +49 -0
  44. package/dist/structures/helpers/readers/JSONReader.js +172 -0
  45. package/dist/structures/helpers/readers/SVGReader.d.ts +20 -0
  46. package/dist/structures/helpers/readers/SVGReader.js +577 -0
  47. package/dist/structures/helpers/readers/YAMLReader.d.ts +0 -0
  48. package/dist/structures/helpers/readers/YAMLReader.js +1 -0
  49. package/dist/structures/managers/AnimationManager.d.ts +120 -0
  50. package/dist/structures/managers/AnimationManager.js +99 -0
  51. package/dist/structures/managers/FontsManager.d.ts +76 -32
  52. package/dist/structures/managers/FontsManager.js +70 -45
  53. package/dist/structures/managers/LayersManager.d.ts +84 -32
  54. package/dist/structures/managers/LayersManager.js +67 -29
  55. package/dist/structures/managers/RenderManager.d.ts +63 -6
  56. package/dist/structures/managers/RenderManager.js +162 -33
  57. package/dist/types/LazyCanvas.d.ts +2 -0
  58. package/dist/types/components/ClearLayer.d.ts +19 -0
  59. package/dist/types/enum.d.ts +20 -7
  60. package/dist/types/enum.js +24 -10
  61. package/dist/types/index.d.ts +2 -17
  62. package/dist/types/index.js +17 -0
  63. package/dist/types/managers/AnimationManager.d.ts +14 -0
  64. package/dist/types/types.d.ts +7 -3
  65. package/dist/utils/LazyUtil.js +2 -2
  66. package/dist/utils/utils.d.ts +10 -9
  67. package/dist/utils/utils.js +159 -164
  68. package/package.json +9 -5
@@ -2,23 +2,35 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BezierLayer = void 0;
4
4
  const BaseLayer_1 = require("./BaseLayer");
5
- const enum_1 = require("../../types/enum");
5
+ const types_1 = require("../../types");
6
6
  const utils_1 = require("../../utils/utils");
7
7
  const LazyUtil_1 = require("../../utils/LazyUtil");
8
- const Gradient_1 = require("../helpers/Gradient");
9
- const Pattern_1 = require("../helpers/Pattern");
8
+ const helpers_1 = require("../helpers");
9
+ /**
10
+ * Class representing a Bezier layer, extending the BaseLayer class.
11
+ */
10
12
  class BezierLayer extends BaseLayer_1.BaseLayer {
13
+ /**
14
+ * The properties of the Bezier layer.
15
+ */
11
16
  props;
12
- constructor(props) {
13
- super(enum_1.LayerType.BezierCurve, props || {});
17
+ /**
18
+ * Constructs a new BezierLayer instance.
19
+ * @param props {IBezierLayerProps} - The properties of the Bezier layer.
20
+ * @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
21
+ */
22
+ constructor(props, misc) {
23
+ super(types_1.LayerType.BezierCurve, props || {}, misc);
14
24
  this.props = props ? props : {};
15
25
  if (!this.props.fillStyle)
16
26
  this.props.fillStyle = '#000000';
17
- this.props.centring = enum_1.Centring.None;
27
+ this.props.centring = types_1.Centring.None;
18
28
  }
19
29
  /**
20
- * @description Sets the control points of the bezier layer. You can use `numbers`, `percentages`, `px`, `vw`, `vh`, `vmin`, `vmax`.
21
- * @param controlPoints {Array<{ x: ScaleType, y: ScaleType }>} - The `controlPoints` of the bezier layer.
30
+ * Sets the control points of the Bezier layer.
31
+ * @param controlPoints {Array<{ x: ScaleType, y: ScaleType }>} - The control points of the Bezier layer.
32
+ * @returns {this} The current instance for chaining.
33
+ * @throws {LazyError} If the number of control points is not exactly 2.
22
34
  */
23
35
  setControlPoints(...controlPoints) {
24
36
  if (controlPoints.length !== 2)
@@ -27,17 +39,20 @@ class BezierLayer extends BaseLayer_1.BaseLayer {
27
39
  return this;
28
40
  }
29
41
  /**
30
- * @description Sets the end point of the bezier layer. You can use `numbers`, `percentages`, `px`, `vw`, `vh`, `vmin`, `vmax`.
31
- * @param x {ScaleType} - The end `x` of the bezier layer.
32
- * @param y {ScaleType} - The end `y` of the bezier layer.
42
+ * Sets the end position of the Bezier layer.
43
+ * @param x {ScaleType} - The x-coordinate of the end point.
44
+ * @param y {ScaleType} - The y-coordinate of the end point.
45
+ * @returns {this} The current instance for chaining.
33
46
  */
34
47
  setEndPosition(x, y) {
35
48
  this.props.endPoint = { x, y };
36
49
  return this;
37
50
  }
38
51
  /**
39
- * @description Sets the color of the layer. You can use `hex`, `rgb`, `rgba`, `hsl`, `hsla`, and `Gradient`color.
40
- * @param color {string} - The `color` of the layer.
52
+ * Sets the color of the Bezier layer.
53
+ * @param color {ColorType} - The color of the layer.
54
+ * @returns {this} The current instance for chaining.
55
+ * @throws {LazyError} If the color is not provided or invalid.
41
56
  */
42
57
  setColor(color) {
43
58
  if (!color)
@@ -45,7 +60,7 @@ class BezierLayer extends BaseLayer_1.BaseLayer {
45
60
  if (!(0, utils_1.isColor)(color))
46
61
  throw new LazyUtil_1.LazyError('The color of the layer must be a valid color');
47
62
  let fill = (0, utils_1.parseColor)(color);
48
- if (fill instanceof Gradient_1.Gradient || fill instanceof Pattern_1.Pattern) {
63
+ if (fill instanceof helpers_1.Gradient || fill instanceof helpers_1.Pattern) {
49
64
  this.props.fillStyle = fill;
50
65
  }
51
66
  else {
@@ -56,13 +71,14 @@ class BezierLayer extends BaseLayer_1.BaseLayer {
56
71
  return this;
57
72
  }
58
73
  /**
59
- * @description Sets the stroke of the layer.
60
- * @param width {number} - The `width` of the stroke.
61
- * @param cap {string} - The `cap` of the stroke.
62
- * @param join {string} - The `join` of the stroke.
63
- * @param dash {number[]} - The `dash` of the stroke.
64
- * @param dashOffset {number} - The `dashOffset` of the stroke.
65
- * @param miterLimit {number} - The `miterLimit` of the stroke.
74
+ * Sets the stroke properties of the Bezier layer.
75
+ * @param width {number} - The width of the stroke.
76
+ * @param cap {string} - The cap style of the stroke.
77
+ * @param join {string} - The join style of the stroke.
78
+ * @param dash {number[]} - The dash pattern of the stroke.
79
+ * @param dashOffset {number} - The dash offset of the stroke.
80
+ * @param miterLimit {number} - The miter limit of the stroke.
81
+ * @returns {this} The current instance for chaining.
66
82
  */
67
83
  setStroke(width, cap, join, dash, dashOffset, miterLimit) {
68
84
  this.props.stroke = {
@@ -75,6 +91,13 @@ class BezierLayer extends BaseLayer_1.BaseLayer {
75
91
  };
76
92
  return this;
77
93
  }
94
+ /**
95
+ * Calculates the bounding box of the Bezier layer.
96
+ * @param ctx {SKRSContext2D} - The canvas rendering context.
97
+ * @param canvas {Canvas | SvgCanvas} - The canvas instance.
98
+ * @param manager {LayersManager} - The layers manager.
99
+ * @returns {Object} The bounding box details including max, min, center, width, and height.
100
+ */
78
101
  getBoundingBox(ctx, canvas, manager) {
79
102
  const parcer = (0, utils_1.parser)(ctx, canvas, manager);
80
103
  const { xs, ys, cp1x, cp1y, cp2x, cp2y, xe, ye } = parcer.parseBatch({
@@ -90,6 +113,13 @@ class BezierLayer extends BaseLayer_1.BaseLayer {
90
113
  const { max, min, center, width, height } = (0, utils_1.getBoundingBoxBezier)([{ x: xs, y: ys }, { x: cp1x, y: cp1y }, { x: cp2x, y: cp2y }, { x: xe, y: ye }]);
91
114
  return { max, min, center, width, height };
92
115
  }
116
+ /**
117
+ * Draws the Bezier layer on the canvas.
118
+ * @param ctx {SKRSContext2D} - The canvas rendering context.
119
+ * @param canvas {Canvas | SvgCanvas} - The canvas instance.
120
+ * @param manager {LayersManager} - The layers manager.
121
+ * @param debug {boolean} - Whether to enable debug logging.
122
+ */
93
123
  async draw(ctx, canvas, manager, debug) {
94
124
  const parcer = (0, utils_1.parser)(ctx, canvas, manager);
95
125
  const { xs, ys, cp1x, cp1y, cp2x, cp2y, xe, ye } = parcer.parseBatch({
@@ -126,12 +156,31 @@ class BezierLayer extends BaseLayer_1.BaseLayer {
126
156
  ctx.restore();
127
157
  }
128
158
  /**
129
- * @returns {IBezierLayer}
159
+ * Converts the Bezier layer to a JSON representation.
160
+ * @returns {IBezierLayer} The JSON representation of the Bezier layer.
130
161
  */
131
162
  toJSON() {
132
163
  let data = super.toJSON();
133
- data.props = this.props;
134
- return { ...data };
164
+ let copy = { ...this.props };
165
+ for (const key of ['x', 'y', 'endPoint.x', 'endPoint.y', 'fillStyle']) {
166
+ if (copy[key] && typeof copy[key] === 'object' && 'toJSON' in copy[key]) {
167
+ copy[key] = copy[key].toJSON();
168
+ }
169
+ }
170
+ if (copy.controlPoints) {
171
+ copy.controlPoints = copy.controlPoints.map((point) => {
172
+ if (point.x && typeof point.x === 'object' && 'toJSON' in point.x) {
173
+ // @ts-ignore
174
+ point.x = point.x.toJSON();
175
+ }
176
+ if (point.y && typeof point.y === 'object' && 'toJSON' in point.y) {
177
+ // @ts-ignore
178
+ point.y = point.y.toJSON();
179
+ }
180
+ return point;
181
+ });
182
+ }
183
+ return { ...data, props: copy };
135
184
  }
136
185
  }
137
186
  exports.BezierLayer = BezierLayer;
@@ -0,0 +1,142 @@
1
+ import { ScaleType, LayerType, AnyCentring } from "../../types";
2
+ import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
3
+ import { LayersManager } from "../managers/LayersManager";
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
+ /**
61
+ * Class representing a Clear Layer.
62
+ */
63
+ export declare class ClearLayer implements IClearLayer {
64
+ /**
65
+ * The unique identifier of the layer.
66
+ */
67
+ id: string;
68
+ /**
69
+ * The type of the layer, which is `Clear`.
70
+ */
71
+ type: LayerType.Clear;
72
+ /**
73
+ * The z-index of the layer, determining its stacking order.
74
+ */
75
+ zIndex: number;
76
+ /**
77
+ * The visibility of the layer.
78
+ */
79
+ visible: boolean;
80
+ /**
81
+ * The properties of the Clear Layer.
82
+ */
83
+ props: IClearLayerProps;
84
+ /**
85
+ * Constructs a new ClearLayer instance.
86
+ * @param props {IClearLayerProps} - The properties of the Clear Layer.
87
+ * @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
88
+ */
89
+ constructor(props?: IClearLayerProps, misc?: IBaseLayerMisc);
90
+ /**
91
+ * Sets the position of the layer in the 2D plane.
92
+ * @param x {ScaleType} - The x-coordinate of the layer.
93
+ * @param y {ScaleType} - The y-coordinate of the layer.
94
+ * @returns {this} The current instance for chaining.
95
+ */
96
+ setPosition(x: ScaleType, y: ScaleType): this;
97
+ /**
98
+ * Sets the size of the layer.
99
+ * @param width {ScaleType} - The width of the layer.
100
+ * @param height {ScaleType} - The height of the layer.
101
+ * @returns {this} The current instance for chaining.
102
+ */
103
+ setSize(width: ScaleType, height: ScaleType): this;
104
+ /**
105
+ * Sets the unique identifier of the layer.
106
+ *
107
+ * @param {string} id - The unique identifier.
108
+ * @returns {this} The current instance for chaining.
109
+ */
110
+ setID(id: string): this;
111
+ /**
112
+ * Sets the centring type of the layer.
113
+ * @param centring {AnyCentring} - The centring type of the layer.
114
+ * @returns {this} The current instance for chaining.
115
+ */
116
+ setCentring(centring: AnyCentring): this;
117
+ /**
118
+ * Sets the visibility of the layer.
119
+ * @param visible {boolean} - The visibility state of the layer.
120
+ * @returns {this} The current instance for chaining.
121
+ */
122
+ setVisible(visible: boolean): this;
123
+ /**
124
+ * Sets the z-index of the layer.
125
+ * @param zIndex {number} - The z-index value of the layer.
126
+ * @returns {this} The current instance for chaining.
127
+ */
128
+ setZIndex(zIndex: number): this;
129
+ /**
130
+ * Draws the Clear Layer on the canvas.
131
+ * @param ctx {SKRSContext2D} - The canvas rendering context.
132
+ * @param canvas {Canvas | SvgCanvas} - The canvas instance.
133
+ * @param manager {LayersManager} - The layers manager.
134
+ * @param debug {boolean} - Whether to enable debug logging.
135
+ */
136
+ draw(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager, debug: boolean): Promise<void>;
137
+ /**
138
+ * Converts the Clear Layer to a JSON representation.
139
+ * @returns {IClearLayer} The JSON representation of the Clear Layer.
140
+ */
141
+ toJSON(): IClearLayer;
142
+ }
@@ -0,0 +1,152 @@
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 props {IClearLayerProps} - The properties of the Clear Layer.
35
+ * @param misc {IBaseLayerMisc} - 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
+ x: 0,
44
+ y: 0,
45
+ size: {
46
+ width: 0,
47
+ height: 0
48
+ }
49
+ };
50
+ }
51
+ /**
52
+ * Sets the position of the layer in the 2D plane.
53
+ * @param x {ScaleType} - The x-coordinate of the layer.
54
+ * @param y {ScaleType} - The y-coordinate of the layer.
55
+ * @returns {this} The current instance for chaining.
56
+ */
57
+ setPosition(x, y) {
58
+ this.props.x = x;
59
+ this.props.y = y;
60
+ return this;
61
+ }
62
+ /**
63
+ * Sets the size of the layer.
64
+ * @param width {ScaleType} - The width of the layer.
65
+ * @param height {ScaleType} - The height of the layer.
66
+ * @returns {this} The current instance for chaining.
67
+ */
68
+ setSize(width, height) {
69
+ this.props.size = {
70
+ width,
71
+ height
72
+ };
73
+ return this;
74
+ }
75
+ /**
76
+ * Sets the unique identifier of the layer.
77
+ *
78
+ * @param {string} id - The unique identifier.
79
+ * @returns {this} The current instance for chaining.
80
+ */
81
+ setID(id) {
82
+ this.id = id;
83
+ return this;
84
+ }
85
+ /**
86
+ * Sets the centring type of the layer.
87
+ * @param centring {AnyCentring} - The centring type of the layer.
88
+ * @returns {this} The current instance for chaining.
89
+ */
90
+ setCentring(centring) {
91
+ this.props.centring = centring;
92
+ return this;
93
+ }
94
+ /**
95
+ * Sets the visibility of the layer.
96
+ * @param visible {boolean} - The visibility state of the layer.
97
+ * @returns {this} The current instance for chaining.
98
+ */
99
+ setVisible(visible) {
100
+ this.visible = visible;
101
+ return this;
102
+ }
103
+ /**
104
+ * Sets the z-index of the layer.
105
+ * @param zIndex {number} - The z-index value of the layer.
106
+ * @returns {this} The current instance for chaining.
107
+ */
108
+ setZIndex(zIndex) {
109
+ this.zIndex = zIndex;
110
+ return this;
111
+ }
112
+ /**
113
+ * Draws the Clear Layer on the canvas.
114
+ * @param ctx {SKRSContext2D} - The canvas rendering context.
115
+ * @param canvas {Canvas | SvgCanvas} - The canvas instance.
116
+ * @param manager {LayersManager} - The layers manager.
117
+ * @param debug {boolean} - Whether to enable debug logging.
118
+ */
119
+ async draw(ctx, canvas, manager, debug) {
120
+ const parcer = (0, utils_1.parser)(ctx, canvas, manager);
121
+ const { xs, ys, w } = parcer.parseBatch({
122
+ xs: { v: this.props.x },
123
+ ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
124
+ w: { v: this.props.size.width },
125
+ });
126
+ const h = parcer.parse(this.props.size.height, LazyUtil_1.defaultArg.wh(w), LazyUtil_1.defaultArg.vl(true));
127
+ let { x, y } = (0, utils_1.centring)(this.props.centring, this.type, w, h, xs, ys);
128
+ if (debug)
129
+ LazyUtil_1.LazyLog.log('none', `ClearLayer:`, { x, y, w, h });
130
+ ctx.clearRect(x, y, w, h);
131
+ }
132
+ /**
133
+ * Converts the Clear Layer to a JSON representation.
134
+ * @returns {IClearLayer} The JSON representation of the Clear Layer.
135
+ */
136
+ toJSON() {
137
+ let copy = { ...this.props };
138
+ for (const key of ['x', 'y', 'size.width', 'size.height']) {
139
+ if (copy[key] && typeof copy[key] === 'object' && 'toJSON' in copy[key]) {
140
+ copy[key] = copy[key].toJSON();
141
+ }
142
+ }
143
+ return {
144
+ id: this.id,
145
+ type: this.type,
146
+ zIndex: this.zIndex,
147
+ visible: this.visible,
148
+ props: copy,
149
+ };
150
+ }
151
+ }
152
+ exports.ClearLayer = ClearLayer;
@@ -1,51 +1,119 @@
1
- import { AnyLayer, IGroup } from "../../types";
1
+ import { AnyLayer, LayerType } from "../../types";
2
+ /**
3
+ * Interface representing a group of layers.
4
+ */
5
+ export interface IGroup {
6
+ /**
7
+ * The unique identifier of the group.
8
+ */
9
+ id: string;
10
+ /**
11
+ * The type of the group, which is `Group`.
12
+ */
13
+ type: LayerType.Group;
14
+ /**
15
+ * The visibility of the group.
16
+ */
17
+ visible: boolean;
18
+ /**
19
+ * The z-index of the group, determining its stacking order.
20
+ */
21
+ zIndex: number;
22
+ /**
23
+ * The layers contained within the group.
24
+ */
25
+ layers: Array<AnyLayer>;
26
+ }
27
+ /**
28
+ * Class representing a group of layers.
29
+ */
2
30
  export declare class Group implements IGroup {
31
+ /**
32
+ * The unique identifier of the group.
33
+ */
3
34
  id: string;
35
+ /**
36
+ * The type of the group, which is `Group`.
37
+ */
38
+ type: LayerType.Group;
39
+ /**
40
+ * The visibility of the group.
41
+ */
4
42
  visible: boolean;
43
+ /**
44
+ * The z-index of the group, determining its stacking order.
45
+ */
5
46
  zIndex: number;
6
- components: Array<any>;
7
- constructor();
8
47
  /**
9
- * Set the ID of the group
10
- * @param id {string} - The `id` of the group
48
+ * The layers contained within the group.
49
+ */
50
+ layers: Array<any>;
51
+ /**
52
+ * Constructs a new Group instance.
53
+ * @param opts {Object} - Optional parameters for the group.
54
+ * @param opts.id {string} - The unique identifier of the group.
55
+ * @param opts.visible {boolean} - The visibility of the group.
56
+ * @param opts.zIndex {number} - The z-index of the group.
57
+ */
58
+ constructor(opts?: {
59
+ id?: string;
60
+ visible?: boolean;
61
+ zIndex?: number;
62
+ });
63
+ /**
64
+ * Sets the ID of the group.
65
+ * @param id {string} - The unique identifier of the group.
66
+ * @returns {this} The current instance for chaining.
11
67
  */
12
68
  setID(id: string): this;
13
69
  /**
14
- * Set the visibility of the group
15
- * @param visible {boolean} - The `visibility` of the group
70
+ * Sets the visibility of the group.
71
+ * @param visible {boolean} - The visibility state of the group.
72
+ * @returns {this} The current instance for chaining.
16
73
  */
17
74
  setVisible(visible: boolean): this;
18
75
  /**
19
- * Set the zIndex of the group
20
- * @param zIndex {number} - The `zIndex` of the group
76
+ * Sets the z-index of the group.
77
+ * @param zIndex {number} - The z-index value of the group.
78
+ * @returns {this} The current instance for chaining.
21
79
  */
22
80
  setZIndex(zIndex: number): this;
23
81
  /**
24
- * Add a component to the group
25
- * @param components {any[]} - The `components` to add to the group
82
+ * Adds components to the group.
83
+ * @param components {AnyLayer[]} - The components to add to the group.
84
+ * @returns {this} The current instance for chaining.
26
85
  */
27
86
  add(...components: AnyLayer[]): this;
28
87
  /**
29
- * Remove a component from the group
30
- * @param id {any} - The `id` of the component to remove
88
+ * Removes a component from the group by its ID.
89
+ * @param id {string} - The unique identifier of the component to remove.
90
+ * @returns {this} The current instance for chaining.
31
91
  */
32
92
  remove(id: string): this;
33
93
  /**
34
- * Clear all components from the group
94
+ * Clears all components from the group.
95
+ * @returns {this} The current instance for chaining.
35
96
  */
36
97
  clear(): this;
37
98
  /**
38
- * Get a component from the group
39
- * @param id {string} - The `id` of the component to get
99
+ * Retrieves a component from the group by its ID.
100
+ * @param id {string} - The unique identifier of the component to retrieve.
101
+ * @returns {AnyLayer | undefined} The component with the specified ID, or undefined if not found.
40
102
  */
41
103
  get(id: string): any;
42
104
  /**
43
- * Get all components from the group
105
+ * Retrieves all components from the group.
106
+ * @returns {AnyLayer[]} An array of all components in the group.
44
107
  */
45
108
  getAll(): any[];
46
109
  /**
47
- * Get the length of the components
110
+ * Gets the number of components in the group.
111
+ * @returns {number} The number of components in the group.
48
112
  */
49
113
  get length(): number;
114
+ /**
115
+ * Converts the group to a JSON representation.
116
+ * @returns {IGroup} The JSON representation of the group.
117
+ */
50
118
  toJSON(): IGroup;
51
119
  }