@nmmty/lazycanvas 0.4.0 → 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 (64) 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 -47
  7. package/dist/structures/LazyCanvas.d.ts +126 -19
  8. package/dist/structures/LazyCanvas.js +100 -35
  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 +120 -17
  14. package/dist/structures/components/ClearLayer.js +83 -22
  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 +52 -39
  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 +53 -25
  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 +99 -47
  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 +96 -20
  50. package/dist/structures/managers/AnimationManager.js +54 -26
  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 +66 -28
  55. package/dist/structures/managers/RenderManager.d.ts +60 -6
  56. package/dist/structures/managers/RenderManager.js +120 -40
  57. package/dist/types/enum.d.ts +11 -6
  58. package/dist/types/enum.js +17 -12
  59. package/dist/types/index.d.ts +2 -19
  60. package/dist/types/index.js +17 -0
  61. package/dist/utils/LazyUtil.js +2 -2
  62. package/dist/utils/utils.d.ts +10 -9
  63. package/dist/utils/utils.js +159 -164
  64. package/package.json +4 -5
@@ -1,94 +1,134 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Group = void 0;
4
- const enum_1 = require("../../types/enum");
4
+ const types_1 = require("../../types");
5
5
  const utils_1 = require("../../utils/utils");
6
+ /**
7
+ * Class representing a group of layers.
8
+ */
6
9
  class Group {
10
+ /**
11
+ * The unique identifier of the group.
12
+ */
7
13
  id;
14
+ /**
15
+ * The type of the group, which is `Group`.
16
+ */
17
+ type = types_1.LayerType.Group;
18
+ /**
19
+ * The visibility of the group.
20
+ */
8
21
  visible;
22
+ /**
23
+ * The z-index of the group, determining its stacking order.
24
+ */
9
25
  zIndex;
10
- components;
11
- constructor() {
12
- this.id = (0, utils_1.generateID)(enum_1.LayerType.Group);
13
- this.visible = true;
14
- this.zIndex = 1;
15
- this.components = [];
26
+ /**
27
+ * The layers contained within the group.
28
+ */
29
+ layers;
30
+ /**
31
+ * Constructs a new Group instance.
32
+ * @param opts {Object} - Optional parameters for the group.
33
+ * @param opts.id {string} - The unique identifier of the group.
34
+ * @param opts.visible {boolean} - The visibility of the group.
35
+ * @param opts.zIndex {number} - The z-index of the group.
36
+ */
37
+ constructor(opts) {
38
+ this.id = opts?.id || (0, utils_1.generateID)(types_1.LayerType.Group);
39
+ this.visible = opts?.visible || true;
40
+ this.zIndex = opts?.zIndex || 1;
41
+ this.layers = [];
16
42
  }
17
43
  /**
18
- * Set the ID of the group
19
- * @param id {string} - The `id` of the group
44
+ * Sets the ID of the group.
45
+ * @param id {string} - The unique identifier of the group.
46
+ * @returns {this} The current instance for chaining.
20
47
  */
21
48
  setID(id) {
22
49
  this.id = id;
23
50
  return this;
24
51
  }
25
52
  /**
26
- * Set the visibility of the group
27
- * @param visible {boolean} - The `visibility` of the group
53
+ * Sets the visibility of the group.
54
+ * @param visible {boolean} - The visibility state of the group.
55
+ * @returns {this} The current instance for chaining.
28
56
  */
29
57
  setVisible(visible) {
30
58
  this.visible = visible;
31
59
  return this;
32
60
  }
33
61
  /**
34
- * Set the zIndex of the group
35
- * @param zIndex {number} - The `zIndex` of the group
62
+ * Sets the z-index of the group.
63
+ * @param zIndex {number} - The z-index value of the group.
64
+ * @returns {this} The current instance for chaining.
36
65
  */
37
66
  setZIndex(zIndex) {
38
67
  this.zIndex = zIndex;
39
68
  return this;
40
69
  }
41
70
  /**
42
- * Add a component to the group
43
- * @param components {any[]} - The `components` to add to the group
71
+ * Adds components to the group.
72
+ * @param components {AnyLayer[]} - The components to add to the group.
73
+ * @returns {this} The current instance for chaining.
44
74
  */
45
75
  add(...components) {
46
76
  let layersArray = components.flat();
47
77
  layersArray = layersArray.filter(l => l !== undefined);
48
78
  layersArray = layersArray.sort((a, b) => a.zIndex - b.zIndex);
49
- this.components.push(...layersArray);
79
+ this.layers.push(...layersArray);
50
80
  return this;
51
81
  }
52
82
  /**
53
- * Remove a component from the group
54
- * @param id {any} - The `id` of the component to remove
83
+ * Removes a component from the group by its ID.
84
+ * @param id {string} - The unique identifier of the component to remove.
85
+ * @returns {this} The current instance for chaining.
55
86
  */
56
87
  remove(id) {
57
- this.components = this.components.filter(c => c.id !== id);
88
+ this.layers = this.layers.filter(c => c.id !== id);
58
89
  return this;
59
90
  }
60
91
  /**
61
- * ClearLayer all components from the group
92
+ * Clears all components from the group.
93
+ * @returns {this} The current instance for chaining.
62
94
  */
63
95
  clear() {
64
- this.components = [];
96
+ this.layers = [];
65
97
  return this;
66
98
  }
67
99
  /**
68
- * Get a component from the group
69
- * @param id {string} - The `id` of the component to get
100
+ * Retrieves a component from the group by its ID.
101
+ * @param id {string} - The unique identifier of the component to retrieve.
102
+ * @returns {AnyLayer | undefined} The component with the specified ID, or undefined if not found.
70
103
  */
71
104
  get(id) {
72
- return this.components.find(c => c.id === id);
105
+ return this.layers.find(c => c.id === id);
73
106
  }
74
107
  /**
75
- * Get all components from the group
108
+ * Retrieves all components from the group.
109
+ * @returns {AnyLayer[]} An array of all components in the group.
76
110
  */
77
111
  getAll() {
78
- return this.components;
112
+ return this.layers;
79
113
  }
80
114
  /**
81
- * Get the length of the components
115
+ * Gets the number of components in the group.
116
+ * @returns {number} The number of components in the group.
82
117
  */
83
118
  get length() {
84
- return this.components.length;
119
+ return this.layers.length;
85
120
  }
121
+ /**
122
+ * Converts the group to a JSON representation.
123
+ * @returns {IGroup} The JSON representation of the group.
124
+ */
86
125
  toJSON() {
87
126
  return {
88
127
  id: this.id,
128
+ type: this.type,
89
129
  visible: this.visible,
90
130
  zIndex: this.zIndex,
91
- components: this.components.map(c => c.toJSON())
131
+ layers: this.layers.map(c => c.toJSON())
92
132
  };
93
133
  }
94
134
  }
@@ -1,25 +1,98 @@
1
- import { BaseLayer } from "./BaseLayer";
2
- import { IImageLayer, IImageLayerProps, ScaleType } from "../../types";
3
- import { Canvas, SKRSContext2D } from "@napi-rs/canvas";
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
4
+ import { ScaleType, LayerType } from "../../types";
5
+ import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
4
6
  import { LayersManager } from "../managers/LayersManager";
7
+ /**
8
+ * Interface representing an Image Layer.
9
+ */
10
+ export interface IImageLayer extends IBaseLayer {
11
+ /**
12
+ * The type of the layer, which is `Image`.
13
+ */
14
+ type: LayerType.Image;
15
+ /**
16
+ * The properties specific to the Image Layer.
17
+ */
18
+ props: IImageLayerProps;
19
+ }
20
+ /**
21
+ * Interface representing the properties of an Image Layer.
22
+ */
23
+ export interface IImageLayerProps extends IBaseLayerProps {
24
+ /**
25
+ * The source of the image, which can be a URL or a Buffer.
26
+ */
27
+ src: string | Buffer;
28
+ /**
29
+ * Whether the image should be resized.
30
+ */
31
+ resize: boolean;
32
+ /**
33
+ * The size of the image, including width, height, and radius.
34
+ */
35
+ size: {
36
+ /**
37
+ * The width of the image.
38
+ */
39
+ width: ScaleType;
40
+ /**
41
+ * The height of the image.
42
+ */
43
+ height: ScaleType;
44
+ /**
45
+ * The radius of the image.
46
+ */
47
+ radius: ScaleType;
48
+ };
49
+ }
50
+ /**
51
+ * Class representing an Image Layer, extending the BaseLayer class.
52
+ */
5
53
  export declare class ImageLayer extends BaseLayer<IImageLayerProps> {
54
+ /**
55
+ * The properties of the Image Layer.
56
+ */
6
57
  props: IImageLayerProps;
7
- constructor(props?: IImageLayerProps);
8
58
  /**
9
- * @description Sets the source of the image, it can be like link to website or path to file.
10
- * @param src {string} - The `src` of the image.
59
+ * Constructs a new ImageLayer instance.
60
+ * @param props {IImageLayerProps} - The properties of the Image Layer.
61
+ * @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
62
+ */
63
+ constructor(props?: IImageLayerProps, misc?: IBaseLayerMisc);
64
+ /**
65
+ * Sets the source of the image.
66
+ * @param src {string} - The source of the image, which can be a URL or file path.
67
+ * @returns {this} The current instance for chaining.
68
+ * @throws {LazyError} If the source is not a valid URL.
11
69
  */
12
70
  setSrc(src: string): this;
13
71
  /**
14
- * @description Set the size of the image. You can use `numbers`, `percentages`, `px`, `vw`, `vh`, `vmin`, `vmax`.
15
- * @param width {ScaleType} - The `width` of the image.
16
- * @param height {ScaleType} - The `height` of the image.
17
- * @param radius {ScaleType} - The `radius` of the image. (optional)
72
+ * Sets the size of the image.
73
+ * @param width {ScaleType} - The width of the image.
74
+ * @param height {ScaleType} - The height of the image.
75
+ * @param radius {ScaleType} - The radius of the image (optional).
76
+ * @returns {this} The current instance for chaining.
18
77
  */
19
78
  setSize(width: ScaleType, height: ScaleType, radius?: ScaleType): this;
20
- draw(ctx: SKRSContext2D, canvas: Canvas, manager: LayersManager, debug: boolean): Promise<void>;
21
79
  /**
22
- * @returns {IImageLayer}
80
+ * Disables resizing for the image.
81
+ * @returns {this} The current instance for chaining.
82
+ */
83
+ dontResize(): this;
84
+ /**
85
+ * Draws the Image Layer on the canvas.
86
+ * @param ctx {SKRSContext2D} - The canvas rendering context.
87
+ * @param canvas {Canvas | SvgCanvas} - The canvas instance.
88
+ * @param manager {LayersManager} - The layers manager.
89
+ * @param debug {boolean} - Whether to enable debug logging.
90
+ * @throws {LazyError} If the image could not be loaded.
91
+ */
92
+ draw(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager, debug: boolean): Promise<void>;
93
+ /**
94
+ * Converts the Image Layer to a JSON representation.
95
+ * @returns {IImageLayer} The JSON representation of the Image Layer.
23
96
  */
24
97
  toJSON(): IImageLayer;
25
98
  }
@@ -1,45 +1,35 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.ImageLayer = void 0;
27
4
  const BaseLayer_1 = require("./BaseLayer");
28
- const enum_1 = require("../../types/enum");
5
+ const types_1 = require("../../types");
29
6
  const canvas_1 = require("@napi-rs/canvas");
30
7
  const utils_1 = require("../../utils/utils");
31
8
  const LazyUtil_1 = require("../../utils/LazyUtil");
32
- const jimp = __importStar(require("jimp"));
9
+ /**
10
+ * Class representing an Image Layer, extending the BaseLayer class.
11
+ */
33
12
  class ImageLayer extends BaseLayer_1.BaseLayer {
13
+ /**
14
+ * The properties of the Image Layer.
15
+ */
34
16
  props;
35
- constructor(props) {
36
- super(enum_1.LayerType.Image, props || {});
17
+ /**
18
+ * Constructs a new ImageLayer instance.
19
+ * @param props {IImageLayerProps} - The properties of the Image Layer.
20
+ * @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
21
+ */
22
+ constructor(props, misc) {
23
+ super(types_1.LayerType.Image, props || {}, misc);
37
24
  this.props = props ? props : {};
38
- this.props.centring = enum_1.Centring.Center;
25
+ this.props.centring = types_1.Centring.Center;
26
+ this.props.resize = true;
39
27
  }
40
28
  /**
41
- * @description Sets the source of the image, it can be like link to website or path to file.
42
- * @param src {string} - The `src` of the image.
29
+ * Sets the source of the image.
30
+ * @param src {string} - The source of the image, which can be a URL or file path.
31
+ * @returns {this} The current instance for chaining.
32
+ * @throws {LazyError} If the source is not a valid URL.
43
33
  */
44
34
  setSrc(src) {
45
35
  if (!(0, utils_1.isImageUrlValid)(src))
@@ -48,10 +38,11 @@ class ImageLayer extends BaseLayer_1.BaseLayer {
48
38
  return this;
49
39
  }
50
40
  /**
51
- * @description Set the size of the image. You can use `numbers`, `percentages`, `px`, `vw`, `vh`, `vmin`, `vmax`.
52
- * @param width {ScaleType} - The `width` of the image.
53
- * @param height {ScaleType} - The `height` of the image.
54
- * @param radius {ScaleType} - The `radius` of the image. (optional)
41
+ * Sets the size of the image.
42
+ * @param width {ScaleType} - The width of the image.
43
+ * @param height {ScaleType} - The height of the image.
44
+ * @param radius {ScaleType} - The radius of the image (optional).
45
+ * @returns {this} The current instance for chaining.
55
46
  */
56
47
  setSize(width, height, radius) {
57
48
  this.props.size = {
@@ -61,6 +52,22 @@ class ImageLayer extends BaseLayer_1.BaseLayer {
61
52
  };
62
53
  return this;
63
54
  }
55
+ /**
56
+ * Disables resizing for the image.
57
+ * @returns {this} The current instance for chaining.
58
+ */
59
+ dontResize() {
60
+ this.props.resize = false;
61
+ return this;
62
+ }
63
+ /**
64
+ * Draws the Image Layer on the canvas.
65
+ * @param ctx {SKRSContext2D} - The canvas rendering context.
66
+ * @param canvas {Canvas | SvgCanvas} - The canvas instance.
67
+ * @param manager {LayersManager} - The layers manager.
68
+ * @param debug {boolean} - Whether to enable debug logging.
69
+ * @throws {LazyError} If the image could not be loaded.
70
+ */
64
71
  async draw(ctx, canvas, manager, debug) {
65
72
  const parcer = (0, utils_1.parser)(ctx, canvas, manager);
66
73
  const { xs, ys, w } = parcer.parseBatch({
@@ -78,9 +85,9 @@ class ImageLayer extends BaseLayer_1.BaseLayer {
78
85
  (0, utils_1.drawShadow)(ctx, this.props.shadow);
79
86
  (0, utils_1.opacity)(ctx, this.props.opacity);
80
87
  (0, utils_1.filters)(ctx, this.props.filter);
81
- let jmp = await jimp.read(this.props.src);
82
- jmp.resize(w, h);
83
- let image = await (0, canvas_1.loadImage)(await jmp.getBufferAsync('image/png'));
88
+ let image = await (0, canvas_1.loadImage)(this.props.src);
89
+ image.width = w;
90
+ image.height = h;
84
91
  if (!image)
85
92
  throw new LazyUtil_1.LazyError('The image could not be loaded');
86
93
  if (r) {
@@ -100,11 +107,17 @@ class ImageLayer extends BaseLayer_1.BaseLayer {
100
107
  ctx.restore();
101
108
  }
102
109
  /**
103
- * @returns {IImageLayer}
110
+ * Converts the Image Layer to a JSON representation.
111
+ * @returns {IImageLayer} The JSON representation of the Image Layer.
104
112
  */
105
113
  toJSON() {
106
114
  let data = super.toJSON();
107
- data.props = this.props;
115
+ let copy = { ...this.props };
116
+ for (const key of ['x', 'y', 'size.width', 'size.height', 'size.radius']) {
117
+ if (copy[key] && typeof copy[key] === 'object' && 'toJSON' in copy[key]) {
118
+ copy[key] = copy[key].toJSON();
119
+ }
120
+ }
108
121
  return { ...data };
109
122
  }
110
123
  }
@@ -1,32 +1,114 @@
1
- import { BaseLayer } from "./BaseLayer";
2
- import { ColorType, ILineLayer, ILineLayerProps, ScaleType } from "../../types/";
3
- import { Canvas, SKRSContext2D } from "@napi-rs/canvas";
1
+ import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
2
+ import { ColorType, ScaleType, LayerType } from "../../types";
3
+ import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
4
4
  import { LayersManager } from "../managers/LayersManager";
5
+ /**
6
+ * Interface representing a Line Layer.
7
+ */
8
+ export interface ILineLayer extends IBaseLayer {
9
+ /**
10
+ * The type of the layer, which is `Line`.
11
+ */
12
+ type: LayerType.Line;
13
+ /**
14
+ * The properties specific to the Line Layer.
15
+ */
16
+ props: ILineLayerProps;
17
+ }
18
+ /**
19
+ * Interface representing the properties of a Line Layer.
20
+ */
21
+ export interface ILineLayerProps extends IBaseLayerProps {
22
+ /**
23
+ * The end point of the line, including x and y coordinates.
24
+ */
25
+ endPoint: {
26
+ /**
27
+ * The x-coordinate of the end point.
28
+ */
29
+ x: ScaleType;
30
+ /**
31
+ * The y-coordinate of the end point.
32
+ */
33
+ y: ScaleType;
34
+ };
35
+ /**
36
+ * The stroke properties of the line.
37
+ */
38
+ stroke: {
39
+ /**
40
+ * The width of the stroke.
41
+ */
42
+ width: number;
43
+ /**
44
+ * The cap style of the stroke.
45
+ */
46
+ cap: CanvasLineCap;
47
+ /**
48
+ * The join style of the stroke.
49
+ */
50
+ join: CanvasLineJoin;
51
+ /**
52
+ * The dash offset of the stroke.
53
+ */
54
+ dashOffset: number;
55
+ /**
56
+ * The dash pattern of the stroke.
57
+ */
58
+ dash: number[];
59
+ /**
60
+ * The miter limit of the stroke.
61
+ */
62
+ miterLimit: number;
63
+ };
64
+ }
65
+ /**
66
+ * Class representing a Line Layer, extending the BaseLayer class.
67
+ */
5
68
  export declare class LineLayer extends BaseLayer<ILineLayerProps> {
69
+ /**
70
+ * The properties of the Line Layer.
71
+ */
6
72
  props: ILineLayerProps;
7
- constructor(props?: ILineLayerProps);
8
73
  /**
9
- * @description Sets the end point of the line layer. You can use `numbers`, `percentages`, `px`, `vw`, `vh`, `vmin`, `vmax`.
10
- * @param x {ScaleType} - The end `x` of the line layer.
11
- * @param y {ScaleType} - The end `y` of the line layer.
74
+ * Constructs a new LineLayer instance.
75
+ * @param props {ILineLayerProps} - The properties of the Line Layer.
76
+ * @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
77
+ */
78
+ constructor(props?: ILineLayerProps, misc?: IBaseLayerMisc);
79
+ /**
80
+ * Sets the end position of the line layer.
81
+ * @param x {ScaleType} - The x-coordinate of the end point.
82
+ * @param y {ScaleType} - The y-coordinate of the end point.
83
+ * @returns {this} The current instance for chaining.
12
84
  */
13
85
  setEndPosition(x: ScaleType, y: ScaleType): this;
14
86
  /**
15
- * @description Sets the color of the layer. You can use `hex`, `rgb`, `rgba`, `hsl`, `hsla`, and `Gradient`color.
16
- * @param color {string} - The `color` of the layer.
87
+ * Sets the color of the line layer.
88
+ * @param color {ColorType} - The color of the line.
89
+ * @returns {this} The current instance for chaining.
90
+ * @throws {LazyError} If the color is not provided or invalid.
17
91
  */
18
92
  setColor(color: ColorType): this;
19
93
  /**
20
- * @description Sets the stroke of the layer.
21
- * @param width {number} - The `width` of the stroke.
22
- * @param cap {string} - The `cap` of the stroke.
23
- * @param join {string} - The `join` of the stroke.
24
- * @param dash {number[]} - The `dash` of the stroke.
25
- * @param dashOffset {number} - The `dashOffset` of the stroke.
26
- * @param miterLimit {number} - The `miterLimit` of the stroke.
94
+ * Sets the stroke properties of the line layer.
95
+ * @param width {number} - The width of the stroke.
96
+ * @param cap {CanvasLineCap} - The cap style of the stroke.
97
+ * @param join {CanvasLineJoin} - The join style of the stroke.
98
+ * @param dash {number[]} - The dash pattern of the stroke.
99
+ * @param dashOffset {number} - The dash offset of the stroke.
100
+ * @param miterLimit {number} - The miter limit of the stroke.
101
+ * @returns {this} The current instance for chaining.
27
102
  */
28
103
  setStroke(width: number, cap?: CanvasLineCap, join?: CanvasLineJoin, dash?: number[], dashOffset?: number, miterLimit?: number): this;
29
- getBoundingBox(ctx: SKRSContext2D, canvas: Canvas, manager: LayersManager): {
104
+ /**
105
+ * Calculates the bounding box of the line layer.
106
+ * @param ctx {SKRSContext2D} - The canvas rendering context.
107
+ * @param canvas {Canvas | SvgCanvas} - The canvas instance.
108
+ * @param manager {LayersManager} - The layers manager.
109
+ * @returns {Object} The bounding box details including start and end points, width, and height.
110
+ */
111
+ getBoundingBox(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager): {
30
112
  xs: number;
31
113
  ys: number;
32
114
  xe: number;
@@ -34,6 +116,17 @@ export declare class LineLayer extends BaseLayer<ILineLayerProps> {
34
116
  width: number;
35
117
  height: number;
36
118
  };
37
- draw(ctx: SKRSContext2D, canvas: Canvas, manager: LayersManager, debug: boolean): Promise<void>;
119
+ /**
120
+ * Draws the line layer on the canvas.
121
+ * @param ctx {SKRSContext2D} - The canvas rendering context.
122
+ * @param canvas {Canvas | SvgCanvas} - The canvas instance.
123
+ * @param manager {LayersManager} - The layers manager.
124
+ * @param debug {boolean} - Whether to enable debug logging.
125
+ */
126
+ draw(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager, debug: boolean): Promise<void>;
127
+ /**
128
+ * Converts the Line Layer to a JSON representation.
129
+ * @returns {ILineLayer} The JSON representation of the Line Layer.
130
+ */
38
131
  toJSON(): ILineLayer;
39
132
  }