apexify.js 4.6.2 → 4.6.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 (122) hide show
  1. package/dist/cjs/ai/functions/readFiles.js +1 -1
  2. package/dist/cjs/ai/functions/readFiles.js.map +1 -1
  3. package/dist/cjs/ai/modals-chat/electronHub/chatmodels.d.ts.map +1 -1
  4. package/dist/cjs/ai/modals-chat/electronHub/chatmodels.js +2 -1
  5. package/dist/cjs/ai/modals-chat/electronHub/chatmodels.js.map +1 -1
  6. package/dist/cjs/ai/modals-chat/electronHub/speechModels.d.ts.map +1 -1
  7. package/dist/cjs/ai/modals-chat/electronHub/speechModels.js +1 -1
  8. package/dist/cjs/ai/modals-chat/electronHub/speechModels.js.map +1 -1
  9. package/dist/cjs/canvas/ApexPainter.d.ts.map +1 -1
  10. package/dist/cjs/canvas/ApexPainter.js +27 -28
  11. package/dist/cjs/canvas/ApexPainter.js.map +1 -1
  12. package/dist/cjs/canvas/Themes/Level-Up/levelup.d.ts +11 -0
  13. package/dist/cjs/canvas/Themes/Level-Up/levelup.d.ts.map +1 -0
  14. package/dist/cjs/canvas/Themes/Level-Up/levelup.js +163 -0
  15. package/dist/cjs/canvas/Themes/Level-Up/levelup.js.map +1 -0
  16. package/dist/cjs/canvas/utils/Background/bg.d.ts +17 -10
  17. package/dist/cjs/canvas/utils/Background/bg.d.ts.map +1 -1
  18. package/dist/cjs/canvas/utils/Background/bg.js +102 -27
  19. package/dist/cjs/canvas/utils/Background/bg.js.map +1 -1
  20. package/dist/cjs/canvas/utils/Custom/customLines.d.ts.map +1 -1
  21. package/dist/cjs/canvas/utils/Custom/customLines.js +43 -19
  22. package/dist/cjs/canvas/utils/Custom/customLines.js.map +1 -1
  23. package/dist/cjs/canvas/utils/General/general functions.d.ts +6 -1
  24. package/dist/cjs/canvas/utils/General/general functions.d.ts.map +1 -1
  25. package/dist/cjs/canvas/utils/General/general functions.js +19 -20
  26. package/dist/cjs/canvas/utils/General/general functions.js.map +1 -1
  27. package/dist/cjs/canvas/utils/Image/imageProperties.d.ts +3 -9
  28. package/dist/cjs/canvas/utils/Image/imageProperties.d.ts.map +1 -1
  29. package/dist/cjs/canvas/utils/Image/imageProperties.js +220 -214
  30. package/dist/cjs/canvas/utils/Image/imageProperties.js.map +1 -1
  31. package/dist/cjs/canvas/utils/Texts/textProperties.d.ts +12 -14
  32. package/dist/cjs/canvas/utils/Texts/textProperties.d.ts.map +1 -1
  33. package/dist/cjs/canvas/utils/Texts/textProperties.js +100 -91
  34. package/dist/cjs/canvas/utils/Texts/textProperties.js.map +1 -1
  35. package/dist/cjs/canvas/utils/types.d.ts +89 -109
  36. package/dist/cjs/canvas/utils/types.d.ts.map +1 -1
  37. package/dist/cjs/canvas/utils/types.js.map +1 -1
  38. package/dist/cjs/canvas/utils/utils.d.ts +2 -4
  39. package/dist/cjs/canvas/utils/utils.d.ts.map +1 -1
  40. package/dist/cjs/canvas/utils/utils.js +2 -5
  41. package/dist/cjs/canvas/utils/utils.js.map +1 -1
  42. package/dist/cjs/index.d.ts.map +1 -1
  43. package/dist/cjs/index.js +31 -3
  44. package/dist/cjs/index.js.map +1 -1
  45. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  46. package/dist/esm/ai/functions/readFiles.js +1 -1
  47. package/dist/esm/ai/functions/readFiles.js.map +1 -1
  48. package/dist/esm/ai/modals-chat/electronHub/chatmodels.d.ts.map +1 -1
  49. package/dist/esm/ai/modals-chat/electronHub/chatmodels.js +2 -1
  50. package/dist/esm/ai/modals-chat/electronHub/chatmodels.js.map +1 -1
  51. package/dist/esm/ai/modals-chat/electronHub/speechModels.d.ts.map +1 -1
  52. package/dist/esm/ai/modals-chat/electronHub/speechModels.js +1 -1
  53. package/dist/esm/ai/modals-chat/electronHub/speechModels.js.map +1 -1
  54. package/dist/esm/canvas/ApexPainter.d.ts.map +1 -1
  55. package/dist/esm/canvas/ApexPainter.js +27 -28
  56. package/dist/esm/canvas/ApexPainter.js.map +1 -1
  57. package/dist/esm/canvas/Themes/Level-Up/levelup.d.ts +11 -0
  58. package/dist/esm/canvas/Themes/Level-Up/levelup.d.ts.map +1 -0
  59. package/dist/esm/canvas/Themes/Level-Up/levelup.js +163 -0
  60. package/dist/esm/canvas/Themes/Level-Up/levelup.js.map +1 -0
  61. package/dist/esm/canvas/utils/Background/bg.d.ts +17 -10
  62. package/dist/esm/canvas/utils/Background/bg.d.ts.map +1 -1
  63. package/dist/esm/canvas/utils/Background/bg.js +102 -27
  64. package/dist/esm/canvas/utils/Background/bg.js.map +1 -1
  65. package/dist/esm/canvas/utils/Custom/customLines.d.ts.map +1 -1
  66. package/dist/esm/canvas/utils/Custom/customLines.js +43 -19
  67. package/dist/esm/canvas/utils/Custom/customLines.js.map +1 -1
  68. package/dist/esm/canvas/utils/General/general functions.d.ts +6 -1
  69. package/dist/esm/canvas/utils/General/general functions.d.ts.map +1 -1
  70. package/dist/esm/canvas/utils/General/general functions.js +19 -20
  71. package/dist/esm/canvas/utils/General/general functions.js.map +1 -1
  72. package/dist/esm/canvas/utils/Image/imageProperties.d.ts +3 -9
  73. package/dist/esm/canvas/utils/Image/imageProperties.d.ts.map +1 -1
  74. package/dist/esm/canvas/utils/Image/imageProperties.js +220 -214
  75. package/dist/esm/canvas/utils/Image/imageProperties.js.map +1 -1
  76. package/dist/esm/canvas/utils/Texts/textProperties.d.ts +12 -14
  77. package/dist/esm/canvas/utils/Texts/textProperties.d.ts.map +1 -1
  78. package/dist/esm/canvas/utils/Texts/textProperties.js +100 -91
  79. package/dist/esm/canvas/utils/Texts/textProperties.js.map +1 -1
  80. package/dist/esm/canvas/utils/types.d.ts +89 -109
  81. package/dist/esm/canvas/utils/types.d.ts.map +1 -1
  82. package/dist/esm/canvas/utils/types.js.map +1 -1
  83. package/dist/esm/canvas/utils/utils.d.ts +2 -4
  84. package/dist/esm/canvas/utils/utils.d.ts.map +1 -1
  85. package/dist/esm/canvas/utils/utils.js +2 -5
  86. package/dist/esm/canvas/utils/utils.js.map +1 -1
  87. package/dist/esm/index.d.ts.map +1 -1
  88. package/dist/esm/index.js +31 -3
  89. package/dist/esm/index.js.map +1 -1
  90. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  91. package/lib/ai/functions/readFiles.ts +1 -1
  92. package/lib/ai/modals-chat/electronHub/chatmodels.ts +4 -2
  93. package/lib/ai/modals-chat/electronHub/speechModels.ts +2 -1
  94. package/lib/canvas/ApexPainter.ts +52 -61
  95. package/lib/canvas/Themes/Level-Up/levelup.ts +183 -0
  96. package/lib/canvas/utils/Background/bg.ts +179 -65
  97. package/lib/canvas/utils/Custom/customLines.ts +53 -20
  98. package/lib/canvas/utils/General/general functions.ts +21 -29
  99. package/lib/canvas/utils/Image/imageProperties.ts +399 -318
  100. package/lib/canvas/utils/Texts/textProperties.ts +213 -162
  101. package/lib/canvas/utils/types.ts +74 -107
  102. package/lib/canvas/utils/utils.ts +2 -5
  103. package/lib/index.ts +38 -10
  104. package/package.json +2 -2
  105. package/dist/cjs/canvas/utils/Background/circular.d.ts +0 -3
  106. package/dist/cjs/canvas/utils/Background/circular.d.ts.map +0 -1
  107. package/dist/cjs/canvas/utils/Background/circular.js +0 -13
  108. package/dist/cjs/canvas/utils/Background/circular.js.map +0 -1
  109. package/dist/cjs/canvas/utils/Background/radius.d.ts +0 -18
  110. package/dist/cjs/canvas/utils/Background/radius.d.ts.map +0 -1
  111. package/dist/cjs/canvas/utils/Background/radius.js +0 -104
  112. package/dist/cjs/canvas/utils/Background/radius.js.map +0 -1
  113. package/dist/esm/canvas/utils/Background/circular.d.ts +0 -3
  114. package/dist/esm/canvas/utils/Background/circular.d.ts.map +0 -1
  115. package/dist/esm/canvas/utils/Background/circular.js +0 -13
  116. package/dist/esm/canvas/utils/Background/circular.js.map +0 -1
  117. package/dist/esm/canvas/utils/Background/radius.d.ts +0 -18
  118. package/dist/esm/canvas/utils/Background/radius.d.ts.map +0 -1
  119. package/dist/esm/canvas/utils/Background/radius.js +0 -104
  120. package/dist/esm/canvas/utils/Background/radius.js.map +0 -1
  121. package/lib/canvas/utils/Background/circular.ts +0 -17
  122. package/lib/canvas/utils/Background/radius.ts +0 -102
@@ -22,8 +22,7 @@ export declare function applyZoom(ctx: SKRSContext2D, zoom?: {
22
22
  }): void;
23
23
  /**
24
24
  * Applies stroke to the canvas context with support for selective side strokes.
25
- * If stroke.borderPosition is "all", it uses the full rounded path.
26
- * Otherwise, it constructs individual segments for the specified sides.
25
+ * Supports optional blur effect on the stroke.
27
26
  *
28
27
  * @param ctx The canvas rendering context.
29
28
  * @param stroke The stroke properties.
@@ -31,14 +30,9 @@ export declare function applyZoom(ctx: SKRSContext2D, zoom?: {
31
30
  * @param y The y-coordinate of the shape.
32
31
  * @param width The width of the shape.
33
32
  * @param height The height of the shape.
33
+ * @param blur Optional blur effect on the stroke.
34
34
  */
35
- export declare function applyStroke(ctx: SKRSContext2D, stroke: ImageProperties['stroke'], x: number, y: number, width: number, height: number): void;
36
- /**
37
- * Draws a shape on the canvas context based on the provided settings.
38
- * Supports built‑in shapes as well as a custom polygon.
39
- * @param ctx - The canvas rendering context.
40
- * @param shapeSettings - The settings for the shape.
41
- */
35
+ export declare function applyStroke(ctx: SKRSContext2D, stroke: ImageProperties["stroke"], x: number, y: number, width: number, height: number, shapeName?: string, isImage?: boolean): void;
42
36
  export declare function drawShape(ctx: SKRSContext2D, shapeSettings: any): void;
43
37
  export declare function createGradient(ctx: any, gradientOptions: any, startX: number, startY: number, endX: number, endY: number): any;
44
38
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"imageProperties.d.ts","sourceRoot":"","sources":["../../../../../lib/canvas/utils/Image/imageProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACvB,GAAG,EAAE,aAAa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0);
27
27
  const shadowY = y + (shadow.offsetY ?? 0);
28
- objectRadius(ctx, shadowX, shadowY, width, height, shadow.borderRadius ?? 2, shadow.borderPosition);
28
+ objectRadius(ctx, shadowX, shadowY, width, height, shadow.borderRadius ?? 2);
29
29
  ctx.fillStyle = shadow.gradient
30
- ? createGradient(ctx, shadow.gradient, x, y, x + width, y + height)
30
+ ? createGradient(ctx, shadow.gradient, shadowX, shadowY, shadowX + width, shadowY + height)
31
31
  : shadow.color || "transparent";
32
32
  ctx.fill();
33
33
  }
@@ -52,8 +52,7 @@ function applyZoom(ctx, zoom) {
52
52
  }
53
53
  /**
54
54
  * Applies stroke to the canvas context with support for selective side strokes.
55
- * If stroke.borderPosition is "all", it uses the full rounded path.
56
- * Otherwise, it constructs individual segments for the specified sides.
55
+ * Supports optional blur effect on the stroke.
57
56
  *
58
57
  * @param ctx The canvas rendering context.
59
58
  * @param stroke The stroke properties.
@@ -61,38 +60,79 @@ function applyZoom(ctx, zoom) {
61
60
  * @param y The y-coordinate of the shape.
62
61
  * @param width The width of the shape.
63
62
  * @param height The height of the shape.
63
+ * @param blur Optional blur effect on the stroke.
64
64
  */
65
- function applyStroke(ctx, stroke, x, y, width, height) {
65
+ function applyStroke(ctx, stroke, x, y, width, height, shapeName, isImage) {
66
66
  if (!stroke)
67
67
  return;
68
68
  ctx.save();
69
- ctx.beginPath();
69
+ if (stroke.blur && stroke.blur > 0) {
70
+ ctx.filter = `blur(${stroke.blur}px)`;
71
+ }
70
72
  ctx.strokeStyle = stroke.gradient
71
73
  ? createGradient(ctx, stroke.gradient, x, y, x + width, y + height)
72
74
  : stroke.color || "transparent";
73
75
  ctx.lineWidth = stroke.width && stroke.width > 0 ? stroke.width : 2;
74
- const positionOffset = stroke.position ?? 0;
75
- const halfStroke = ctx.lineWidth / 2;
76
- const totalOffset = positionOffset > 0 ? positionOffset + halfStroke : 0;
77
- const adjustedBorderRadius = stroke.borderRadius === "circular"
78
- ? "circular"
79
- : (stroke.borderRadius ?? 2) + halfStroke;
80
- const adjustedX = x - totalOffset;
81
- const adjustedY = y - totalOffset;
82
- const adjustedWidth = width + totalOffset * 2;
83
- const adjustedHeight = height + totalOffset * 2;
84
- objectRadius(ctx, adjustedX, adjustedY, adjustedWidth, adjustedHeight, adjustedBorderRadius, "all");
76
+ ctx.beginPath();
77
+ if (isImage) {
78
+ ctx.globalCompositeOperation = "source-atop";
79
+ ctx.rect(x, y, width, height);
80
+ }
81
+ else if (["heart", "arrow", "circle", "star", "pentagon", "hexagon", "heptagon", "octagon", "diamond", "trapezoid", "kite"].includes(shapeName)) {
82
+ switch (shapeName) {
83
+ case "circle":
84
+ ctx.arc(x + width / 2, y + height / 2, width / 2, 0, Math.PI * 2);
85
+ break;
86
+ case "star":
87
+ drawStar(ctx, x, y, width, height);
88
+ break;
89
+ case "arrow":
90
+ drawArrow(ctx, x, y, width, height);
91
+ break;
92
+ case "pentagon":
93
+ case "hexagon":
94
+ case "heptagon":
95
+ case "octagon":
96
+ const sides = parseInt(shapeName.replace(/\D/g, ""), 10);
97
+ drawPolygon(ctx, x, y, width, height, sides);
98
+ break;
99
+ case "diamond":
100
+ ctx.moveTo(x + width / 2, y);
101
+ ctx.lineTo(x + width, y + height / 2);
102
+ ctx.lineTo(x + width / 2, y + height);
103
+ ctx.lineTo(x, y + height / 2);
104
+ ctx.closePath();
105
+ break;
106
+ case "trapezoid":
107
+ const topWidth = width * 0.6;
108
+ const offset = (width - topWidth) / 2;
109
+ ctx.moveTo(x + offset, y);
110
+ ctx.lineTo(x + offset + topWidth, y);
111
+ ctx.lineTo(x + width, y + height);
112
+ ctx.lineTo(x, y + height);
113
+ ctx.closePath();
114
+ break;
115
+ case "heart":
116
+ drawHeart(ctx, x, y, width, height);
117
+ break;
118
+ case "kite":
119
+ ctx.moveTo(x + width / 2, y);
120
+ ctx.lineTo(x + width, y + height / 2);
121
+ ctx.lineTo(x + width / 2, y + height);
122
+ ctx.lineTo(x, y + height / 2);
123
+ ctx.closePath();
124
+ break;
125
+ }
126
+ }
127
+ else {
128
+ objectRadius(ctx, x, y, width, height, stroke.borderRadius || 2, "all");
129
+ }
85
130
  ctx.stroke();
131
+ ctx.filter = "none";
86
132
  ctx.restore();
87
133
  }
88
- /**
89
- * Draws a shape on the canvas context based on the provided settings.
90
- * Supports built‑in shapes as well as a custom polygon.
91
- * @param ctx - The canvas rendering context.
92
- * @param shapeSettings - The settings for the shape.
93
- */
94
134
  function drawShape(ctx, shapeSettings) {
95
- const { source, x, y, width, height, rotation = 0, borderRadius = 0, borderPosition = 'all', stroke, shadow, isFilled = false, color = "transparent", gradient, } = shapeSettings;
135
+ const { source, x, y, width, height, rotation = 0, borderRadius = 0, borderPosition = 'all', stroke, shadow, isFilled = false, color = "transparent", gradient, filling, } = shapeSettings;
96
136
  const shapeName = source.toLowerCase();
97
137
  ctx.save();
98
138
  applyRotation(ctx, rotation, x, y, width, height);
@@ -114,41 +154,16 @@ function drawShape(ctx, shapeSettings) {
114
154
  ctx.closePath();
115
155
  break;
116
156
  }
117
- case 'pentagon': {
118
- drawPolygon(ctx, x, y, width, height, 5);
119
- break;
120
- }
121
- case 'hexagon': {
122
- drawPolygon(ctx, x, y, width, height, 6);
123
- break;
124
- }
125
- case 'heptagon': {
126
- drawPolygon(ctx, x, y, width, height, 7);
127
- break;
128
- }
157
+ case 'pentagon':
158
+ case 'hexagon':
159
+ case 'heptagon':
129
160
  case 'octagon': {
130
- drawPolygon(ctx, x, y, width, height, 8);
161
+ const sides = parseInt(shapeName.replace(/\D/g, ""), 10);
162
+ drawPolygon(ctx, x, y, width, height, sides);
131
163
  break;
132
164
  }
133
165
  case 'star': {
134
- {
135
- const cx = x + width / 2;
136
- const cy = y + height / 2;
137
- const outerRadius = Math.min(width, height) / 2;
138
- const innerRadius = outerRadius / 2;
139
- const step = Math.PI / 5;
140
- for (let i = 0; i < 10; i++) {
141
- const r = i % 2 === 0 ? outerRadius : innerRadius;
142
- const angle = i * step - Math.PI / 2;
143
- if (i === 0) {
144
- ctx.moveTo(cx + r * Math.cos(angle), cy + r * Math.sin(angle));
145
- }
146
- else {
147
- ctx.lineTo(cx + r * Math.cos(angle), cy + r * Math.sin(angle));
148
- }
149
- }
150
- ctx.closePath();
151
- }
166
+ drawStar(ctx, x, y, width, height);
152
167
  break;
153
168
  }
154
169
  case 'kite': {
@@ -163,23 +178,12 @@ function drawShape(ctx, shapeSettings) {
163
178
  ctx.ellipse(x + width / 2, y + height / 2, width / 2, height / 2, 0, 0, Math.PI * 2);
164
179
  break;
165
180
  }
166
- case 'heart': {
167
- ctx.moveTo(x + width / 2, y + height * 0.75);
168
- ctx.bezierCurveTo(x + width * 0.1, y + height * 0.5, x, y + height * 0.2, x + width / 2, y + height * 0.3);
169
- ctx.bezierCurveTo(x + width, y + height * 0.2, x + width * 0.9, y + height * 0.5, x + width / 2, y + height * 0.75);
170
- ctx.closePath();
181
+ case 'arrow': {
182
+ drawArrow(ctx, x, y, width, height);
171
183
  break;
172
184
  }
173
- case 'arrow': {
174
- const arrowHeadWidth = width * 0.3;
175
- ctx.moveTo(x, y + height / 2);
176
- ctx.lineTo(x + width - arrowHeadWidth, y + height / 2);
177
- ctx.lineTo(x + width - arrowHeadWidth, y);
178
- ctx.lineTo(x + width, y + height / 2);
179
- ctx.lineTo(x + width - arrowHeadWidth, y + height);
180
- ctx.lineTo(x + width - arrowHeadWidth, y + height / 2);
181
- ctx.lineTo(x, y + height / 2);
182
- ctx.closePath();
185
+ case 'heart': {
186
+ drawHeart(ctx, x, y, width, height);
183
187
  break;
184
188
  }
185
189
  case 'diamond': {
@@ -200,17 +204,6 @@ function drawShape(ctx, shapeSettings) {
200
204
  ctx.closePath();
201
205
  break;
202
206
  }
203
- case 'cloud': {
204
- const radius = width / 5;
205
- ctx.moveTo(x + radius, y + height / 2);
206
- ctx.arc(x + radius, y + height / 2, radius, Math.PI * 0.5, Math.PI * 1.5);
207
- ctx.arc(x + width / 2, y + height / 2 - radius, radius, Math.PI, 0);
208
- ctx.arc(x + width - radius, y + height / 2, radius, Math.PI * 1.5, Math.PI * 0.5);
209
- ctx.lineTo(x + width, y + height);
210
- ctx.lineTo(x, y + height);
211
- ctx.closePath();
212
- break;
213
- }
214
207
  default: {
215
208
  ctx.restore();
216
209
  throw new Error(`Unsupported shape: ${shapeName}`);
@@ -220,42 +213,104 @@ function drawShape(ctx, shapeSettings) {
220
213
  if (borderRadius && shapeName !== 'circle' && shapeName !== 'oval') {
221
214
  objectRadius(ctx, x, y, width, height, borderRadius, borderPosition);
222
215
  }
216
+ let fillStyle = color;
223
217
  if (gradient) {
224
- const gradFill = createGradient(ctx, gradient, x, y, x + width, y + height);
225
- ctx.fillStyle = gradFill;
218
+ fillStyle = createGradient(ctx, gradient, x, y, x + width, y + height);
219
+ }
220
+ if (filling && filling.percentage <= 100) {
221
+ ctx.save();
222
+ const isCustomShape = ["heart", "arrow", "star", "pentagon", "hexagon", "heptagon", "octagon", "diamond", "trapezoid", "kite", "oval", "circle"].includes(shapeName);
223
+ if (isCustomShape) {
224
+ ctx.clip();
225
+ }
226
+ let fillX = x;
227
+ let fillY = y;
228
+ let fillWidth = width;
229
+ let fillHeight = height;
230
+ switch (filling.rotation) {
231
+ case 0:
232
+ fillHeight = (filling.percentage / 100) * height;
233
+ fillY = y + height - fillHeight;
234
+ break;
235
+ case 180:
236
+ fillHeight = (filling.percentage / 100) * height;
237
+ break;
238
+ case 90:
239
+ fillWidth = (filling.percentage / 100) * width;
240
+ break;
241
+ case 270:
242
+ fillWidth = (filling.percentage / 100) * width;
243
+ fillX = x + width - fillWidth;
244
+ break;
245
+ default:
246
+ console.warn(`Unsupported filling rotation: ${filling.rotation}, defaulting to 0 (Bottom to Top).`);
247
+ fillHeight = (filling.percentage / 100) * height;
248
+ fillY = y + height - fillHeight;
249
+ }
250
+ ctx.beginPath();
251
+ ctx.rect(fillX, fillY, fillWidth, fillHeight);
252
+ ctx.fillStyle = fillStyle;
253
+ ctx.fill();
254
+ ctx.restore();
226
255
  }
227
256
  else {
228
- ctx.fillStyle = color;
257
+ ctx.fillStyle = fillStyle;
258
+ ctx.fill();
229
259
  }
230
- ctx.fill();
231
260
  }
232
261
  if (stroke) {
233
- applyStroke(ctx, stroke, x, y, width, height);
262
+ applyStroke(ctx, stroke, x, y, width, height, shapeName, false);
234
263
  }
235
264
  ctx.restore();
236
265
  }
237
- /**
238
- * Helper function to draw a regular polygon.
239
- * Inscribes a polygon with a given number of sides inside the rectangle defined by (x, y, width, height).
240
- * @param ctx - The canvas rendering context.
241
- * @param x - The x-coordinate of the bounding rectangle.
242
- * @param y - The y-coordinate of the bounding rectangle.
243
- * @param width - The width of the bounding rectangle.
244
- * @param height - The height of the bounding rectangle.
245
- * @param sides - The number of sides (≥ 3).
246
- */
266
+ function drawHeart(ctx, x, y, width, height) {
267
+ ctx.beginPath();
268
+ ctx.moveTo(x + width / 2, y + height * 0.9);
269
+ ctx.bezierCurveTo(x + (width * 35) / 100, y + (height * 60) / 100, x + (width * 10) / 100, y + (height * 55) / 100, x + (width * 10) / 100, y + (height * 33.33) / 100);
270
+ ctx.bezierCurveTo(x + (width * 10) / 100, y + (height * 10) / 100, x + (width * 50) / 100, y + (height * 5) / 100, x + (width * 50) / 100, y + (height * 33.33) / 100);
271
+ ctx.bezierCurveTo(x + (width * 50) / 100, y + (height * 5) / 100, x + (width * 90) / 100, y + (height * 10) / 100, x + (width * 90) / 100, y + (height * 33.33) / 100);
272
+ ctx.bezierCurveTo(x + (width * 90) / 100, y + (height * 55) / 100, x + (width * 65) / 100, y + (height * 60) / 100, x + width / 2, y + height * 0.9);
273
+ ctx.closePath();
274
+ }
275
+ /** Draws a polygon with a given number of sides */
247
276
  function drawPolygon(ctx, x, y, width, height, sides) {
248
277
  const cx = x + width / 2;
249
278
  const cy = y + height / 2;
250
279
  const radius = Math.min(width, height) / 2;
251
- for (let i = 0; i < sides; i++) {
252
- const angle = (2 * Math.PI * i) / sides - Math.PI / 2;
253
- if (i === 0) {
254
- ctx.moveTo(cx + radius * Math.cos(angle), cy + radius * Math.sin(angle));
255
- }
256
- else {
257
- ctx.lineTo(cx + radius * Math.cos(angle), cy + radius * Math.sin(angle));
258
- }
280
+ ctx.moveTo(cx + radius, cy);
281
+ for (let i = 1; i <= sides; i++) {
282
+ const angle = (Math.PI * 2 * i) / sides;
283
+ ctx.lineTo(cx + radius * Math.cos(angle), cy + radius * Math.sin(angle));
284
+ }
285
+ ctx.closePath();
286
+ }
287
+ function drawArrow(ctx, x, y, width, height) {
288
+ const shaftWidth = width * 0.25;
289
+ const headWidth = width * 0.5;
290
+ const headHeight = height * 0.6;
291
+ ctx.beginPath();
292
+ ctx.moveTo(x, y + height / 2 - shaftWidth / 2);
293
+ ctx.lineTo(x + width - headWidth, y + height / 2 - shaftWidth / 2);
294
+ ctx.lineTo(x + width - headWidth, y);
295
+ ctx.lineTo(x + width, y + height / 2);
296
+ ctx.lineTo(x + width - headWidth, y + height);
297
+ ctx.lineTo(x + width - headWidth, y + height / 2 + shaftWidth / 2);
298
+ ctx.lineTo(x, y + height / 2 + shaftWidth / 2);
299
+ ctx.closePath();
300
+ }
301
+ function drawStar(ctx, x, y, width, height) {
302
+ const cx = x + width / 2;
303
+ const cy = y + height / 2;
304
+ const size = Math.min(width, height);
305
+ const outerRadius = size / 2;
306
+ const innerRadius = outerRadius * 0.5;
307
+ const rotationOffset = -Math.PI / 2;
308
+ ctx.beginPath();
309
+ for (let i = 0; i < 5; i++) {
310
+ let angle = (i * (Math.PI * 2)) / 5 + rotationOffset;
311
+ ctx.lineTo(cx + outerRadius * Math.cos(angle), cy + outerRadius * Math.sin(angle));
312
+ angle += Math.PI / 5;
313
+ ctx.lineTo(cx + innerRadius * Math.cos(angle), cy + innerRadius * Math.sin(angle));
259
314
  }
260
315
  ctx.closePath();
261
316
  }
@@ -273,9 +328,22 @@ function createGradient(ctx, gradientOptions, startX, startY, endX, endY) {
273
328
  typeof endY !== "number") {
274
329
  throw new Error("Invalid gradient options for linear gradient. Numeric values are required for startX, startY, endX, and endY.");
275
330
  }
331
+ if (typeof gradientOptions.rotate === "number") {
332
+ const centerX = (startX + endX) / 2;
333
+ const centerY = (startY + endY) / 2;
334
+ const dx = endX - startX;
335
+ const dy = endY - startY;
336
+ const length = Math.sqrt(dx * dx + dy * dy);
337
+ const angleRad = (gradientOptions.rotate * Math.PI) / 180;
338
+ startX = centerX - (length / 2) * Math.cos(angleRad);
339
+ startY = centerY - (length / 2) * Math.sin(angleRad);
340
+ endX = centerX + (length / 2) * Math.cos(angleRad);
341
+ endY = centerY + (length / 2) * Math.sin(angleRad);
342
+ }
276
343
  const gradient = ctx.createLinearGradient(startX, startY, endX, endY);
277
344
  for (const colorStop of gradientOptions.colors) {
278
- if (typeof colorStop.stop !== "number" || typeof colorStop.color !== "string") {
345
+ if (typeof colorStop.stop !== "number" ||
346
+ typeof colorStop.color !== "string") {
279
347
  throw new Error("Invalid color stop. Each color stop should have a numeric stop value and a color string.");
280
348
  }
281
349
  gradient.addColorStop(colorStop.stop, colorStop.color);
@@ -293,7 +361,8 @@ function createGradient(ctx, gradientOptions, startX, startY, endX, endY) {
293
361
  }
294
362
  const gradient = ctx.createRadialGradient(gradientOptions.startX, gradientOptions.startY, gradientOptions.startRadius, gradientOptions.endX, gradientOptions.endY, gradientOptions.endRadius);
295
363
  for (const colorStop of gradientOptions.colors) {
296
- if (typeof colorStop.stop !== "number" || typeof colorStop.color !== "string") {
364
+ if (typeof colorStop.stop !== "number" ||
365
+ typeof colorStop.color !== "string") {
297
366
  throw new Error("Invalid color stop. Each color stop should have a numeric stop value and a color string.");
298
367
  }
299
368
  gradient.addColorStop(colorStop.stop, colorStop.color);
@@ -343,49 +412,39 @@ function imageRadius(ctx, image, x, y, width, height, borderRadius, borderPositi
343
412
  if (borderRadius === "circular") {
344
413
  const circleRadius = Math.min(width, height) / 2;
345
414
  ctx.arc(x + width / 2, y + height / 2, circleRadius, 0, 2 * Math.PI);
346
- ctx.closePath();
415
+ ctx.clip();
347
416
  }
348
- else {
349
- const br = typeof borderRadius === "number" ? borderRadius : 0;
350
- const bp = borderPosition.trim().toLowerCase();
351
- const selectedCorners = new Set(bp.split(",").map((s) => s.trim()));
352
- const roundTopLeft = selectedCorners.has("all") || selectedCorners.has("top-left") || (selectedCorners.has("top") && selectedCorners.has("left"));
353
- const roundTopRight = selectedCorners.has("all") || selectedCorners.has("top-right") || (selectedCorners.has("top") && selectedCorners.has("right"));
354
- const roundBottomRight = selectedCorners.has("all") || selectedCorners.has("bottom-right") || (selectedCorners.has("bottom") && selectedCorners.has("right"));
355
- const roundBottomLeft = selectedCorners.has("all") || selectedCorners.has("bottom-left") || (selectedCorners.has("bottom") && selectedCorners.has("left"));
417
+ else if (typeof borderRadius === "number" && borderRadius > 0) {
418
+ const br = Math.min(borderRadius, width / 2, height / 2);
419
+ const selectedPositions = new Set(borderPosition.toLowerCase().split(",").map((s) => s.trim()));
420
+ const roundTopLeft = selectedPositions.has("all") || selectedPositions.has("top-left") || (selectedPositions.has("top") && selectedPositions.has("left"));
421
+ const roundTopRight = selectedPositions.has("all") || selectedPositions.has("top-right") || (selectedPositions.has("top") && selectedPositions.has("right"));
422
+ const roundBottomRight = selectedPositions.has("all") || selectedPositions.has("bottom-right") || (selectedPositions.has("bottom") && selectedPositions.has("right"));
423
+ const roundBottomLeft = selectedPositions.has("all") || selectedPositions.has("bottom-left") || (selectedPositions.has("bottom") && selectedPositions.has("left"));
356
424
  const tl = roundTopLeft ? br : 0;
357
425
  const tr = roundTopRight ? br : 0;
358
426
  const brR = roundBottomRight ? br : 0;
359
427
  const bl = roundBottomLeft ? br : 0;
360
428
  ctx.moveTo(x + tl, y);
361
- if (roundTopLeft && roundTopRight) {
362
- ctx.arcTo(x, y, x + width, y, tl);
363
- }
364
- else if (roundTopLeft) {
365
- ctx.arcTo(x, y, x + width, y, tl);
366
- }
367
- else {
368
- ctx.lineTo(x, y);
369
- ctx.lineTo(x + width, y);
370
- }
371
- if (tr > 0) {
372
- ctx.arcTo(x + width, y, x + width, y + height, tr);
373
- }
429
+ ctx.lineTo(x + width - tr, y);
430
+ if (tr > 0)
431
+ ctx.arc(x + width - tr, y + tr, tr, -Math.PI / 2, 0, false);
374
432
  ctx.lineTo(x + width, y + height - brR);
375
- if (brR > 0) {
376
- ctx.arcTo(x + width, y + height, x, y + height, brR);
377
- }
433
+ if (brR > 0)
434
+ ctx.arc(x + width - brR, y + height - brR, brR, 0, Math.PI / 2, false);
378
435
  ctx.lineTo(x + bl, y + height);
379
- if (bl > 0) {
380
- ctx.arcTo(x, y + height, x, y, bl);
381
- }
436
+ if (bl > 0)
437
+ ctx.arc(x + bl, y + height - bl, bl, Math.PI / 2, Math.PI, false);
382
438
  ctx.lineTo(x, y + tl);
383
- if (tl > 0) {
384
- ctx.arcTo(x, y, x + tl, y, tl);
385
- }
439
+ if (tl > 0)
440
+ ctx.arc(x + tl, y + tl, tl, Math.PI, -Math.PI / 2, false);
386
441
  ctx.closePath();
442
+ ctx.clip();
443
+ }
444
+ else {
445
+ ctx.rect(x, y, width, height);
446
+ ctx.clip();
387
447
  }
388
- ctx.clip();
389
448
  ctx.drawImage(image, x, y, width, height);
390
449
  ctx.restore();
391
450
  }
@@ -404,94 +463,41 @@ function imageRadius(ctx, image, x, y, width, height, borderRadius, borderPositi
404
463
  * - "top-left", "top-right", "bottom-left", "bottom-right"
405
464
  * - Or a comma-separated list, e.g. "top-left, bottom-right" or "top, left, bottom"
406
465
  */
407
- function objectRadius(ctx, x, y, width, height, borderRadius = 0.1, borderPosition = 'all') {
466
+ function objectRadius(ctx, x, y, width, height, borderRadius = 0.1, borderPosition = "all") {
467
+ ctx.beginPath();
408
468
  if (borderRadius === "circular") {
409
469
  const circleRadius = Math.min(width, height) / 2;
410
- ctx.beginPath();
411
470
  ctx.arc(x + width / 2, y + height / 2, circleRadius, 0, 2 * Math.PI);
412
- ctx.closePath();
413
471
  }
414
- else if (borderRadius) {
415
- let roundTopLeft = false;
416
- let roundTopRight = false;
417
- let roundBottomRight = false;
418
- let roundBottomLeft = false;
419
- const bp = borderPosition.trim().toLowerCase();
420
- if (bp === 'all') {
421
- roundTopLeft = roundTopRight = roundBottomRight = roundBottomLeft = true;
422
- }
423
- else if (bp === 'top') {
424
- roundTopLeft = roundTopRight = true;
425
- }
426
- else if (bp === 'bottom') {
427
- roundBottomLeft = roundBottomRight = true;
428
- }
429
- else if (bp === 'left') {
430
- roundTopLeft = roundBottomLeft = true;
431
- }
432
- else if (bp === 'right') {
433
- roundTopRight = roundBottomRight = true;
434
- }
435
- else if (bp === 'top-left') {
436
- roundTopLeft = true;
437
- }
438
- else if (bp === 'top-right') {
439
- roundTopRight = true;
440
- }
441
- else if (bp === 'bottom-left') {
442
- roundBottomLeft = true;
443
- }
444
- else if (bp === 'bottom-right') {
445
- roundBottomRight = true;
446
- }
447
- else {
448
- const positions = bp.split(',').map(s => s.trim());
449
- roundTopLeft = positions.includes('top-left') || (positions.includes('top') && positions.includes('left'));
450
- roundTopRight = positions.includes('top-right') || (positions.includes('top') && positions.includes('right'));
451
- roundBottomRight = positions.includes('bottom-right') || (positions.includes('bottom') && positions.includes('right'));
452
- roundBottomLeft = positions.includes('bottom-left') || (positions.includes('bottom') && positions.includes('left'));
453
- }
454
- const tl = roundTopLeft ? +borderRadius : 0;
455
- const tr = roundTopRight ? +borderRadius : 0;
456
- const br = roundBottomRight ? +borderRadius : 0;
457
- const bl = roundBottomLeft ? +borderRadius : 0;
458
- ctx.beginPath();
472
+ else if (borderRadius > 0) {
473
+ const br = Math.min(borderRadius, width / 2, height / 2);
474
+ const selectedPositions = new Set(borderPosition.toLowerCase().split(",").map((s) => s.trim()));
475
+ const roundTopLeft = selectedPositions.has("all") || selectedPositions.has("top-left") || (selectedPositions.has("top") && selectedPositions.has("left"));
476
+ const roundTopRight = selectedPositions.has("all") || selectedPositions.has("top-right") || (selectedPositions.has("top") && selectedPositions.has("right"));
477
+ const roundBottomRight = selectedPositions.has("all") || selectedPositions.has("bottom-right") || (selectedPositions.has("bottom") && selectedPositions.has("right"));
478
+ const roundBottomLeft = selectedPositions.has("all") || selectedPositions.has("bottom-left") || (selectedPositions.has("bottom") && selectedPositions.has("left"));
479
+ const tl = roundTopLeft ? br : 0;
480
+ const tr = roundTopRight ? br : 0;
481
+ const brR = roundBottomRight ? br : 0;
482
+ const bl = roundBottomLeft ? br : 0;
459
483
  ctx.moveTo(x + tl, y);
460
484
  ctx.lineTo(x + width - tr, y);
461
- if (tr > 0) {
462
- ctx.quadraticCurveTo(x + width, y, x + width, y + tr);
463
- }
464
- else {
465
- ctx.lineTo(x + width, y);
466
- }
467
- ctx.lineTo(x + width, y + height - br);
468
- if (br > 0) {
469
- ctx.quadraticCurveTo(x + width, y + height, x + width - br, y + height);
470
- }
471
- else {
472
- ctx.lineTo(x + width, y + height);
473
- }
485
+ if (tr > 0)
486
+ ctx.arc(x + width - tr, y + tr, tr, -Math.PI / 2, 0, false);
487
+ ctx.lineTo(x + width, y + height - brR);
488
+ if (brR > 0)
489
+ ctx.arc(x + width - brR, y + height - brR, brR, 0, Math.PI / 2, false);
474
490
  ctx.lineTo(x + bl, y + height);
475
- if (bl > 0) {
476
- ctx.quadraticCurveTo(x, y + height, x, y + height - bl);
477
- }
478
- else {
479
- ctx.lineTo(x, y + height);
480
- }
491
+ if (bl > 0)
492
+ ctx.arc(x + bl, y + height - bl, bl, Math.PI / 2, Math.PI, false);
481
493
  ctx.lineTo(x, y + tl);
482
- if (tl > 0) {
483
- ctx.quadraticCurveTo(x, y, x + tl, y);
484
- }
485
- else {
486
- ctx.lineTo(x, y);
487
- }
488
- ctx.closePath();
494
+ if (tl > 0)
495
+ ctx.arc(x + tl, y + tl, tl, Math.PI, -Math.PI / 2, false);
489
496
  }
490
497
  else {
491
- ctx.beginPath();
492
498
  ctx.rect(x, y, width, height);
493
- ctx.closePath();
494
499
  }
500
+ ctx.closePath();
495
501
  }
496
502
  /**
497
503
  * Performs bilinear interpolation on four corners.