@nmmty/lazycanvas 0.6.5 → 1.0.0-dev.3

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 (80) hide show
  1. package/ReadMe.md +1 -1
  2. package/biome.json +41 -0
  3. package/dist/core/Interpolation.d.ts +30 -0
  4. package/dist/core/Interpolation.js +200 -0
  5. package/dist/core/Scene.d.ts +96 -0
  6. package/dist/core/Scene.js +172 -0
  7. package/dist/core/Signal.d.ts +133 -0
  8. package/dist/core/Signal.js +255 -0
  9. package/dist/core/SignalUtils.d.ts +133 -0
  10. package/dist/core/SignalUtils.js +333 -0
  11. package/dist/core/ThreadScheduler.d.ts +38 -0
  12. package/dist/core/ThreadScheduler.js +74 -0
  13. package/dist/helpers/Filters.js +1 -1
  14. package/dist/helpers/FontsList.js +18 -18
  15. package/dist/helpers/Utlis.d.ts +3 -3
  16. package/dist/helpers/Utlis.js +15 -18
  17. package/dist/helpers/index.d.ts +3 -3
  18. package/dist/index.d.ts +10 -0
  19. package/dist/index.js +10 -0
  20. package/dist/jsx-runtime.d.ts +17 -0
  21. package/dist/jsx-runtime.js +111 -0
  22. package/dist/structures/LazyCanvas.d.ts +3 -45
  23. package/dist/structures/LazyCanvas.js +11 -74
  24. package/dist/structures/components/BaseLayer.d.ts +34 -12
  25. package/dist/structures/components/BaseLayer.js +68 -35
  26. package/dist/structures/components/BezierLayer.d.ts +16 -37
  27. package/dist/structures/components/BezierLayer.js +83 -46
  28. package/dist/structures/components/{Group.d.ts → Div.d.ts} +22 -16
  29. package/dist/structures/components/{Group.js → Div.js} +38 -39
  30. package/dist/structures/components/ImageLayer.d.ts +1 -1
  31. package/dist/structures/components/ImageLayer.js +24 -25
  32. package/dist/structures/components/LineLayer.d.ts +11 -37
  33. package/dist/structures/components/LineLayer.js +42 -42
  34. package/dist/structures/components/MorphLayer.d.ts +3 -32
  35. package/dist/structures/components/MorphLayer.js +32 -46
  36. package/dist/structures/components/Path2DLayer.d.ts +4 -32
  37. package/dist/structures/components/Path2DLayer.js +28 -33
  38. package/dist/structures/components/PolygonLayer.d.ts +2 -31
  39. package/dist/structures/components/PolygonLayer.js +35 -38
  40. package/dist/structures/components/QuadraticLayer.d.ts +16 -33
  41. package/dist/structures/components/QuadraticLayer.js +80 -42
  42. package/dist/structures/components/TextLayer.d.ts +4 -33
  43. package/dist/structures/components/TextLayer.js +60 -62
  44. package/dist/structures/components/index.d.ts +10 -11
  45. package/dist/structures/components/index.js +1 -2
  46. package/dist/structures/helpers/Exporter.d.ts +13 -4
  47. package/dist/structures/helpers/Exporter.js +79 -42
  48. package/dist/structures/helpers/Font.js +1 -17
  49. package/dist/structures/helpers/Gradient.js +32 -45
  50. package/dist/structures/helpers/Link.js +2 -14
  51. package/dist/structures/helpers/Pattern.js +9 -17
  52. package/dist/structures/helpers/index.d.ts +7 -7
  53. package/dist/structures/helpers/readers/JSONReader.d.ts +4 -4
  54. package/dist/structures/helpers/readers/JSONReader.js +32 -40
  55. package/dist/structures/helpers/readers/YAMLReader.js +5 -5
  56. package/dist/structures/managers/FontsManager.js +9 -18
  57. package/dist/structures/managers/LayersManager.d.ts +18 -28
  58. package/dist/structures/managers/LayersManager.js +14 -36
  59. package/dist/structures/managers/RenderManager.d.ts +1 -15
  60. package/dist/structures/managers/RenderManager.js +17 -110
  61. package/dist/structures/managers/index.d.ts +3 -5
  62. package/dist/structures/managers/index.js +0 -2
  63. package/dist/types/enum.d.ts +1 -2
  64. package/dist/types/enum.js +1 -2
  65. package/dist/types/index.d.ts +1 -1
  66. package/dist/utils/APNGEncoder.d.ts +67 -0
  67. package/dist/utils/APNGEncoder.js +205 -0
  68. package/dist/utils/DrawUtils.d.ts +9 -0
  69. package/dist/utils/DrawUtils.js +42 -0
  70. package/dist/utils/LazyUtil.js +1 -2
  71. package/dist/utils/utils.d.ts +4 -7
  72. package/dist/utils/utils.js +133 -76
  73. package/package.json +62 -59
  74. package/dist/structures/components/ClearLayer.d.ts +0 -147
  75. package/dist/structures/components/ClearLayer.js +0 -158
  76. package/dist/structures/managers/AnimationManager.d.ts +0 -120
  77. package/dist/structures/managers/AnimationManager.js +0 -99
  78. package/dist/structures/managers/PluginManager.d.ts +0 -230
  79. package/dist/structures/managers/PluginManager.js +0 -182
  80. package/dist/types/types.d.ts +0 -107
@@ -5,8 +5,8 @@ const BaseLayer_1 = require("./BaseLayer");
5
5
  const types_1 = require("../../types");
6
6
  const LazyUtil_1 = require("../../utils/LazyUtil");
7
7
  const utils_1 = require("../../utils/utils");
8
+ const DrawUtils_1 = require("../../utils/DrawUtils");
8
9
  class PolygonLayer extends BaseLayer_1.BaseLayer {
9
- props;
10
10
  constructor(props, misc) {
11
11
  super(types_1.LayerType.Polygon, props || {}, misc);
12
12
  this.props = props ? props : {};
@@ -37,9 +37,9 @@ class PolygonLayer extends BaseLayer_1.BaseLayer {
37
37
  */
38
38
  setColor(color) {
39
39
  if (!color)
40
- throw new LazyUtil_1.LazyError('The color of the layer must be provided');
40
+ throw new LazyUtil_1.LazyError("The color of the layer must be provided");
41
41
  if (!(0, utils_1.isColor)(color))
42
- throw new LazyUtil_1.LazyError('The color of the layer must be a valid color');
42
+ throw new LazyUtil_1.LazyError("The color of the layer must be a valid color");
43
43
  this.props.fillStyle = color;
44
44
  return this;
45
45
  }
@@ -56,13 +56,12 @@ class PolygonLayer extends BaseLayer_1.BaseLayer {
56
56
  setStroke(width, cap, join, dash, dashOffset, miterLimit) {
57
57
  this.props.stroke = {
58
58
  width,
59
- cap: cap || 'butt',
60
- join: join || 'miter',
59
+ cap: cap || "butt",
60
+ join: join || "miter",
61
61
  dash: dash || [],
62
62
  dashOffset: dashOffset || 0,
63
63
  miterLimit: miterLimit || 10,
64
64
  };
65
- this.props.filled = false; // Ensure filled is false when stroke is set
66
65
  return this;
67
66
  }
68
67
  /**
@@ -75,15 +74,26 @@ class PolygonLayer extends BaseLayer_1.BaseLayer {
75
74
  async draw(ctx, canvas, manager, debug) {
76
75
  const parcer = (0, utils_1.parser)(ctx, canvas, manager);
77
76
  const { xs, ys, w } = parcer.parseBatch({
78
- xs: { v: this.props.x },
79
- ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
77
+ xs: { v: this.props.position.x },
78
+ ys: { v: this.props.position.y, options: LazyUtil_1.defaultArg.vl(true) },
80
79
  w: { v: this.props.size.width },
81
80
  });
82
81
  const h = parcer.parse(this.props.size.height, LazyUtil_1.defaultArg.wh(w), LazyUtil_1.defaultArg.vl(true));
83
82
  let { x, y } = (0, utils_1.centring)(this.props.centring, this.type, w, h, xs, ys);
84
- let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle, { debug, layer: { width: w, height: h, x: xs, y: ys, align: this.props.centring }, manager });
83
+ let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle, {
84
+ debug,
85
+ layer: { width: w, height: h, x: xs, y: ys, align: this.props.centring },
86
+ manager,
87
+ });
85
88
  if (debug)
86
- LazyUtil_1.LazyLog.log('none', `PolygonLayer:`, { x, y, w, h, count: this.props.size.count, radius: this.props.size.radius });
89
+ LazyUtil_1.LazyLog.log("none", `PolygonLayer:`, {
90
+ x,
91
+ y,
92
+ w,
93
+ h,
94
+ count: this.props.size.count,
95
+ radius: this.props.size.radius,
96
+ });
87
97
  ctx.save();
88
98
  ctx.beginPath();
89
99
  // Calculate polygon vertices
@@ -92,7 +102,7 @@ class PolygonLayer extends BaseLayer_1.BaseLayer {
92
102
  const angle = (i / this.props.size.count) * (2 * Math.PI) - Math.PI / 2;
93
103
  vertices.push({
94
104
  x: x + w / 2 + (w / 2) * Math.cos(angle),
95
- y: y + h / 2 + (h / 2) * Math.sin(angle)
105
+ y: y + h / 2 + (h / 2) * Math.sin(angle),
96
106
  });
97
107
  }
98
108
  if (this.props.size.radius > 0) {
@@ -119,11 +129,11 @@ class PolygonLayer extends BaseLayer_1.BaseLayer {
119
129
  // Calculate arc start and end points
120
130
  const arcStart = {
121
131
  x: current.x - ndx1 * cornerRadius,
122
- y: current.y - ndy1 * cornerRadius
132
+ y: current.y - ndy1 * cornerRadius,
123
133
  };
124
134
  const arcEnd = {
125
135
  x: current.x + ndx2 * cornerRadius,
126
- y: current.y + ndy2 * cornerRadius
136
+ y: current.y + ndy2 * cornerRadius,
127
137
  };
128
138
  if (i === 0) {
129
139
  ctx.moveTo(arcStart.x, arcStart.y);
@@ -148,20 +158,16 @@ class PolygonLayer extends BaseLayer_1.BaseLayer {
148
158
  }
149
159
  ctx.closePath();
150
160
  }
151
- if (this.props.filled) {
152
- ctx.fillStyle = fillStyle;
153
- ctx.fill();
154
- }
155
- if (this.props.stroke && this.props.stroke.width > 0) {
156
- ctx.lineWidth = this.props.stroke.width;
157
- ctx.lineCap = this.props.stroke.cap;
158
- ctx.lineJoin = this.props.stroke.join;
159
- ctx.setLineDash(this.props.stroke.dash);
160
- ctx.lineDashOffset = this.props.stroke.dashOffset;
161
- ctx.miterLimit = this.props.stroke.miterLimit;
162
- ctx.strokeStyle = fillStyle;
161
+ DrawUtils_1.DrawUtils.drawShadow(ctx, this.props.shadow);
162
+ DrawUtils_1.DrawUtils.opacity(ctx, this.props.opacity);
163
+ DrawUtils_1.DrawUtils.filters(ctx, this.props.filter);
164
+ DrawUtils_1.DrawUtils.fillStyle(ctx, fillStyle, this.props.stroke);
165
+ if (this.props.stroke) {
163
166
  ctx.stroke();
164
167
  }
168
+ else {
169
+ ctx.fill();
170
+ }
165
171
  ctx.restore();
166
172
  }
167
173
  /**
@@ -171,8 +177,8 @@ class PolygonLayer extends BaseLayer_1.BaseLayer {
171
177
  toJSON() {
172
178
  let data = super.toJSON();
173
179
  let copy = { ...this.props };
174
- for (const key of ['x', 'y', 'size.width', 'size.height', 'fillStyle']) {
175
- if (copy[key] && typeof copy[key] === 'object' && 'toJSON' in copy[key]) {
180
+ for (const key of ["x", "y", "size.width", "size.height", "fillStyle"]) {
181
+ if (copy[key] && typeof copy[key] === "object" && "toJSON" in copy[key]) {
176
182
  copy[key] = copy[key].toJSON();
177
183
  }
178
184
  }
@@ -190,18 +196,9 @@ class PolygonLayer extends BaseLayer_1.BaseLayer {
190
196
  width: data.size?.width || 100,
191
197
  height: data.size?.height || 100,
192
198
  radius: data.size?.radius || 0,
193
- count: data.size?.count || 3
199
+ count: data.size?.count || 3,
194
200
  },
195
- filled: data.filled !== undefined ? data.filled : true,
196
- fillStyle: data.fillStyle || '#000000',
197
- stroke: {
198
- width: data.stroke?.width || 1,
199
- cap: data.stroke?.cap || 'butt',
200
- join: data.stroke?.join || 'miter',
201
- dashOffset: data.stroke?.dashOffset || 0,
202
- dash: data.stroke?.dash || [],
203
- miterLimit: data.stroke?.miterLimit || 10
204
- }
201
+ fillStyle: data.fillStyle || "#000000",
205
202
  };
206
203
  }
207
204
  }
@@ -1,5 +1,5 @@
1
1
  import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
2
- import { ColorType, ScaleType, Point, LayerType } from "../../types";
2
+ import { ColorType, ScaleType, Point, LayerType, StrokeOptions } from "../../types";
3
3
  import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
4
4
  import { LayersManager } from "../managers";
5
5
  /**
@@ -19,14 +19,20 @@ export interface IQuadraticLayer extends IBaseLayer {
19
19
  * Interface representing the properties of a Quadratic layer.
20
20
  */
21
21
  export interface IQuadraticLayerProps extends IBaseLayerProps {
22
+ position: IBaseLayerProps["position"] & {
23
+ /**
24
+ * The end x coordinate of the quadratic curve.
25
+ */
26
+ endX: ScaleType;
27
+ /**
28
+ * The end y coordinate of the quadratic curve.
29
+ */
30
+ endY: ScaleType;
31
+ };
22
32
  /**
23
33
  * The control point of the quadratic curve, including x and y coordinates.
24
34
  */
25
35
  controlPoints: Array<Point>;
26
- /**
27
- * The end point of the quadratic curve, including x and y coordinates.
28
- */
29
- endPoint: Point;
30
36
  /**
31
37
  * Whether the layer is filled.
32
38
  */
@@ -38,32 +44,7 @@ export interface IQuadraticLayerProps extends IBaseLayerProps {
38
44
  /**
39
45
  * The stroke properties of the quadratic curve.
40
46
  */
41
- stroke: {
42
- /**
43
- * The width of the stroke.
44
- */
45
- width: number;
46
- /**
47
- * The cap style of the stroke.
48
- */
49
- cap: CanvasLineCap;
50
- /**
51
- * The join style of the stroke.
52
- */
53
- join: CanvasLineJoin;
54
- /**
55
- * The dash offset of the stroke.
56
- */
57
- dashOffset: number;
58
- /**
59
- * The dash pattern of the stroke.
60
- */
61
- dash: number[];
62
- /**
63
- * The miter limit of the stroke.
64
- */
65
- miterLimit: number;
66
- };
47
+ stroke: StrokeOptions;
67
48
  }
68
49
  /**
69
50
  * Class representing a Quadratic layer, extending the BaseLayer class.
@@ -87,12 +68,14 @@ export declare class QuadraticLayer extends BaseLayer<IQuadraticLayerProps> {
87
68
  */
88
69
  setControlPoint(x: ScaleType, y: ScaleType): this;
89
70
  /**
90
- * Sets the end point of the quadratic layer.
71
+ * Sets the position of the quadratic layer.
91
72
  * @param {ScaleType} [x] - The x-coordinate of the end point.
92
73
  * @param {ScaleType} [y] - The y-coordinate of the end point.
74
+ * @param {ScaleType} [endX] - The x-coordinate of the end point.
75
+ * @param {ScaleType} [endY] - The y-coordinate of the end point.
93
76
  * @returns {this} The current instance for chaining.
94
77
  */
95
- setEndPosition(x: ScaleType, y: ScaleType): this;
78
+ setPosition(x: ScaleType, y: ScaleType, endX?: ScaleType, endY?: ScaleType): this;
96
79
  /**
97
80
  * Sets the color of the layer.
98
81
  * @param {ColorType} [color] - The color of the layer.
@@ -5,14 +5,11 @@ const BaseLayer_1 = require("./BaseLayer");
5
5
  const types_1 = require("../../types");
6
6
  const utils_1 = require("../../utils/utils");
7
7
  const LazyUtil_1 = require("../../utils/LazyUtil");
8
+ const DrawUtils_1 = require("../../utils/DrawUtils");
8
9
  /**
9
10
  * Class representing a Quadratic layer, extending the BaseLayer class.
10
11
  */
11
12
  class QuadraticLayer extends BaseLayer_1.BaseLayer {
12
- /**
13
- * The properties of the Quadratic layer.
14
- */
15
- props;
16
13
  /**
17
14
  * Constructs a new QuadraticLayer instance.
18
15
  * @param {IQuadraticLayerProps} [props] - The properties of the Quadratic layer.
@@ -34,13 +31,15 @@ class QuadraticLayer extends BaseLayer_1.BaseLayer {
34
31
  return this;
35
32
  }
36
33
  /**
37
- * Sets the end point of the quadratic layer.
34
+ * Sets the position of the quadratic layer.
38
35
  * @param {ScaleType} [x] - The x-coordinate of the end point.
39
36
  * @param {ScaleType} [y] - The y-coordinate of the end point.
37
+ * @param {ScaleType} [endX] - The x-coordinate of the end point.
38
+ * @param {ScaleType} [endY] - The y-coordinate of the end point.
40
39
  * @returns {this} The current instance for chaining.
41
40
  */
42
- setEndPosition(x, y) {
43
- this.props.endPoint = { x, y };
41
+ setPosition(x, y, endX, endY) {
42
+ this.props.position = { x, y, endX: endX || 0, endY: endY || 0 };
44
43
  return this;
45
44
  }
46
45
  /**
@@ -51,9 +50,9 @@ class QuadraticLayer extends BaseLayer_1.BaseLayer {
51
50
  */
52
51
  setColor(color) {
53
52
  if (!color)
54
- throw new LazyUtil_1.LazyError('The color of the layer must be provided');
53
+ throw new LazyUtil_1.LazyError("The color of the layer must be provided");
55
54
  if (!(0, utils_1.isColor)(color))
56
- throw new LazyUtil_1.LazyError('The color of the layer must be a valid color');
55
+ throw new LazyUtil_1.LazyError("The color of the layer must be a valid color");
57
56
  this.props.fillStyle = color;
58
57
  return this;
59
58
  }
@@ -70,8 +69,8 @@ class QuadraticLayer extends BaseLayer_1.BaseLayer {
70
69
  setStroke(width, cap, join, dash, dashOffset, miterLimit) {
71
70
  this.props.stroke = {
72
71
  width,
73
- cap: cap || 'butt',
74
- join: join || 'miter',
72
+ cap: cap || "butt",
73
+ join: join || "miter",
75
74
  dash: dash || [],
76
75
  dashOffset: dashOffset || 0,
77
76
  miterLimit: miterLimit || 10,
@@ -88,14 +87,18 @@ class QuadraticLayer extends BaseLayer_1.BaseLayer {
88
87
  getBoundingBox(ctx, canvas, manager) {
89
88
  const parcer = (0, utils_1.parser)(ctx, canvas, manager);
90
89
  const { xs, ys, cx, cy, xe, ye } = parcer.parseBatch({
91
- xs: { v: this.props.x },
92
- ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
90
+ xs: { v: this.props.position.x },
91
+ ys: { v: this.props.position.y, options: LazyUtil_1.defaultArg.vl(true) },
93
92
  cx: { v: this.props.controlPoints[0].x },
94
93
  cy: { v: this.props.controlPoints[0].y, options: LazyUtil_1.defaultArg.vl(true) },
95
- xe: { v: this.props.endPoint.x },
96
- ye: { v: this.props.endPoint.y, options: LazyUtil_1.defaultArg.vl(true) }
94
+ xe: { v: this.props.position.endX },
95
+ ye: { v: this.props.position.endY, options: LazyUtil_1.defaultArg.vl(true) },
97
96
  });
98
- const { max, min, center, width, height } = (0, utils_1.getBoundingBoxBezier)([{ x: xs, y: ys }, { x: cx, y: cy }, { x: xe, y: ye }]);
97
+ const { max, min, center, width, height } = (0, utils_1.getBoundingBoxBezier)([
98
+ { x: xs, y: ys },
99
+ { x: cx, y: cy },
100
+ { x: xe, y: ye },
101
+ ]);
99
102
  return { max, min, center, width, height };
100
103
  }
101
104
  /**
@@ -108,31 +111,54 @@ class QuadraticLayer extends BaseLayer_1.BaseLayer {
108
111
  async draw(ctx, canvas, manager, debug) {
109
112
  const parcer = (0, utils_1.parser)(ctx, canvas, manager);
110
113
  const { xs, ys, cx, cy, xe, ye } = parcer.parseBatch({
111
- xs: { v: this.props.x },
112
- ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
114
+ xs: { v: this.props.position.x },
115
+ ys: { v: this.props.position.y, options: LazyUtil_1.defaultArg.vl(true) },
113
116
  cx: { v: this.props.controlPoints[0].x },
114
117
  cy: { v: this.props.controlPoints[0].y, options: LazyUtil_1.defaultArg.vl(true) },
115
- xe: { v: this.props.endPoint.x },
116
- ye: { v: this.props.endPoint.y, options: LazyUtil_1.defaultArg.vl(true) }
118
+ xe: { v: this.props.position.endX },
119
+ ye: { v: this.props.position.endY, options: LazyUtil_1.defaultArg.vl(true) },
120
+ });
121
+ const { max, min, center, width, height } = (0, utils_1.getBoundingBoxBezier)([
122
+ { x: xs, y: ys },
123
+ { x: cx, y: cy },
124
+ { x: xe, y: ye },
125
+ ]);
126
+ let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle, {
127
+ debug,
128
+ layer: { width, height, x: min.x, y: min.y, align: "none" },
129
+ manager,
117
130
  });
118
- const { max, min, center, width, height } = (0, utils_1.getBoundingBoxBezier)([{ x: xs, y: ys }, { x: cx, y: cy }, { x: xe, y: ye }]);
119
- let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle, { debug, layer: { width, height, x: min.x, y: min.y, align: 'none' }, manager });
120
131
  if (debug)
121
- LazyUtil_1.LazyLog.log('none', `BezierLayer:`, { xs, ys, cx, cy, xe, ye, max, min, center, width, height, fillStyle });
132
+ LazyUtil_1.LazyLog.log("none", `BezierLayer:`, {
133
+ xs,
134
+ ys,
135
+ cx,
136
+ cy,
137
+ xe,
138
+ ye,
139
+ max,
140
+ min,
141
+ center,
142
+ width,
143
+ height,
144
+ fillStyle,
145
+ });
122
146
  ctx.save();
123
- (0, utils_1.transform)(ctx, this.props.transform, { x: center.x, y: center.y, width, height, type: this.type });
124
- (0, utils_1.drawShadow)(ctx, this.props.shadow);
125
- (0, utils_1.opacity)(ctx, this.props.opacity);
126
- (0, utils_1.filters)(ctx, this.props.filter);
147
+ if (this.props.transform) {
148
+ (0, utils_1.transform)(ctx, this.props.transform, {
149
+ x: center.x,
150
+ y: center.y,
151
+ width,
152
+ height,
153
+ type: this.type,
154
+ });
155
+ }
156
+ DrawUtils_1.DrawUtils.drawShadow(ctx, this.props.shadow);
157
+ DrawUtils_1.DrawUtils.opacity(ctx, this.props.opacity);
158
+ DrawUtils_1.DrawUtils.filters(ctx, this.props.filter);
159
+ DrawUtils_1.DrawUtils.fillStyle(ctx, fillStyle, this.props.stroke);
127
160
  ctx.beginPath();
128
161
  ctx.moveTo(xs, ys);
129
- ctx.strokeStyle = fillStyle;
130
- ctx.lineWidth = this.props.stroke?.width || 1;
131
- ctx.lineCap = this.props.stroke?.cap || 'butt';
132
- ctx.lineJoin = this.props.stroke?.join || 'miter';
133
- ctx.miterLimit = this.props.stroke?.miterLimit || 10;
134
- ctx.lineDashOffset = this.props.stroke?.dashOffset || 0;
135
- ctx.setLineDash(this.props.stroke?.dash || []);
136
162
  ctx.quadraticCurveTo(cx, cy, xe, ye);
137
163
  ctx.stroke();
138
164
  ctx.closePath();
@@ -145,8 +171,16 @@ class QuadraticLayer extends BaseLayer_1.BaseLayer {
145
171
  toJSON() {
146
172
  let data = super.toJSON();
147
173
  let copy = { ...this.props };
148
- for (const key of ['x', 'y', 'endPoint.x', 'endPoint.y', 'controlPoint.x', 'controlPoint.y', 'fillStyle']) {
149
- if (copy[key] && typeof copy[key] === 'object' && 'toJSON' in copy[key]) {
174
+ for (const key of [
175
+ "x",
176
+ "y",
177
+ "endPoint.x",
178
+ "endPoint.y",
179
+ "controlPoint.x",
180
+ "controlPoint.y",
181
+ "fillStyle",
182
+ ]) {
183
+ if (copy[key] && typeof copy[key] === "object" && "toJSON" in copy[key]) {
150
184
  copy[key] = copy[key].toJSON();
151
185
  }
152
186
  }
@@ -160,19 +194,23 @@ class QuadraticLayer extends BaseLayer_1.BaseLayer {
160
194
  validateProps(data) {
161
195
  return {
162
196
  ...super.validateProps(data),
163
- filled: data.filled || false,
164
- fillStyle: data.fillStyle || '#000000',
197
+ position: {
198
+ x: data.position?.x || 0,
199
+ y: data.position?.y || 0,
200
+ endX: data.position?.endX || 0,
201
+ endY: data.position?.endY || 0,
202
+ },
203
+ fillStyle: data.fillStyle || "#000000",
165
204
  centring: data.centring || types_1.Centring.None,
166
205
  controlPoints: data.controlPoints || [{ x: 0, y: 0 }],
167
- endPoint: data.endPoint || { x: 0, y: 0 },
168
206
  stroke: {
169
207
  width: data.stroke?.width || 1,
170
- cap: data.stroke?.cap || 'butt',
171
- join: data.stroke?.join || 'miter',
208
+ cap: data.stroke?.cap || "butt",
209
+ join: data.stroke?.join || "miter",
172
210
  dashOffset: data.stroke?.dashOffset || 0,
173
211
  dash: data.stroke?.dash || [],
174
212
  miterLimit: data.stroke?.miterLimit || 10,
175
- }
213
+ },
176
214
  };
177
215
  }
178
216
  }
@@ -1,5 +1,5 @@
1
1
  import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
2
- import { AnyTextAlign, AnyTextBaseline, AnyTextDirection, AnyWeight, ColorType, LayerType, LineCap, LineJoin, ScaleType, SubStringColor } from "../../types";
2
+ import { AnyTextAlign, AnyTextBaseline, AnyTextDirection, AnyWeight, ColorType, LayerType, LineCap, LineJoin, ScaleType, StrokeOptions, SubStringColor } from "../../types";
3
3
  import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
4
4
  import { LayersManager } from "../managers";
5
5
  /**
@@ -23,10 +23,6 @@ export interface ITextLayerProps extends IBaseLayerProps {
23
23
  * The text content of the layer.
24
24
  */
25
25
  text: string;
26
- /**
27
- * Whether the layer is filled.
28
- */
29
- filled: boolean;
30
26
  /**
31
27
  * The fill style (color or pattern) of the layer.
32
28
  */
@@ -55,7 +51,7 @@ export interface ITextLayerProps extends IBaseLayerProps {
55
51
  /**
56
52
  * Configuration for multiline text.
57
53
  */
58
- multiline: {
54
+ multiline?: {
59
55
  /**
60
56
  * Whether multiline is enabled.
61
57
  */
@@ -68,7 +64,7 @@ export interface ITextLayerProps extends IBaseLayerProps {
68
64
  /**
69
65
  * The size of the Text layer, including width and height.
70
66
  */
71
- size: {
67
+ size?: {
72
68
  /**
73
69
  * The width of the Text layer.
74
70
  */
@@ -101,32 +97,7 @@ export interface ITextLayerProps extends IBaseLayerProps {
101
97
  /**
102
98
  * The stroke properties of the text.
103
99
  */
104
- stroke?: {
105
- /**
106
- * The width of the stroke.
107
- */
108
- width: number;
109
- /**
110
- * The cap style of the stroke.
111
- */
112
- cap: CanvasLineCap;
113
- /**
114
- * The join style of the stroke.
115
- */
116
- join: CanvasLineJoin;
117
- /**
118
- * The dash offset of the stroke.
119
- */
120
- dashOffset: number;
121
- /**
122
- * The dash pattern of the stroke.
123
- */
124
- dash: number[];
125
- /**
126
- * The miter limit of the stroke.
127
- */
128
- miterLimit: number;
129
- };
100
+ stroke?: StrokeOptions;
130
101
  }
131
102
  /**
132
103
  * Class representing a Text layer, extending the BaseLayer class.