@nmmty/lazycanvas 0.6.0-dev.f33019 → 0.6.1

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 (58) hide show
  1. package/dist/helpers/Utlis.d.ts +28 -0
  2. package/dist/helpers/Utlis.js +78 -0
  3. package/dist/helpers/index.d.ts +3 -0
  4. package/dist/helpers/index.js +19 -0
  5. package/dist/index.d.ts +5 -10
  6. package/dist/index.js +5 -29
  7. package/dist/structures/LazyCanvas.d.ts +46 -13
  8. package/dist/structures/LazyCanvas.js +66 -22
  9. package/dist/structures/components/BaseLayer.d.ts +16 -16
  10. package/dist/structures/components/BaseLayer.js +17 -17
  11. package/dist/structures/components/BezierLayer.d.ts +21 -21
  12. package/dist/structures/components/BezierLayer.js +20 -20
  13. package/dist/structures/components/ClearLayer.d.ts +15 -15
  14. package/dist/structures/components/ClearLayer.js +14 -14
  15. package/dist/structures/components/Group.d.ts +10 -11
  16. package/dist/structures/components/Group.js +9 -10
  17. package/dist/structures/components/ImageLayer.d.ts +12 -14
  18. package/dist/structures/components/ImageLayer.js +11 -11
  19. package/dist/structures/components/LineLayer.d.ts +20 -20
  20. package/dist/structures/components/LineLayer.js +19 -19
  21. package/dist/structures/components/MorphLayer.d.ts +18 -24
  22. package/dist/structures/components/MorphLayer.js +18 -26
  23. package/dist/structures/components/Path2DLayer.d.ts +4 -78
  24. package/dist/structures/components/Path2DLayer.js +2 -116
  25. package/dist/structures/components/QuadraticLayer.d.ts +22 -22
  26. package/dist/structures/components/QuadraticLayer.js +21 -21
  27. package/dist/structures/components/TextLayer.d.ts +37 -43
  28. package/dist/structures/components/TextLayer.js +37 -45
  29. package/dist/structures/helpers/Exporter.d.ts +9 -11
  30. package/dist/structures/helpers/Exporter.js +49 -32
  31. package/dist/structures/helpers/Font.d.ts +4 -6
  32. package/dist/structures/helpers/Font.js +4 -4
  33. package/dist/structures/helpers/Gradient.d.ts +15 -10
  34. package/dist/structures/helpers/Gradient.js +14 -9
  35. package/dist/structures/helpers/Link.d.ts +5 -5
  36. package/dist/structures/helpers/Link.js +5 -5
  37. package/dist/structures/helpers/Pattern.d.ts +5 -5
  38. package/dist/structures/helpers/Pattern.js +5 -5
  39. package/dist/structures/helpers/index.d.ts +7 -7
  40. package/dist/structures/helpers/readers/JSONReader.d.ts +12 -12
  41. package/dist/structures/helpers/readers/JSONReader.js +29 -19
  42. package/dist/structures/helpers/readers/YAMLReader.d.ts +4 -4
  43. package/dist/structures/helpers/readers/YAMLReader.js +21 -11
  44. package/dist/structures/managers/AnimationManager.d.ts +11 -11
  45. package/dist/structures/managers/AnimationManager.js +11 -11
  46. package/dist/structures/managers/FontsManager.d.ts +14 -15
  47. package/dist/structures/managers/FontsManager.js +14 -15
  48. package/dist/structures/managers/LayersManager.d.ts +22 -12
  49. package/dist/structures/managers/LayersManager.js +27 -12
  50. package/dist/structures/managers/PluginManager.d.ts +230 -0
  51. package/dist/structures/managers/PluginManager.js +182 -0
  52. package/dist/structures/managers/RenderManager.d.ts +10 -12
  53. package/dist/structures/managers/RenderManager.js +31 -16
  54. package/dist/structures/managers/index.d.ts +5 -0
  55. package/dist/structures/managers/index.js +21 -0
  56. package/dist/utils/utils.d.ts +1 -1
  57. package/dist/utils/utils.js +15 -16
  58. package/package.json +59 -56
@@ -15,8 +15,8 @@ class TextLayer extends BaseLayer_1.BaseLayer {
15
15
  props;
16
16
  /**
17
17
  * Constructs a new TextLayer instance.
18
- * @param props {ITextLayerProps} - The properties of the Text Layer.
19
- * @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
18
+ * @param {ITextLayerProps} [props] - The properties of the Text Layer.
19
+ * @param {IBaseLayerMisc} [misc] - Miscellaneous options for the layer.
20
20
  */
21
21
  constructor(props, misc) {
22
22
  super(types_1.LayerType.Text, props || {}, misc);
@@ -25,7 +25,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
25
25
  }
26
26
  /**
27
27
  * Sets the text of the text layer.
28
- * @param text {string} - The text content of the layer.
28
+ * @param {string} [text] - The text content of the layer.
29
29
  * @returns {this} The current instance for chaining.
30
30
  */
31
31
  setText(text) {
@@ -34,9 +34,9 @@ class TextLayer extends BaseLayer_1.BaseLayer {
34
34
  }
35
35
  /**
36
36
  * Sets the font of the text layer.
37
- * @param familyOrConfig {string | { family: string; size: number; weight: AnyWeight }} - The font family or configuration object.
38
- * @param size {number} - The font size (required if `familyOrConfig` is a string).
39
- * @param weight {AnyWeight} - The font weight (required if `familyOrConfig` is a string).
37
+ * @param {string | { family: string; size: number; weight: AnyWeight }} [familyOrConfig] - The font family or configuration object.
38
+ * @param {number} [size] - The font size (required if `familyOrConfig` is a string).
39
+ * @param {AnyWeight} [weight] - The font weight (required if `familyOrConfig` is a string).
40
40
  * @returns {this} The current instance for chaining.
41
41
  * @throws {LazyError} If size or weight is not provided when `familyOrConfig` is a string.
42
42
  */
@@ -63,10 +63,10 @@ class TextLayer extends BaseLayer_1.BaseLayer {
63
63
  }
64
64
  /**
65
65
  * Configures the multiline properties of the text layer.
66
- * @param enabled {boolean} - Whether multiline is enabled.
67
- * @param width {ScaleType} - The width of the multiline text area.
68
- * @param height {ScaleType} - The height of the multiline text area.
69
- * @param spacing {number} - The spacing between lines (optional).
66
+ * @param {boolean} [enabled] - Whether multiline is enabled.
67
+ * @param {ScaleType} [width] - The width of the multiline text area.
68
+ * @param {ScaleType} [height] - The height of the multiline text area.
69
+ * @param {number} [spacing] - The spacing between lines (optional).
70
70
  * @returns {this} The current instance for chaining.
71
71
  */
72
72
  setMultiline(enabled, width, height, spacing) {
@@ -82,7 +82,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
82
82
  }
83
83
  /**
84
84
  * Sets the color of the text layer.
85
- * @param color {ColorType} - The color of the text.
85
+ * @param {ColorType} [color] - The color of the text.
86
86
  * @returns {this} The current instance for chaining.
87
87
  * @throws {LazyError} If the color is not provided or invalid.
88
88
  */
@@ -96,7 +96,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
96
96
  }
97
97
  /**
98
98
  * Sets the alignment of the text layer.
99
- * @param align {AnyTextAlign} - The alignment of the text.
99
+ * @param {AnyTextAlign} [align] - The alignment of the text.
100
100
  * @returns {this} The current instance for chaining.
101
101
  */
102
102
  setAlign(align) {
@@ -105,7 +105,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
105
105
  }
106
106
  /**
107
107
  * Sets the baseline of the text layer.
108
- * @param baseline {AnyTextBaseline} - The baseline of the text.
108
+ * @param {AnyTextBaseline} [baseline] - The baseline of the text.
109
109
  * @returns {this} The current instance for chaining.
110
110
  */
111
111
  setBaseline(baseline) {
@@ -114,7 +114,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
114
114
  }
115
115
  /**
116
116
  * Sets the direction of the text layer.
117
- * @param direction {AnyTextDirection} - The direction of the text.
117
+ * @param {AnyTextDirection} [direction] - The direction of the text.
118
118
  * @returns {this} The current instance for chaining.
119
119
  */
120
120
  setDirection(direction) {
@@ -123,12 +123,12 @@ class TextLayer extends BaseLayer_1.BaseLayer {
123
123
  }
124
124
  /**
125
125
  * Configures the stroke properties of the text layer.
126
- * @param width {number} - The width of the stroke.
127
- * @param cap {string} - The cap style of the stroke (optional).
128
- * @param join {string} - The join style of the stroke (optional).
129
- * @param dash {number[]} - The dash pattern of the stroke (optional).
130
- * @param dashOffset {number} - The dash offset of the stroke (optional).
131
- * @param miterLimit {number} - The miter limit of the stroke (optional).
126
+ * @param {number} [width] - The width of the stroke.
127
+ * @param {string} [cap] - The cap style of the stroke.
128
+ * @param {string} [join] - The join style of the stroke.
129
+ * @param {number[]} [dash] - The dash pattern of the stroke.
130
+ * @param {number} [dashOffset] - The dash offset of the stroke.
131
+ * @param {number} [miterLimit] - The miter limit of the stroke.
132
132
  * @returns {this} The current instance for chaining.
133
133
  */
134
134
  setStroke(width, cap, join, dash, dashOffset, miterLimit) {
@@ -140,20 +140,12 @@ class TextLayer extends BaseLayer_1.BaseLayer {
140
140
  dashOffset: dashOffset || 0,
141
141
  miterLimit: miterLimit || 10,
142
142
  };
143
- return this;
144
- }
145
- /**
146
- * Sets whether the text layer should be filled or stroked.
147
- * @param filled {boolean} - If true, the layer will be filled; otherwise, it will be stroked.
148
- * @returns {this} The current instance for chaining.
149
- */
150
- setFilled(filled) {
151
- this.props.filled = filled;
143
+ this.props.filled = false; // Ensure filled is false when stroke is set
152
144
  return this;
153
145
  }
154
146
  /**
155
147
  * Sets the spacing between words in the text layer.
156
- * @param wordSpacing {number} - The spacing between words.
148
+ * @param {number} [wordSpacing] - The spacing between words.
157
149
  * @returns {this} The current instance for chaining.
158
150
  */
159
151
  setWordSpacing(wordSpacing) {
@@ -162,7 +154,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
162
154
  }
163
155
  /**
164
156
  * Sets the spacing between letters in the text layer.
165
- * @param letterSpacing {number} - The spacing between letters.
157
+ * @param {number} [letterSpacing] - The spacing between letters.
166
158
  * @returns {this} The current instance for chaining.
167
159
  */
168
160
  setLetterSpacing(letterSpacing) {
@@ -171,8 +163,8 @@ class TextLayer extends BaseLayer_1.BaseLayer {
171
163
  }
172
164
  /**
173
165
  * Measures the dimensions of the text.
174
- * @param ctx {SKRSContext2D} - The canvas rendering context.
175
- * @param canvas {Canvas | SvgCanvas} - The canvas instance.
166
+ * @param {SKRSContext2D} [ctx] - The canvas rendering context.
167
+ * @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
176
168
  * @returns {Object} The width and height of the text.
177
169
  */
178
170
  measureText(ctx, canvas) {
@@ -189,10 +181,10 @@ class TextLayer extends BaseLayer_1.BaseLayer {
189
181
  }
190
182
  /**
191
183
  * Draws the text layer on the canvas.
192
- * @param ctx {SKRSContext2D} - The canvas rendering context.
193
- * @param canvas {Canvas | SvgCanvas} - The canvas instance.
194
- * @param manager {LayersManager} - The layers manager.
195
- * @param debug {boolean} - Whether to enable debug logging.
184
+ * @param {SKRSContext2D} [ctx] - The canvas rendering context.
185
+ * @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
186
+ * @param {LayersManager} [manager] - The layers manager.
187
+ * @param {boolean} [debug] - Whether to enable debug logging.
196
188
  */
197
189
  async draw(ctx, canvas, manager, debug) {
198
190
  const parcer = (0, utils_1.parser)(ctx, canvas, manager);
@@ -258,13 +250,13 @@ class TextLayer extends BaseLayer_1.BaseLayer {
258
250
  }
259
251
  /**
260
252
  * Draws the text on the canvas.
261
- * @param props {ITextLayerProps} - The properties of the text layer.
262
- * @param ctx {SKRSContext2D} - The canvas rendering context.
263
- * @param fillStyle {string | CanvasGradient | CanvasPattern} - The fill style for the text.
264
- * @param text {string} - The text content.
265
- * @param x {number} - The x-coordinate of the text.
266
- * @param y {number} - The y-coordinate of the text.
267
- * @param w {number} - The width of the text area.
253
+ * @param {ITextLayerProps} [props] - The properties of the text layer.
254
+ * @param {SKRSContext2D} [ctx] - The canvas rendering context.
255
+ * @param {string | CanvasGradient | CanvasPattern} [fillStyle] - The fill style for the text.
256
+ * @param {string} [text] - The text content.
257
+ * @param {number} [x] - The x-coordinate of the text.
258
+ * @param {number} [y] - The y-coordinate of the text.
259
+ * @param {number} [w] - The width of the text area.
268
260
  */
269
261
  drawText(props, ctx, fillStyle, text, x, y, w) {
270
262
  if (props.filled) {
@@ -298,7 +290,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
298
290
  }
299
291
  /**
300
292
  * Validates the properties of the Text Layer.
301
- * @param props {ITextLayerProps} - The properties to validate.
293
+ * @param {ITextLayerProps} [props] - The properties to validate.
302
294
  * @returns {ITextLayerProps} The validated properties.
303
295
  */
304
296
  validateProps(props) {
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { IOLazyCanvas, LazyCanvas } from "../LazyCanvas";
4
2
  import { AnyExport } from "../../types";
5
3
  import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
@@ -18,24 +16,24 @@ export declare class Exporter {
18
16
  constructor(canvas: LazyCanvas);
19
17
  /**
20
18
  * Saves a file to the filesystem.
21
- * @param buffer {any} - The data to be saved.
22
- * @param extension {Extensions} - The file extension.
23
- * @param name {string} - The name of the file (optional).
19
+ * @param {any} [buffer] - The data to be saved.
20
+ * @param {Extensions} [extension] - The file extension.
21
+ * @param {string} [name] - The name of the file (optional).
24
22
  * @throws {LazyError} If the buffer or extension is not provided.
25
23
  */
26
24
  private saveFile;
27
25
  /**
28
26
  * Exports all layers from the LayersManager as an array of JSON objects.
29
- * @param manager {LayersManager} - The LayersManager instance.
27
+ * @param {LayersManager} [manager] - The LayersManager instance.
30
28
  * @returns {any[]} An array of JSON representations of the layers.
31
29
  */
32
30
  private exportLayers;
33
31
  /**
34
32
  * Exports the canvas to the specified format.
35
- * @param exportType {AnyExport} - The type of export (e.g., "png", "json").
36
- * @param opts {Object} - Optional settings.
37
- * @param opts.name {string} - The name of the file (optional).
38
- * @param opts.saveAsFile {boolean} - Whether to save the export as a file (optional).
33
+ * @param {AnyExport} [exportType] - The type of export (e.g., "png", "json").
34
+ * @param {Object} [opts] - Optional settings.
35
+ * @param {string} [opts.name] - The name of the file (optional).
36
+ * @param {boolean} [opts.saveAsFile] - Whether to save the export as a file (optional).
39
37
  * @returns {Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>} The exported data.
40
38
  * @throws {LazyError} If the export type is not supported.
41
39
  */
@@ -45,7 +43,7 @@ export declare class Exporter {
45
43
  }): Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>;
46
44
  /**
47
45
  * Synchronously exports the canvas to the specified format.
48
- * @param exportType {AnyExport} - The type of export (e.g., "json").
46
+ * @param {AnyExport} [exportType] - The type of export (e.g., "json").
49
47
  * @returns {IOLazyCanvas | void} The exported data or void if the export type is unsupported.
50
48
  */
51
49
  syncExport(exportType: AnyExport): IOLazyCanvas | void;
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.Exporter = void 0;
27
37
  const types_1 = require("../../types");
@@ -46,9 +56,9 @@ class Exporter {
46
56
  }
47
57
  /**
48
58
  * Saves a file to the filesystem.
49
- * @param buffer {any} - The data to be saved.
50
- * @param extension {Extensions} - The file extension.
51
- * @param name {string} - The name of the file (optional).
59
+ * @param {any} [buffer] - The data to be saved.
60
+ * @param {Extensions} [extension] - The file extension.
61
+ * @param {string} [name] - The name of the file (optional).
52
62
  * @throws {LazyError} If the buffer or extension is not provided.
53
63
  */
54
64
  async saveFile(buffer, extension, name) {
@@ -60,7 +70,7 @@ class Exporter {
60
70
  }
61
71
  /**
62
72
  * Exports all layers from the LayersManager as an array of JSON objects.
63
- * @param manager {LayersManager} - The LayersManager instance.
73
+ * @param {LayersManager} [manager] - The LayersManager instance.
64
74
  * @returns {any[]} An array of JSON representations of the layers.
65
75
  */
66
76
  exportLayers(manager) {
@@ -72,51 +82,55 @@ class Exporter {
72
82
  }
73
83
  /**
74
84
  * Exports the canvas to the specified format.
75
- * @param exportType {AnyExport} - The type of export (e.g., "png", "json").
76
- * @param opts {Object} - Optional settings.
77
- * @param opts.name {string} - The name of the file (optional).
78
- * @param opts.saveAsFile {boolean} - Whether to save the export as a file (optional).
85
+ * @param {AnyExport} [exportType] - The type of export (e.g., "png", "json").
86
+ * @param {Object} [opts] - Optional settings.
87
+ * @param {string} [opts.name] - The name of the file (optional).
88
+ * @param {boolean} [opts.saveAsFile] - Whether to save the export as a file (optional).
79
89
  * @returns {Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>} The exported data.
80
90
  * @throws {LazyError} If the export type is not supported.
81
91
  */
82
92
  async export(exportType, opts) {
93
+ // beforeExport hook
94
+ this.canvas.manager.plugins.executeHook('beforeExport', this.canvas);
95
+ let result;
83
96
  switch (exportType) {
84
97
  case types_1.Export.CTX:
85
98
  case "ctx":
86
- return await this.canvas.manager.render.render(exportType);
99
+ result = await this.canvas.manager.render.render(exportType);
100
+ break;
87
101
  case types_1.Export.SVG:
88
102
  case "svg":
89
- const svg = await this.canvas.manager.render.render('svg');
103
+ result = await this.canvas.manager.render.render('svg');
90
104
  if (opts?.saveAsFile) {
91
- await this.saveFile(svg, 'svg', opts.name);
105
+ await this.saveFile(result, 'svg', opts.name);
92
106
  }
93
- return svg;
107
+ break;
94
108
  case types_1.Export.BUFFER:
95
109
  case "buffer":
96
- const buffer = await this.canvas.manager.render.render('buffer');
110
+ result = await this.canvas.manager.render.render('buffer');
97
111
  if (opts?.saveAsFile) {
98
- await this.saveFile(buffer, 'png', opts.name);
112
+ await this.saveFile(result, 'png', opts.name);
99
113
  }
100
- return buffer;
114
+ break;
101
115
  case types_1.Export.GIF:
102
116
  case "gif":
103
- const gif = await this.canvas.manager.render.render('buffer');
117
+ result = await this.canvas.manager.render.render('buffer');
104
118
  if (opts?.saveAsFile) {
105
- await this.saveFile(gif, 'gif', opts.name);
119
+ await this.saveFile(result, 'gif', opts.name);
106
120
  }
107
- return gif;
121
+ break;
108
122
  case types_1.Export.WEBP:
109
123
  case "webp":
110
- const webp = await this.canvas.manager.render.render('buffer');
124
+ result = await this.canvas.manager.render.render('buffer');
111
125
  if (opts?.saveAsFile) {
112
- await this.saveFile(webp, 'webp', opts.name);
126
+ await this.saveFile(result, 'webp', opts.name);
113
127
  }
114
- return webp;
128
+ break;
115
129
  case types_1.Export.JPEG:
116
130
  case "jpeg":
117
- const jpeg = await this.canvas.manager.render.render('buffer');
118
- await this.saveFile(jpeg, 'jpeg', opts?.name);
119
- return jpeg;
131
+ result = await this.canvas.manager.render.render('buffer');
132
+ await this.saveFile(result, 'jpeg', opts?.name);
133
+ break;
120
134
  case types_1.Export.JPG:
121
135
  case "jpg":
122
136
  const jpg = await this.canvas.manager.render.render('buffer');
@@ -147,10 +161,13 @@ class Exporter {
147
161
  default:
148
162
  throw new LazyUtil_1.LazyError(`Export type ${exportType} is not supported`);
149
163
  }
164
+ // afterExport hook
165
+ this.canvas.manager.plugins.executeHook('afterExport', this.canvas, result);
166
+ return result;
150
167
  }
151
168
  /**
152
169
  * Synchronously exports the canvas to the specified format.
153
- * @param exportType {AnyExport} - The type of export (e.g., "json").
170
+ * @param {AnyExport} [exportType] - The type of export (e.g., "json").
154
171
  * @returns {IOLazyCanvas | void} The exported data or void if the export type is unsupported.
155
172
  */
156
173
  syncExport(exportType) {
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { AnyWeight } from "../../types";
4
2
  /**
5
3
  * Interface representing a font.
@@ -55,28 +53,28 @@ export declare class Font implements IFont {
55
53
  constructor();
56
54
  /**
57
55
  * Sets the font family.
58
- * @param family {string} - The `family` of the font.
56
+ * @param {string} [family] - The `family` of the font.
59
57
  * @returns {this} The current instance for chaining.
60
58
  * @throws {Error} If the family is not provided.
61
59
  */
62
60
  setFamily(family: string): this;
63
61
  /**
64
62
  * Sets the font weight.
65
- * @param weight {AnyWeight} - The `weight` of the font.
63
+ * @param {AnyWeight} [weight] - The `weight` of the font.
66
64
  * @returns {this} The current instance for chaining.
67
65
  * @throws {Error} If the weight is not provided.
68
66
  */
69
67
  setWeight(weight: AnyWeight): this;
70
68
  /**
71
69
  * Sets the file path of the font.
72
- * @param path {string} - The `path` of the font.
70
+ * @param {string} [path] - The `path` of the font.
73
71
  * @returns {this} The current instance for chaining.
74
72
  * @throws {Error} If the path is not provided.
75
73
  */
76
74
  setPath(path: string): this;
77
75
  /**
78
76
  * Sets the base64 representation of the font.
79
- * @param base64 {Buffer} - The `base64` of the font.
77
+ * @param {Buffer} [base64] - The `base64` of the font.
80
78
  * @returns {this} The current instance for chaining.
81
79
  * @throws {Error} If the base64 is not provided.
82
80
  */
@@ -31,7 +31,7 @@ class Font {
31
31
  }
32
32
  /**
33
33
  * Sets the font family.
34
- * @param family {string} - The `family` of the font.
34
+ * @param {string} [family] - The `family` of the font.
35
35
  * @returns {this} The current instance for chaining.
36
36
  * @throws {Error} If the family is not provided.
37
37
  */
@@ -43,7 +43,7 @@ class Font {
43
43
  }
44
44
  /**
45
45
  * Sets the font weight.
46
- * @param weight {AnyWeight} - The `weight` of the font.
46
+ * @param {AnyWeight} [weight] - The `weight` of the font.
47
47
  * @returns {this} The current instance for chaining.
48
48
  * @throws {Error} If the weight is not provided.
49
49
  */
@@ -55,7 +55,7 @@ class Font {
55
55
  }
56
56
  /**
57
57
  * Sets the file path of the font.
58
- * @param path {string} - The `path` of the font.
58
+ * @param {string} [path] - The `path` of the font.
59
59
  * @returns {this} The current instance for chaining.
60
60
  * @throws {Error} If the path is not provided.
61
61
  */
@@ -67,7 +67,7 @@ class Font {
67
67
  }
68
68
  /**
69
69
  * Sets the base64 representation of the font.
70
- * @param base64 {Buffer} - The `base64` of the font.
70
+ * @param {Buffer} [base64] - The `base64` of the font.
71
71
  * @returns {this} The current instance for chaining.
72
72
  * @throws {Error} If the base64 is not provided.
73
73
  */
@@ -1,6 +1,6 @@
1
1
  import { AnyCentring, AnyGradientType, FillType, StringColorType, ScaleType } from "../../types";
2
2
  import { SKRSContext2D } from "@napi-rs/canvas";
3
- import { LayersManager } from "../managers/LayersManager";
3
+ import { LayersManager } from "../managers";
4
4
  /**
5
5
  * Interface representing a gradient.
6
6
  */
@@ -82,54 +82,59 @@ export declare class Gradient implements IGradient {
82
82
  angle?: number;
83
83
  /**
84
84
  * Constructs a new Gradient instance.
85
- * @param opts {Object} - Optional properties for the gradient.
86
- * @param opts.props {IGradient} - The gradient properties.
85
+ * @param {Object} [opts] - Optional properties for the gradient.
86
+ * @param {IGradient} [opts.props] - The gradient properties.
87
87
  */
88
88
  constructor(opts?: {
89
89
  props?: IGradient;
90
90
  });
91
91
  /**
92
92
  * Sets the type of the gradient.
93
- * @param type {AnyGradientType} - The type of the gradient (e.g., linear, radial, conic).
93
+ * @param {AnyGradientType} [type] - The type of the gradient (e.g., linear, radial, conic).
94
94
  * @returns {this} The current instance for chaining.
95
95
  */
96
96
  setType(type: AnyGradientType): this;
97
97
  /**
98
98
  * Adds points to the gradient.
99
- * @param points {GradientPoint[]} - The points to add to the gradient.
99
+ * @param {GradientPoint[]} [points] - The points to add to the gradient.
100
100
  * @returns {this} The current instance for chaining.
101
101
  */
102
102
  addPoints(...points: GradientPoint[]): this;
103
103
  /**
104
104
  * Sets the points of the gradient.
105
- * @param points {GradientPoint[]} - The points to set for the gradient.
105
+ * @param {GradientPoint[]} [points] - The points to set for the gradient.
106
106
  * @returns {this} The current instance for chaining.
107
107
  */
108
108
  setPoints(...points: GradientPoint[]): this;
109
109
  /**
110
110
  * Removes points from the gradient by their indexes.
111
- * @param indexes {number[]} - The indexes of the points to remove.
111
+ * @param {number[]} [indexes] - The indexes of the points to remove.
112
112
  * @returns {this} The current instance for chaining.
113
113
  */
114
114
  removePoints(...indexes: number[]): this;
115
115
  /**
116
116
  * Adds color stops to the gradient.
117
- * @param stops {GradientColorStop[]} - The color stops to add to the gradient.
117
+ * @param {GradientColorStop[]} [stops] - The color stops to add to the gradient.
118
118
  * @returns {this} The current instance for chaining.
119
119
  */
120
120
  addStops(...stops: GradientColorStop[]): this;
121
121
  /**
122
122
  * Sets the color stops of the gradient.
123
- * @param stops {GradientColorStop[]} - The color stops to set for the gradient.
123
+ * @param {GradientColorStop[]} [stops] - The color stops to set for the gradient.
124
124
  * @returns {this} The current instance for chaining.
125
125
  */
126
126
  setStops(...stops: GradientColorStop[]): this;
127
127
  /**
128
128
  * Removes color stops from the gradient by their indexes.
129
- * @param indexes {number[]} - The indexes of the color stops to remove.
129
+ * @param {number[]} [indexes] - The indexes of the color stops to remove.
130
130
  * @returns {this} The current instance for chaining.
131
131
  */
132
132
  removeStops(...indexes: number[]): this;
133
+ /**
134
+ * Sets the angle of the gradient (used for linear gradients).
135
+ * @param {number} [angle] - The angle in degrees.
136
+ * @returns {this} The current instance for chaining.
137
+ */
133
138
  setAngle(angle: number): this;
134
139
  draw(ctx: SKRSContext2D, opts?: {
135
140
  debug?: boolean;
@@ -30,8 +30,8 @@ class Gradient {
30
30
  angle;
31
31
  /**
32
32
  * Constructs a new Gradient instance.
33
- * @param opts {Object} - Optional properties for the gradient.
34
- * @param opts.props {IGradient} - The gradient properties.
33
+ * @param {Object} [opts] - Optional properties for the gradient.
34
+ * @param {IGradient} [opts.props] - The gradient properties.
35
35
  */
36
36
  constructor(opts) {
37
37
  this.type = opts?.props?.type || types_1.GradientType.Linear;
@@ -41,7 +41,7 @@ class Gradient {
41
41
  }
42
42
  /**
43
43
  * Sets the type of the gradient.
44
- * @param type {AnyGradientType} - The type of the gradient (e.g., linear, radial, conic).
44
+ * @param {AnyGradientType} [type] - The type of the gradient (e.g., linear, radial, conic).
45
45
  * @returns {this} The current instance for chaining.
46
46
  */
47
47
  setType(type) {
@@ -50,7 +50,7 @@ class Gradient {
50
50
  }
51
51
  /**
52
52
  * Adds points to the gradient.
53
- * @param points {GradientPoint[]} - The points to add to the gradient.
53
+ * @param {GradientPoint[]} [points] - The points to add to the gradient.
54
54
  * @returns {this} The current instance for chaining.
55
55
  */
56
56
  addPoints(...points) {
@@ -59,7 +59,7 @@ class Gradient {
59
59
  }
60
60
  /**
61
61
  * Sets the points of the gradient.
62
- * @param points {GradientPoint[]} - The points to set for the gradient.
62
+ * @param {GradientPoint[]} [points] - The points to set for the gradient.
63
63
  * @returns {this} The current instance for chaining.
64
64
  */
65
65
  setPoints(...points) {
@@ -68,7 +68,7 @@ class Gradient {
68
68
  }
69
69
  /**
70
70
  * Removes points from the gradient by their indexes.
71
- * @param indexes {number[]} - The indexes of the points to remove.
71
+ * @param {number[]} [indexes] - The indexes of the points to remove.
72
72
  * @returns {this} The current instance for chaining.
73
73
  */
74
74
  removePoints(...indexes) {
@@ -77,7 +77,7 @@ class Gradient {
77
77
  }
78
78
  /**
79
79
  * Adds color stops to the gradient.
80
- * @param stops {GradientColorStop[]} - The color stops to add to the gradient.
80
+ * @param {GradientColorStop[]} [stops] - The color stops to add to the gradient.
81
81
  * @returns {this} The current instance for chaining.
82
82
  */
83
83
  addStops(...stops) {
@@ -86,7 +86,7 @@ class Gradient {
86
86
  }
87
87
  /**
88
88
  * Sets the color stops of the gradient.
89
- * @param stops {GradientColorStop[]} - The color stops to set for the gradient.
89
+ * @param {GradientColorStop[]} [stops] - The color stops to set for the gradient.
90
90
  * @returns {this} The current instance for chaining.
91
91
  */
92
92
  setStops(...stops) {
@@ -95,13 +95,18 @@ class Gradient {
95
95
  }
96
96
  /**
97
97
  * Removes color stops from the gradient by their indexes.
98
- * @param indexes {number[]} - The indexes of the color stops to remove.
98
+ * @param {number[]} [indexes] - The indexes of the color stops to remove.
99
99
  * @returns {this} The current instance for chaining.
100
100
  */
101
101
  removeStops(...indexes) {
102
102
  this.stops = this.stops.filter((_, index) => !indexes.includes(index));
103
103
  return this;
104
104
  }
105
+ /**
106
+ * Sets the angle of the gradient (used for linear gradients).
107
+ * @param {number} [angle] - The angle in degrees.
108
+ * @returns {this} The current instance for chaining.
109
+ */
105
110
  setAngle(angle) {
106
111
  this.angle = angle;
107
112
  return this;
@@ -34,27 +34,27 @@ export declare class Link {
34
34
  additionalSpacing: ScaleType;
35
35
  /**
36
36
  * Constructs a new Link instance.
37
- * @param opts {Object} - Optional properties for the link.
38
- * @param opts.props {ILink} - The link properties.
37
+ * @param {Object} [opts] - Optional properties for the link.
38
+ * @param {ILink} [opts.props] - The link properties.
39
39
  */
40
40
  constructor(opts?: {
41
41
  props?: ILink;
42
42
  });
43
43
  /**
44
44
  * Sets the source of the link.
45
- * @param source {string} - The ID of the layer to link.
45
+ * @param {string} [source] - The ID of the layer to link.
46
46
  * @returns {this} The current instance for chaining.
47
47
  */
48
48
  setSource(source: string): this;
49
49
  /**
50
50
  * Sets the type of the link.
51
- * @param type {AnyLinkType} - The type of the link.
51
+ * @param {AnyLinkType} [type] - The type of the link.
52
52
  * @returns {this} The current instance for chaining.
53
53
  */
54
54
  setType(type: AnyLinkType): this;
55
55
  /**
56
56
  * Sets the additional spacing of the link.
57
- * @param additionalSpacing {ScaleType} - The additional spacing of the link.
57
+ * @param {ScaleType} [additionalSpacing] - The additional spacing of the link.
58
58
  * @returns {this} The current instance for chaining.
59
59
  */
60
60
  setSpacing(additionalSpacing: ScaleType): this;