@nmmty/lazycanvas 0.6.0 → 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 (57) hide show
  1. package/dist/helpers/index.d.ts +3 -0
  2. package/dist/helpers/index.js +19 -0
  3. package/dist/index.d.ts +5 -12
  4. package/dist/index.js +5 -31
  5. package/dist/structures/LazyCanvas.d.ts +12 -16
  6. package/dist/structures/LazyCanvas.js +24 -27
  7. package/dist/structures/components/BaseLayer.d.ts +16 -16
  8. package/dist/structures/components/BaseLayer.js +16 -16
  9. package/dist/structures/components/BezierLayer.d.ts +21 -21
  10. package/dist/structures/components/BezierLayer.js +20 -20
  11. package/dist/structures/components/ClearLayer.d.ts +15 -15
  12. package/dist/structures/components/ClearLayer.js +14 -14
  13. package/dist/structures/components/Group.d.ts +10 -11
  14. package/dist/structures/components/Group.js +9 -10
  15. package/dist/structures/components/ImageLayer.d.ts +12 -12
  16. package/dist/structures/components/ImageLayer.js +11 -11
  17. package/dist/structures/components/LineLayer.d.ts +20 -20
  18. package/dist/structures/components/LineLayer.js +19 -19
  19. package/dist/structures/components/MorphLayer.d.ts +18 -18
  20. package/dist/structures/components/MorphLayer.js +17 -17
  21. package/dist/structures/components/Path2DLayer.d.ts +4 -72
  22. package/dist/structures/components/Path2DLayer.js +2 -108
  23. package/dist/structures/components/QuadraticLayer.d.ts +22 -22
  24. package/dist/structures/components/QuadraticLayer.js +21 -21
  25. package/dist/structures/components/TextLayer.d.ts +37 -37
  26. package/dist/structures/components/TextLayer.js +36 -36
  27. package/dist/structures/helpers/Exporter.d.ts +9 -9
  28. package/dist/structures/helpers/Exporter.js +9 -9
  29. package/dist/structures/helpers/Font.d.ts +4 -4
  30. package/dist/structures/helpers/Font.js +4 -4
  31. package/dist/structures/helpers/Gradient.d.ts +15 -10
  32. package/dist/structures/helpers/Gradient.js +14 -9
  33. package/dist/structures/helpers/Link.d.ts +5 -5
  34. package/dist/structures/helpers/Link.js +5 -5
  35. package/dist/structures/helpers/Pattern.d.ts +5 -5
  36. package/dist/structures/helpers/Pattern.js +5 -5
  37. package/dist/structures/helpers/index.d.ts +7 -7
  38. package/dist/structures/helpers/readers/JSONReader.d.ts +12 -12
  39. package/dist/structures/helpers/readers/JSONReader.js +12 -12
  40. package/dist/structures/helpers/readers/YAMLReader.d.ts +4 -4
  41. package/dist/structures/helpers/readers/YAMLReader.js +4 -4
  42. package/dist/structures/managers/AnimationManager.d.ts +11 -11
  43. package/dist/structures/managers/AnimationManager.js +11 -11
  44. package/dist/structures/managers/FontsManager.d.ts +14 -15
  45. package/dist/structures/managers/FontsManager.js +14 -15
  46. package/dist/structures/managers/LayersManager.d.ts +15 -15
  47. package/dist/structures/managers/LayersManager.js +19 -19
  48. package/dist/structures/managers/PluginManager.d.ts +11 -9
  49. package/dist/structures/managers/PluginManager.js +9 -8
  50. package/dist/structures/managers/RenderManager.d.ts +10 -10
  51. package/dist/structures/managers/RenderManager.js +10 -10
  52. package/dist/structures/managers/index.d.ts +5 -0
  53. package/dist/structures/managers/index.js +21 -0
  54. package/dist/types/index.d.ts +0 -1
  55. package/dist/types/index.js +0 -1
  56. package/dist/utils/utils.d.ts +1 -1
  57. package/package.json +59 -60
@@ -1,7 +1,7 @@
1
1
  import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
2
2
  import { ScaleType, ColorType, AnyWeight, AnyTextAlign, AnyTextBaseline, AnyTextDirection, LineCap, LineJoin, LayerType } from "../../types";
3
3
  import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
4
- import { LayersManager } from "../managers/LayersManager";
4
+ import { LayersManager } from "../managers";
5
5
  /**
6
6
  * Interface representing a Text Layer.
7
7
  */
@@ -126,21 +126,21 @@ export declare class TextLayer extends BaseLayer<ITextLayerProps> {
126
126
  props: ITextLayerProps;
127
127
  /**
128
128
  * Constructs a new TextLayer instance.
129
- * @param props {ITextLayerProps} - The properties of the Text Layer.
130
- * @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
129
+ * @param {ITextLayerProps} [props] - The properties of the Text Layer.
130
+ * @param {IBaseLayerMisc} [misc] - Miscellaneous options for the layer.
131
131
  */
132
132
  constructor(props?: ITextLayerProps, misc?: IBaseLayerMisc);
133
133
  /**
134
134
  * Sets the text of the text layer.
135
- * @param text {string} - The text content of the layer.
135
+ * @param {string} [text] - The text content of the layer.
136
136
  * @returns {this} The current instance for chaining.
137
137
  */
138
138
  setText(text: string): this;
139
139
  /**
140
140
  * Sets the font of the text layer.
141
- * @param familyOrConfig {string | { family: string; size: number; weight: AnyWeight }} - The font family or configuration object.
142
- * @param size {number} - The font size (required if `familyOrConfig` is a string).
143
- * @param weight {AnyWeight} - The font weight (required if `familyOrConfig` is a string).
141
+ * @param {string | { family: string; size: number; weight: AnyWeight }} [familyOrConfig] - The font family or configuration object.
142
+ * @param {number} [size] - The font size (required if `familyOrConfig` is a string).
143
+ * @param {AnyWeight} [weight] - The font weight (required if `familyOrConfig` is a string).
144
144
  * @returns {this} The current instance for chaining.
145
145
  * @throws {LazyError} If size or weight is not provided when `familyOrConfig` is a string.
146
146
  */
@@ -151,65 +151,65 @@ export declare class TextLayer extends BaseLayer<ITextLayerProps> {
151
151
  }, size?: number, weight?: AnyWeight): this;
152
152
  /**
153
153
  * Configures the multiline properties of the text layer.
154
- * @param enabled {boolean} - Whether multiline is enabled.
155
- * @param width {ScaleType} - The width of the multiline text area.
156
- * @param height {ScaleType} - The height of the multiline text area.
157
- * @param spacing {number} - The spacing between lines (optional).
154
+ * @param {boolean} [enabled] - Whether multiline is enabled.
155
+ * @param {ScaleType} [width] - The width of the multiline text area.
156
+ * @param {ScaleType} [height] - The height of the multiline text area.
157
+ * @param {number} [spacing] - The spacing between lines (optional).
158
158
  * @returns {this} The current instance for chaining.
159
159
  */
160
160
  setMultiline(enabled: boolean, width: ScaleType, height: ScaleType, spacing?: number): this;
161
161
  /**
162
162
  * Sets the color of the text layer.
163
- * @param color {ColorType} - The color of the text.
163
+ * @param {ColorType} [color] - The color of the text.
164
164
  * @returns {this} The current instance for chaining.
165
165
  * @throws {LazyError} If the color is not provided or invalid.
166
166
  */
167
167
  setColor(color: ColorType): this;
168
168
  /**
169
169
  * Sets the alignment of the text layer.
170
- * @param align {AnyTextAlign} - The alignment of the text.
170
+ * @param {AnyTextAlign} [align] - The alignment of the text.
171
171
  * @returns {this} The current instance for chaining.
172
172
  */
173
173
  setAlign(align: AnyTextAlign): this;
174
174
  /**
175
175
  * Sets the baseline of the text layer.
176
- * @param baseline {AnyTextBaseline} - The baseline of the text.
176
+ * @param {AnyTextBaseline} [baseline] - The baseline of the text.
177
177
  * @returns {this} The current instance for chaining.
178
178
  */
179
179
  setBaseline(baseline: AnyTextBaseline): this;
180
180
  /**
181
181
  * Sets the direction of the text layer.
182
- * @param direction {AnyTextDirection} - The direction of the text.
182
+ * @param {AnyTextDirection} [direction] - The direction of the text.
183
183
  * @returns {this} The current instance for chaining.
184
184
  */
185
185
  setDirection(direction: AnyTextDirection): this;
186
186
  /**
187
187
  * Configures the stroke properties of the text layer.
188
- * @param width {number} - The width of the stroke.
189
- * @param cap {string} - The cap style of the stroke (optional).
190
- * @param join {string} - The join style of the stroke (optional).
191
- * @param dash {number[]} - The dash pattern of the stroke (optional).
192
- * @param dashOffset {number} - The dash offset of the stroke (optional).
193
- * @param miterLimit {number} - The miter limit of the stroke (optional).
188
+ * @param {number} [width] - The width of the stroke.
189
+ * @param {string} [cap] - The cap style of the stroke.
190
+ * @param {string} [join] - The join style of the stroke.
191
+ * @param {number[]} [dash] - The dash pattern of the stroke.
192
+ * @param {number} [dashOffset] - The dash offset of the stroke.
193
+ * @param {number} [miterLimit] - The miter limit of the stroke.
194
194
  * @returns {this} The current instance for chaining.
195
195
  */
196
196
  setStroke(width: number, cap?: LineCap, join?: LineJoin, dash?: number[], dashOffset?: number, miterLimit?: number): this;
197
197
  /**
198
198
  * Sets the spacing between words in the text layer.
199
- * @param wordSpacing {number} - The spacing between words.
199
+ * @param {number} [wordSpacing] - The spacing between words.
200
200
  * @returns {this} The current instance for chaining.
201
201
  */
202
202
  setWordSpacing(wordSpacing: number): this;
203
203
  /**
204
204
  * Sets the spacing between letters in the text layer.
205
- * @param letterSpacing {number} - The spacing between letters.
205
+ * @param {number} [letterSpacing] - The spacing between letters.
206
206
  * @returns {this} The current instance for chaining.
207
207
  */
208
208
  setLetterSpacing(letterSpacing: number): this;
209
209
  /**
210
210
  * Measures the dimensions of the text.
211
- * @param ctx {SKRSContext2D} - The canvas rendering context.
212
- * @param canvas {Canvas | SvgCanvas} - The canvas instance.
211
+ * @param {SKRSContext2D} [ctx] - The canvas rendering context.
212
+ * @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
213
213
  * @returns {Object} The width and height of the text.
214
214
  */
215
215
  measureText(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas): {
@@ -218,21 +218,21 @@ export declare class TextLayer extends BaseLayer<ITextLayerProps> {
218
218
  };
219
219
  /**
220
220
  * Draws the text layer on the canvas.
221
- * @param ctx {SKRSContext2D} - The canvas rendering context.
222
- * @param canvas {Canvas | SvgCanvas} - The canvas instance.
223
- * @param manager {LayersManager} - The layers manager.
224
- * @param debug {boolean} - Whether to enable debug logging.
221
+ * @param {SKRSContext2D} [ctx] - The canvas rendering context.
222
+ * @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
223
+ * @param {LayersManager} [manager] - The layers manager.
224
+ * @param {boolean} [debug] - Whether to enable debug logging.
225
225
  */
226
226
  draw(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager, debug: boolean): Promise<void>;
227
227
  /**
228
228
  * Draws the text on the canvas.
229
- * @param props {ITextLayerProps} - The properties of the text layer.
230
- * @param ctx {SKRSContext2D} - The canvas rendering context.
231
- * @param fillStyle {string | CanvasGradient | CanvasPattern} - The fill style for the text.
232
- * @param text {string} - The text content.
233
- * @param x {number} - The x-coordinate of the text.
234
- * @param y {number} - The y-coordinate of the text.
235
- * @param w {number} - The width of the text area.
229
+ * @param {ITextLayerProps} [props] - The properties of the text layer.
230
+ * @param {SKRSContext2D} [ctx] - The canvas rendering context.
231
+ * @param {string | CanvasGradient | CanvasPattern} [fillStyle] - The fill style for the text.
232
+ * @param {string} [text] - The text content.
233
+ * @param {number} [x] - The x-coordinate of the text.
234
+ * @param {number} [y] - The y-coordinate of the text.
235
+ * @param {number} [w] - The width of the text area.
236
236
  */
237
237
  private drawText;
238
238
  /**
@@ -242,7 +242,7 @@ export declare class TextLayer extends BaseLayer<ITextLayerProps> {
242
242
  toJSON(): ITextLayer;
243
243
  /**
244
244
  * Validates the properties of the Text Layer.
245
- * @param props {ITextLayerProps} - The properties to validate.
245
+ * @param {ITextLayerProps} [props] - The properties to validate.
246
246
  * @returns {ITextLayerProps} The validated properties.
247
247
  */
248
248
  protected validateProps(props: ITextLayerProps): ITextLayerProps;
@@ -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) {
@@ -145,7 +145,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
145
145
  }
146
146
  /**
147
147
  * Sets the spacing between words in the text layer.
148
- * @param wordSpacing {number} - The spacing between words.
148
+ * @param {number} [wordSpacing] - The spacing between words.
149
149
  * @returns {this} The current instance for chaining.
150
150
  */
151
151
  setWordSpacing(wordSpacing) {
@@ -154,7 +154,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
154
154
  }
155
155
  /**
156
156
  * Sets the spacing between letters in the text layer.
157
- * @param letterSpacing {number} - The spacing between letters.
157
+ * @param {number} [letterSpacing] - The spacing between letters.
158
158
  * @returns {this} The current instance for chaining.
159
159
  */
160
160
  setLetterSpacing(letterSpacing) {
@@ -163,8 +163,8 @@ class TextLayer extends BaseLayer_1.BaseLayer {
163
163
  }
164
164
  /**
165
165
  * Measures the dimensions of the text.
166
- * @param ctx {SKRSContext2D} - The canvas rendering context.
167
- * @param canvas {Canvas | SvgCanvas} - The canvas instance.
166
+ * @param {SKRSContext2D} [ctx] - The canvas rendering context.
167
+ * @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
168
168
  * @returns {Object} The width and height of the text.
169
169
  */
170
170
  measureText(ctx, canvas) {
@@ -181,10 +181,10 @@ class TextLayer extends BaseLayer_1.BaseLayer {
181
181
  }
182
182
  /**
183
183
  * Draws the text layer on the canvas.
184
- * @param ctx {SKRSContext2D} - The canvas rendering context.
185
- * @param canvas {Canvas | SvgCanvas} - The canvas instance.
186
- * @param manager {LayersManager} - The layers manager.
187
- * @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.
188
188
  */
189
189
  async draw(ctx, canvas, manager, debug) {
190
190
  const parcer = (0, utils_1.parser)(ctx, canvas, manager);
@@ -250,13 +250,13 @@ class TextLayer extends BaseLayer_1.BaseLayer {
250
250
  }
251
251
  /**
252
252
  * Draws the text on the canvas.
253
- * @param props {ITextLayerProps} - The properties of the text layer.
254
- * @param ctx {SKRSContext2D} - The canvas rendering context.
255
- * @param fillStyle {string | CanvasGradient | CanvasPattern} - The fill style for the text.
256
- * @param text {string} - The text content.
257
- * @param x {number} - The x-coordinate of the text.
258
- * @param y {number} - The y-coordinate of the text.
259
- * @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.
260
260
  */
261
261
  drawText(props, ctx, fillStyle, text, x, y, w) {
262
262
  if (props.filled) {
@@ -290,7 +290,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
290
290
  }
291
291
  /**
292
292
  * Validates the properties of the Text Layer.
293
- * @param props {ITextLayerProps} - The properties to validate.
293
+ * @param {ITextLayerProps} [props] - The properties to validate.
294
294
  * @returns {ITextLayerProps} The validated properties.
295
295
  */
296
296
  validateProps(props) {
@@ -16,24 +16,24 @@ export declare class Exporter {
16
16
  constructor(canvas: LazyCanvas);
17
17
  /**
18
18
  * Saves a file to the filesystem.
19
- * @param buffer {any} - The data to be saved.
20
- * @param extension {Extensions} - The file extension.
21
- * @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).
22
22
  * @throws {LazyError} If the buffer or extension is not provided.
23
23
  */
24
24
  private saveFile;
25
25
  /**
26
26
  * Exports all layers from the LayersManager as an array of JSON objects.
27
- * @param manager {LayersManager} - The LayersManager instance.
27
+ * @param {LayersManager} [manager] - The LayersManager instance.
28
28
  * @returns {any[]} An array of JSON representations of the layers.
29
29
  */
30
30
  private exportLayers;
31
31
  /**
32
32
  * Exports the canvas to the specified format.
33
- * @param exportType {AnyExport} - The type of export (e.g., "png", "json").
34
- * @param opts {Object} - Optional settings.
35
- * @param opts.name {string} - The name of the file (optional).
36
- * @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).
37
37
  * @returns {Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>} The exported data.
38
38
  * @throws {LazyError} If the export type is not supported.
39
39
  */
@@ -43,7 +43,7 @@ export declare class Exporter {
43
43
  }): Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>;
44
44
  /**
45
45
  * Synchronously exports the canvas to the specified format.
46
- * @param exportType {AnyExport} - The type of export (e.g., "json").
46
+ * @param {AnyExport} [exportType] - The type of export (e.g., "json").
47
47
  * @returns {IOLazyCanvas | void} The exported data or void if the export type is unsupported.
48
48
  */
49
49
  syncExport(exportType: AnyExport): IOLazyCanvas | void;
@@ -56,9 +56,9 @@ class Exporter {
56
56
  }
57
57
  /**
58
58
  * Saves a file to the filesystem.
59
- * @param buffer {any} - The data to be saved.
60
- * @param extension {Extensions} - The file extension.
61
- * @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).
62
62
  * @throws {LazyError} If the buffer or extension is not provided.
63
63
  */
64
64
  async saveFile(buffer, extension, name) {
@@ -70,7 +70,7 @@ class Exporter {
70
70
  }
71
71
  /**
72
72
  * Exports all layers from the LayersManager as an array of JSON objects.
73
- * @param manager {LayersManager} - The LayersManager instance.
73
+ * @param {LayersManager} [manager] - The LayersManager instance.
74
74
  * @returns {any[]} An array of JSON representations of the layers.
75
75
  */
76
76
  exportLayers(manager) {
@@ -82,10 +82,10 @@ class Exporter {
82
82
  }
83
83
  /**
84
84
  * Exports the canvas to the specified format.
85
- * @param exportType {AnyExport} - The type of export (e.g., "png", "json").
86
- * @param opts {Object} - Optional settings.
87
- * @param opts.name {string} - The name of the file (optional).
88
- * @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).
89
89
  * @returns {Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>} The exported data.
90
90
  * @throws {LazyError} If the export type is not supported.
91
91
  */
@@ -167,7 +167,7 @@ class Exporter {
167
167
  }
168
168
  /**
169
169
  * Synchronously exports the canvas to the specified format.
170
- * @param exportType {AnyExport} - The type of export (e.g., "json").
170
+ * @param {AnyExport} [exportType] - The type of export (e.g., "json").
171
171
  * @returns {IOLazyCanvas | void} The exported data or void if the export type is unsupported.
172
172
  */
173
173
  syncExport(exportType) {
@@ -53,28 +53,28 @@ export declare class Font implements IFont {
53
53
  constructor();
54
54
  /**
55
55
  * Sets the font family.
56
- * @param family {string} - The `family` of the font.
56
+ * @param {string} [family] - The `family` of the font.
57
57
  * @returns {this} The current instance for chaining.
58
58
  * @throws {Error} If the family is not provided.
59
59
  */
60
60
  setFamily(family: string): this;
61
61
  /**
62
62
  * Sets the font weight.
63
- * @param weight {AnyWeight} - The `weight` of the font.
63
+ * @param {AnyWeight} [weight] - The `weight` of the font.
64
64
  * @returns {this} The current instance for chaining.
65
65
  * @throws {Error} If the weight is not provided.
66
66
  */
67
67
  setWeight(weight: AnyWeight): this;
68
68
  /**
69
69
  * Sets the file path of the font.
70
- * @param path {string} - The `path` of the font.
70
+ * @param {string} [path] - The `path` of the font.
71
71
  * @returns {this} The current instance for chaining.
72
72
  * @throws {Error} If the path is not provided.
73
73
  */
74
74
  setPath(path: string): this;
75
75
  /**
76
76
  * Sets the base64 representation of the font.
77
- * @param base64 {Buffer} - The `base64` of the font.
77
+ * @param {Buffer} [base64] - The `base64` of the font.
78
78
  * @returns {this} The current instance for chaining.
79
79
  * @throws {Error} If the base64 is not provided.
80
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;