apexify.js 3.0.2 → 3.1.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 (119) hide show
  1. package/.tsbuildinfo +1 -0
  2. package/README.md +190 -151
  3. package/dist/ai/ApexAI.d.ts +37 -0
  4. package/dist/ai/ApexAI.d.ts.map +1 -0
  5. package/dist/ai/ApexAI.js +258 -0
  6. package/dist/ai/ApexAI.js.map +1 -0
  7. package/dist/ai/buttons/drawMenu.d.ts +3 -0
  8. package/dist/ai/buttons/drawMenu.d.ts.map +1 -0
  9. package/dist/ai/buttons/drawMenu.js +271 -0
  10. package/dist/ai/buttons/drawMenu.js.map +1 -0
  11. package/dist/ai/buttons/tools.d.ts +3 -0
  12. package/dist/ai/buttons/tools.d.ts.map +1 -0
  13. package/dist/ai/buttons/tools.js +442 -0
  14. package/dist/ai/buttons/tools.js.map +1 -0
  15. package/dist/ai/functions/chunkString.d.ts +2 -0
  16. package/dist/ai/functions/chunkString.d.ts.map +1 -0
  17. package/{lib → dist}/ai/functions/chunkString.js +8 -8
  18. package/dist/ai/functions/chunkString.js.map +1 -0
  19. package/dist/ai/functions/draw.d.ts +3 -0
  20. package/dist/ai/functions/draw.d.ts.map +1 -0
  21. package/dist/ai/functions/draw.js +377 -0
  22. package/dist/ai/functions/draw.js.map +1 -0
  23. package/dist/ai/functions/generateVoiceResponse.d.ts +3 -0
  24. package/dist/ai/functions/generateVoiceResponse.d.ts.map +1 -0
  25. package/dist/ai/functions/generateVoiceResponse.js +158 -0
  26. package/dist/ai/functions/generateVoiceResponse.js.map +1 -0
  27. package/dist/ai/functions/imageReader.d.ts +3 -0
  28. package/dist/ai/functions/imageReader.d.ts.map +1 -0
  29. package/dist/ai/functions/imageReader.js +23 -0
  30. package/dist/ai/functions/imageReader.js.map +1 -0
  31. package/dist/ai/functions/readFiles.d.ts +3 -0
  32. package/dist/ai/functions/readFiles.d.ts.map +1 -0
  33. package/dist/ai/functions/readFiles.js +62 -0
  34. package/dist/ai/functions/readFiles.js.map +1 -0
  35. package/dist/ai/functions/shouldDrawImage.d.ts +2 -0
  36. package/dist/ai/functions/shouldDrawImage.d.ts.map +1 -0
  37. package/dist/ai/functions/shouldDrawImage.js +12 -0
  38. package/dist/ai/functions/shouldDrawImage.js.map +1 -0
  39. package/dist/ai/models.d.ts +9 -0
  40. package/dist/ai/models.d.ts.map +1 -0
  41. package/dist/ai/models.js +538 -0
  42. package/dist/ai/models.js.map +1 -0
  43. package/dist/ai/utils.d.ts +9 -0
  44. package/dist/ai/utils.d.ts.map +1 -0
  45. package/dist/ai/utils.js +20 -0
  46. package/dist/ai/utils.js.map +1 -0
  47. package/dist/canvas/ApexPainter.d.ts +26 -0
  48. package/dist/canvas/ApexPainter.d.ts.map +1 -0
  49. package/dist/canvas/ApexPainter.js +412 -0
  50. package/dist/canvas/ApexPainter.js.map +1 -0
  51. package/dist/canvas/utils/bg.d.ts +24 -0
  52. package/dist/canvas/utils/bg.d.ts.map +1 -0
  53. package/dist/canvas/utils/bg.js +77 -0
  54. package/dist/canvas/utils/bg.js.map +1 -0
  55. package/dist/canvas/utils/charts.d.ts +9 -0
  56. package/dist/canvas/utils/charts.d.ts.map +1 -0
  57. package/dist/canvas/utils/charts.js +453 -0
  58. package/dist/canvas/utils/charts.js.map +1 -0
  59. package/dist/canvas/utils/circular.d.ts +10 -0
  60. package/dist/canvas/utils/circular.d.ts.map +1 -0
  61. package/dist/canvas/utils/circular.js +22 -0
  62. package/dist/canvas/utils/circular.js.map +1 -0
  63. package/dist/canvas/utils/customLines.d.ts +2 -0
  64. package/dist/canvas/utils/customLines.d.ts.map +1 -0
  65. package/dist/canvas/utils/customLines.js +50 -0
  66. package/dist/canvas/utils/customLines.js.map +1 -0
  67. package/dist/canvas/utils/general functions.d.ts +8 -0
  68. package/dist/canvas/utils/general functions.d.ts.map +1 -0
  69. package/dist/canvas/utils/general functions.js +187 -0
  70. package/dist/canvas/utils/general functions.js.map +1 -0
  71. package/dist/canvas/utils/imageProperties.d.ts +60 -0
  72. package/dist/canvas/utils/imageProperties.d.ts.map +1 -0
  73. package/dist/canvas/utils/imageProperties.js +331 -0
  74. package/dist/canvas/utils/imageProperties.js.map +1 -0
  75. package/dist/canvas/utils/radius.d.ts +10 -0
  76. package/dist/canvas/utils/radius.d.ts.map +1 -0
  77. package/dist/canvas/utils/radius.js +31 -0
  78. package/dist/canvas/utils/radius.js.map +1 -0
  79. package/dist/canvas/utils/textProperties.d.ts +18 -0
  80. package/dist/canvas/utils/textProperties.d.ts.map +1 -0
  81. package/dist/canvas/utils/textProperties.js +67 -0
  82. package/dist/canvas/utils/textProperties.js.map +1 -0
  83. package/dist/canvas/utils/types.d.ts +389 -0
  84. package/dist/canvas/utils/types.d.ts.map +1 -0
  85. package/dist/canvas/utils/types.js +5 -0
  86. package/dist/canvas/utils/types.js.map +1 -0
  87. package/dist/canvas/utils/utils.d.ts +20 -0
  88. package/dist/canvas/utils/utils.d.ts.map +1 -0
  89. package/dist/canvas/utils/utils.js +43 -0
  90. package/dist/canvas/utils/utils.js.map +1 -0
  91. package/dist/index.d.ts +11 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +66 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/utils.d.ts +12 -0
  96. package/dist/utils.d.ts.map +1 -0
  97. package/dist/utils.js +12 -0
  98. package/dist/utils.js.map +1 -0
  99. package/examples/barchart.txt +69 -0
  100. package/examples/linechart.txt +84 -0
  101. package/examples/piechart.txt +63 -0
  102. package/package.json +137 -78
  103. package/dataSQL/data.sql +0 -5
  104. package/dataSQL/dataName.sql +0 -0
  105. package/dataSQL/example_table.sql +0 -1
  106. package/index.js +0 -35
  107. package/lib/ai/apexAI.js +0 -446
  108. package/lib/ai/buttons/drawMenu.js +0 -351
  109. package/lib/ai/buttons/tools.js +0 -652
  110. package/lib/ai/functions/draw.js +0 -514
  111. package/lib/ai/functions/generateVoiceResponse.js +0 -239
  112. package/lib/ai/functions/processImageAttachments.js +0 -93
  113. package/lib/ai/functions/processMessageContent.js +0 -48
  114. package/lib/ai/functions/readFiles.js +0 -95
  115. package/lib/ai/functions/shouldDrawImage.js +0 -12
  116. package/lib/ai/models.js +0 -654
  117. package/lib/ai/utils.js +0 -21
  118. package/lib/canvas/ApexPainter.js +0 -1396
  119. package/lib/utils.js +0 -24
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.imgEffects = exports.applyColorFilters = exports.converter = exports.resizingImg = exports.loadImages = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const sharp_1 = __importDefault(require("sharp"));
10
+ async function loadImages(imagePath, baseDir) {
11
+ try {
12
+ if (!imagePath) {
13
+ throw new Error("Image path is required.");
14
+ }
15
+ if (imagePath.startsWith("http")) {
16
+ if (baseDir) {
17
+ throw new Error("No need for baseDir when using an image URL.");
18
+ }
19
+ const response = await axios_1.default.get(imagePath, {
20
+ responseType: "arraybuffer",
21
+ });
22
+ return (0, sharp_1.default)(response.data);
23
+ }
24
+ else {
25
+ if (!baseDir) {
26
+ throw new Error("baseDir is required for local file paths.");
27
+ }
28
+ const absolutePath = path_1.default.resolve(baseDir, imagePath);
29
+ return (0, sharp_1.default)(absolutePath);
30
+ }
31
+ }
32
+ catch (error) {
33
+ console.error("Error loading image:", error);
34
+ throw new Error("Failed to load image");
35
+ }
36
+ }
37
+ exports.loadImages = loadImages;
38
+ async function resizingImg(resizeOptions, baseDir) {
39
+ try {
40
+ if (!resizeOptions.imagePath) {
41
+ throw new Error("Image path is required for resizing.");
42
+ }
43
+ let imagePath;
44
+ if (Buffer.isBuffer(resizeOptions.imagePath)) {
45
+ const resizedBuffer = await (0, sharp_1.default)(resizeOptions.imagePath)
46
+ .resize(resizeOptions.size.width, resizeOptions.size.height)
47
+ .toBuffer();
48
+ return resizedBuffer;
49
+ }
50
+ if (resizeOptions.imagePath.startsWith("http")) {
51
+ if (baseDir) {
52
+ throw new Error("No need for baseDir when using an image URL.");
53
+ }
54
+ imagePath = resizeOptions.imagePath;
55
+ }
56
+ else {
57
+ if (!baseDir) {
58
+ throw new Error("baseDir is required for local file paths.");
59
+ }
60
+ imagePath = path_1.default.resolve(baseDir, resizeOptions.imagePath);
61
+ }
62
+ const image = await loadImages(imagePath, baseDir);
63
+ const resizedBuffer = await image.resize(resizeOptions.size).toBuffer();
64
+ return resizedBuffer;
65
+ }
66
+ catch (error) {
67
+ console.error("Error resizing image:", error);
68
+ throw new Error("Failed to resize image");
69
+ }
70
+ }
71
+ exports.resizingImg = resizingImg;
72
+ async function converter(imagePath, newExtension, baseDir) {
73
+ try {
74
+ let image;
75
+ if (imagePath.startsWith("http")) {
76
+ const response = await axios_1.default.get(imagePath, {
77
+ responseType: "arraybuffer",
78
+ });
79
+ image = (0, sharp_1.default)(Buffer.from(response.data));
80
+ }
81
+ else {
82
+ if (!imagePath) {
83
+ throw new Error("Image path is required.");
84
+ }
85
+ if (!baseDir) {
86
+ throw new Error("baseDir is required for local file paths.");
87
+ }
88
+ const absolutePath = path_1.default.resolve(baseDir, imagePath);
89
+ image = (0, sharp_1.default)(absolutePath);
90
+ }
91
+ const convertedBuffer = await image.toFormat(newExtension).toBuffer();
92
+ return convertedBuffer;
93
+ }
94
+ catch (error) {
95
+ console.error("Error changing image extension:", error);
96
+ throw new Error("Failed to change image extension");
97
+ }
98
+ }
99
+ exports.converter = converter;
100
+ async function applyColorFilters(imagePath, filterColor, baseDir) {
101
+ try {
102
+ let image;
103
+ if (imagePath.startsWith("http")) {
104
+ const pngBuffer = await converter(imagePath, "png", baseDir);
105
+ image = (0, sharp_1.default)(pngBuffer);
106
+ }
107
+ else {
108
+ if (!baseDir) {
109
+ throw new Error("You need to provide baseDir in options.");
110
+ }
111
+ const imagePathResolved = path_1.default.resolve(baseDir, imagePath);
112
+ image = (0, sharp_1.default)(imagePathResolved);
113
+ }
114
+ const hexColorRegex = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
115
+ if (!hexColorRegex.test(filterColor)) {
116
+ throw new Error("Invalid color format. Only hex colors are supported.");
117
+ }
118
+ image.tint(filterColor);
119
+ const outputBuffer = await image.toBuffer();
120
+ return outputBuffer;
121
+ }
122
+ catch (error) {
123
+ console.error("Error applying color filter:", error);
124
+ throw new Error("Failed to apply color filter");
125
+ }
126
+ }
127
+ exports.applyColorFilters = applyColorFilters;
128
+ async function imgEffects(imagePath, filters, baseDir) {
129
+ try {
130
+ let image;
131
+ if (imagePath.startsWith("http")) {
132
+ const pngBuffer = await converter(imagePath, "png", baseDir);
133
+ image = (0, sharp_1.default)(pngBuffer);
134
+ }
135
+ else {
136
+ if (!baseDir) {
137
+ throw new Error("You need to provide baseDir in options.");
138
+ }
139
+ const imagePathResolved = path_1.default.resolve(baseDir, imagePath);
140
+ image = (0, sharp_1.default)(imagePathResolved);
141
+ }
142
+ for (const filter of filters) {
143
+ switch (filter.type) {
144
+ case "flip":
145
+ image.flip({ horizontal: filter.horizontal, vertical: filter.vertical });
146
+ break;
147
+ case "mirror":
148
+ image.mirror({ horizontal: filter.horizontal, vertical: filter.vertical });
149
+ break;
150
+ case "rotate":
151
+ image.rotate(filter.deg, { mode: filter.mode });
152
+ break;
153
+ case "brightness":
154
+ image.brightness(filter.value);
155
+ break;
156
+ case "contrast":
157
+ image.contrast(filter.value);
158
+ break;
159
+ case "greyscale":
160
+ image.greyscale();
161
+ break;
162
+ case "normalize":
163
+ image.normalize();
164
+ break;
165
+ case "blur":
166
+ image.blur(filter.radius);
167
+ break;
168
+ case "posterize":
169
+ image.posterize(filter.levels);
170
+ break;
171
+ case "sepia":
172
+ image.sepia();
173
+ break;
174
+ default:
175
+ console.error(`Unsupported filter type: ${filter.type}`);
176
+ }
177
+ }
178
+ const outputBuffer = await image.toBuffer();
179
+ return outputBuffer;
180
+ }
181
+ catch (error) {
182
+ console.error("Error processing image:", error);
183
+ throw new Error("Failed to process image");
184
+ }
185
+ }
186
+ exports.imgEffects = imgEffects;
187
+ //# sourceMappingURL=general%20functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"general functions.js","sourceRoot":"","sources":["../../../lib/canvas/utils/general functions.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gDAAuB;AACvB,kDAA0B;AAEnB,KAAK,UAAU,UAAU,CAAC,SAAiB,EAAE,OAAgB;IAChE,IAAI,CAAC;QACD,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,IAAI,OAAO,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;YACpE,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAc,SAAS,EAAE;gBACrD,YAAY,EAAE,aAAa;aAC9B,CAAC,CAAC;YACH,OAAO,IAAA,eAAK,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;YACjE,CAAC;YAED,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACtD,OAAO,IAAA,eAAK,EAAC,YAAY,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC5C,CAAC;AACL,CAAC;AA3BD,gCA2BC;AAEM,KA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C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC1B,MAAM;gBACV,KAAK,WAAW;oBACZ,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC/B,MAAM;gBACV,KAAK,OAAO;oBACR,KAAK,CAAC,KAAK,EAAE,CAAC;oBACd,MAAM;gBACV;oBACI,OAAO,CAAC,KAAK,CAAC,4BAA4B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACjE,CAAC;QACL,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC5C,OAAO,YAAY,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;AACL,CAAC;AA1DD,gCA0DC"}
@@ -0,0 +1,60 @@
1
+ import { ImageProperties } from "./utils";
2
+ /**
3
+ * Applies shadow to the canvas context.
4
+ * @param ctx The canvas rendering context.
5
+ * @param shadow The shadow properties.
6
+ * @param x The x-coordinate of the shape.
7
+ * @param y The y-coordinate of the shape.
8
+ * @param width The width of the shape.
9
+ * @param height The height of the shape.
10
+ */
11
+ export declare function applyShadow(ctx: any, shadow: ImageProperties['shadow'], x: number, y: number, width: number, height: number): void;
12
+ /**
13
+ * Applies stroke to the canvas context.
14
+ * @param ctx The canvas rendering context.
15
+ * @param stroke The stroke properties.
16
+ * @param x The x-coordinate of the shape.
17
+ * @param y The y-coordinate of the shape.
18
+ * @param width The width of the shape.
19
+ * @param height The height of the shape.
20
+ */
21
+ export declare function applyStroke(ctx: any, stroke: ImageProperties['stroke'], x: number, y: number, width: number, height: number, gradient?: any): void;
22
+ /**
23
+ * Draws a shape on the canvas context.
24
+ * @param ctx The canvas rendering context.
25
+ * @param shapeSettings The settings for the shape.
26
+ */
27
+ export declare function drawShape(ctx: any, shapeSettings: any): void;
28
+ export declare function createGradient(ctx: any, gradientOptions: any, startX: number, startY: number, endX: number, endY: number): any;
29
+ /**
30
+ * Applies rotation to the canvas context.
31
+ * @param ctx The canvas rendering context.
32
+ * @param rotation The rotation angle in degrees.
33
+ * @param x The x-coordinate of the center of rotation.
34
+ * @param y The y-coordinate of the center of rotation.
35
+ * @param width The width of the shape.
36
+ * @param height The height of the shape.
37
+ */
38
+ export declare function applyRotation(ctx: any, rotation: number, x: number, y: number, width: number, height: number): void;
39
+ /**
40
+ * Applies border radius to the canvas context.
41
+ * @param ctx The canvas rendering context.
42
+ * @param image The image properties containing the border radius.
43
+ * @param x The x-coordinate of the shape.
44
+ * @param y The y-coordinate of the shape.
45
+ * @param width The width of the shape.
46
+ * @param height The height of the shape.
47
+ * @param borderRadius The border radius value.
48
+ */
49
+ export declare function imageRadius(ctx: any, image: any, x: number, y: number, width: number, height: number, borderRadius: any): void;
50
+ /**
51
+ * Applies border radius to the canvas context for objects.
52
+ * @param ctx The canvas rendering context.
53
+ * @param x The x-coordinate of the object.
54
+ * @param y The y-coordinate of the object.
55
+ * @param width The width of the object.
56
+ * @param height The height of the object.
57
+ * @param borderRadius The border radius value.
58
+ */
59
+ export declare function objectRadius(ctx: any, x: any, y: any, width: number, height: number, borderRadius?: any): void;
60
+ //# sourceMappingURL=imageProperties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageProperties.d.ts","sourceRoot":"","sources":["../../../lib/canvas/utils/imageProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAyBlI;A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ius = exports.imageRadius = exports.applyRotation = exports.createGradient = exports.drawShape = exports.applyStroke = exports.applyShadow = void 0;
4
+ /**
5
+ * Applies shadow to the canvas context.
6
+ * @param ctx The canvas rendering context.
7
+ * @param shadow The shadow properties.
8
+ * @param x The x-coordinate of the shape.
9
+ * @param y The y-coordinate of the shape.
10
+ * @param width The width of the shape.
11
+ * @param height The height of the shape.
12
+ */
13
+ function applyShadow(ctx, shadow, x, y, width, height) {
14
+ ctx.save();
15
+ if (shadow) {
16
+ ctx.globalAlpha = shadow.opacity || null;
17
+ ctx.filter = `blur(${shadow.blur || null}px)`;
18
+ const shadowX = x + (shadow.offsetX || 0);
19
+ const shadowY = y + (shadow.offsetY || 0);
20
+ objectRadius(ctx, shadowX, shadowY, width, height, shadow.borderRadius || 2);
21
+ ctx.fillStyle = shadow.color || "transparent";
22
+ ctx.fill();
23
+ }
24
+ ctx.filter = "none";
25
+ ctx.globalAlpha = 1;
26
+ ctx.restore();
27
+ }
28
+ exports.applyShadow = applyShadow;
29
+ /**
30
+ * Applies stroke to the canvas context.
31
+ * @param ctx The canvas rendering context.
32
+ * @param stroke The stroke properties.
33
+ * @param x The x-coordinate of the shape.
34
+ * @param y The y-coordinate of the shape.
35
+ * @param width The width of the shape.
36
+ * @param height The height of the shape.
37
+ */
38
+ function applyStroke(ctx, stroke, x, y, width, height, gradient) {
39
+ ctx.save();
40
+ if (stroke) {
41
+ if (gradient) {
42
+ const gradientFill = createGradient(ctx, gradient, x, y, x + width, y + height);
43
+ ctx.strokeStyle = gradientFill;
44
+ }
45
+ else {
46
+ ctx.strokeStyle = stroke.color || "transparent";
47
+ }
48
+ ctx.lineWidth = stroke.width || 0;
49
+ const adjustedX = x - (stroke.position || 0);
50
+ const adjustedY = y - (stroke.position || 0);
51
+ const adjustedWidth = width + (stroke.position || 0) * 2;
52
+ const adjustedHeight = height + (stroke.position || 0) * 2;
53
+ objectRadius(ctx, adjustedX, adjustedY, adjustedWidth, adjustedHeight, stroke.borderRadius || 2);
54
+ ctx.stroke();
55
+ }
56
+ ctx.restore();
57
+ }
58
+ exports.applyStroke = applyStroke;
59
+ /**
60
+ * Draws a shape on the canvas context.
61
+ * @param ctx The canvas rendering context.
62
+ * @param shapeSettings The settings for the shape.
63
+ */
64
+ function drawShape(ctx, shapeSettings) {
65
+ const { source, x, y, width, height, rotation, borderRadius, stroke, shadow, isFilled, color, gradient } = shapeSettings;
66
+ const shapeName = source.toLowerCase();
67
+ switch (shapeName) {
68
+ case 'circle':
69
+ ctx.save();
70
+ applyShadow(ctx, shadow, x, y, width, height);
71
+ applyRotation(ctx, rotation, x, y, width, height);
72
+ ctx.beginPath();
73
+ ctx.arc(x + width / 2, y + height / 2, width / 2, 0, Math.PI * 2);
74
+ break;
75
+ case 'square':
76
+ ctx.save();
77
+ applyRotation(ctx, rotation, x, y, width, height);
78
+ applyShadow(ctx, shadow, x, y, width, height);
79
+ break;
80
+ case 'triangle':
81
+ ctx.save();
82
+ applyRotation(ctx, rotation, x, y, width, height);
83
+ applyShadow(ctx, shadow, x, y, width, height);
84
+ ctx.beginPath();
85
+ ctx.moveTo(x, y + height);
86
+ ctx.lineTo(x + width / 2, y);
87
+ ctx.lineTo(x + width, y + height);
88
+ ctx.closePath();
89
+ break;
90
+ case 'pentagon':
91
+ ctx.save();
92
+ applyRotation(ctx, rotation, x, y, width, height);
93
+ applyShadow(ctx, shadow, x, y, width, height);
94
+ ctx.beginPath();
95
+ for (let i = 0; i < 5; i++) {
96
+ ctx.lineTo(x + width / 2 + width / 2 * Math.sin(i * 2 * Math.PI / 5), y + height / 2 - height / 2 * Math.cos(i * 2 * Math.PI / 5));
97
+ }
98
+ ctx.closePath();
99
+ break;
100
+ case 'hexagon':
101
+ ctx.save();
102
+ applyRotation(ctx, rotation, x, y, width, height);
103
+ applyShadow(ctx, shadow, x, y, width, height);
104
+ ctx.beginPath();
105
+ for (let i = 0; i < 6; i++) {
106
+ ctx.lineTo(x + width / 2 + width / 2 * Math.sin(i * 2 * Math.PI / 6), y + height / 2 - height / 2 * Math.cos(i * 2 * Math.PI / 6));
107
+ }
108
+ ctx.closePath();
109
+ break;
110
+ case 'heptagon':
111
+ ctx.save();
112
+ applyRotation(ctx, rotation, x, y, width, height);
113
+ applyShadow(ctx, shadow, x, y, width, height);
114
+ ctx.beginPath();
115
+ for (let i = 0; i < 7; i++) {
116
+ ctx.lineTo(x + width / 2 + width / 2 * Math.sin(i * 2 * Math.PI / 7), y + height / 2 - height / 2 * Math.cos(i * 2 * Math.PI / 7));
117
+ }
118
+ ctx.closePath();
119
+ break;
120
+ case 'octagon':
121
+ ctx.save();
122
+ applyRotation(ctx, rotation, x, y, width, height);
123
+ applyShadow(ctx, shadow, x, y, width, height);
124
+ ctx.beginPath();
125
+ for (let i = 0; i < 8; i++) {
126
+ ctx.lineTo(x + width / 2 + width / 2 * Math.sin(i * 2 * Math.PI / 8), y + height / 2 - height / 2 * Math.cos(i * 2 * Math.PI / 8));
127
+ }
128
+ ctx.closePath();
129
+ case 'star':
130
+ ctx.save();
131
+ applyRotation(ctx, rotation, x, y, width, height);
132
+ applyShadow(ctx, shadow, x, y, width, height);
133
+ ctx.beginPath();
134
+ const numPoints = 5;
135
+ const outerRadius = Math.min(width, height) / 2;
136
+ const innerRadius = outerRadius / 2;
137
+ for (let i = 0; i < numPoints * 2; i++) {
138
+ const radius = i % 2 === 0 ? outerRadius : innerRadius;
139
+ const angle = Math.PI / numPoints * i;
140
+ ctx.lineTo(x + width / 2 + radius * Math.sin(angle), y + height / 2 - radius * Math.cos(angle));
141
+ }
142
+ ctx.closePath();
143
+ break;
144
+ case 'oval':
145
+ ctx.save();
146
+ applyRotation(ctx, rotation, x, y, width, height);
147
+ applyShadow(ctx, shadow, x, y, width, height);
148
+ ctx.beginPath();
149
+ ctx.ellipse(x + width / 2, y + height / 2, width / 2, height / 2, 0, 0, Math.PI * 2);
150
+ ctx.closePath();
151
+ if (isFilled) {
152
+ ctx.fillStyle = color;
153
+ ctx.fill();
154
+ }
155
+ else {
156
+ applyStroke(ctx, stroke, x, y, width, height);
157
+ }
158
+ ctx.restore();
159
+ break;
160
+ default:
161
+ throw new Error(`Unsupported shape: ${shapeName}`);
162
+ }
163
+ if (isFilled) {
164
+ if (borderRadius) {
165
+ objectRadius(ctx, x, y, width, height, borderRadius);
166
+ if (gradient) {
167
+ const gradientFill = createGradient(ctx, gradient, x, y, x + width, y + height);
168
+ ctx.fillStyle = gradientFill;
169
+ }
170
+ else {
171
+ ctx.fillStyle = color || "transparent";
172
+ }
173
+ ctx.fill();
174
+ }
175
+ else {
176
+ if (gradient) {
177
+ const gradientFill = createGradient(ctx, gradient, x, y, x + width, y + height);
178
+ ctx.fillStyle = gradientFill;
179
+ }
180
+ else {
181
+ ctx.fillStyle = color || "transparent";
182
+ }
183
+ if (shapeName === 'square') {
184
+ ctx.fillRect(x, y, width, height);
185
+ }
186
+ else if (shapeName === 'circle') {
187
+ ctx.fill();
188
+ }
189
+ else {
190
+ ctx.fill();
191
+ }
192
+ }
193
+ }
194
+ else {
195
+ if (gradient) {
196
+ // Call createGradient with correct coordinates
197
+ const gradientFill = createGradient(ctx, gradient, x, // startX
198
+ y, // startY
199
+ x + width, // endX
200
+ y + height);
201
+ ctx.fillStyle = gradientFill;
202
+ }
203
+ applyStroke(ctx, stroke, x, y, width, height, gradient);
204
+ }
205
+ ctx.restore();
206
+ }
207
+ exports.drawShape = drawShape;
208
+ function createGradient(ctx, gradientOptions, startX, startY, endX, endY) {
209
+ if (!gradientOptions || !gradientOptions.type) {
210
+ throw new Error("Invalid gradient options. Provide a valid object with a type property.");
211
+ }
212
+ if (gradientOptions.type === "linear") {
213
+ if (typeof startX !== "number" ||
214
+ typeof startY !== "number" ||
215
+ typeof endX !== "number" ||
216
+ typeof endY !== "number") {
217
+ throw new Error("Invalid gradient options for linear gradient. Numeric values are required for startX, startY, endX, and endY.");
218
+ }
219
+ }
220
+ else if (gradientOptions.type === "radial") {
221
+ if (typeof gradientOptions.startX !== "number" ||
222
+ typeof gradientOptions.startY !== "number" ||
223
+ typeof gradientOptions.startRadius !== "number" ||
224
+ typeof gradientOptions.endX !== "number" ||
225
+ typeof gradientOptions.endY !== "number" ||
226
+ typeof gradientOptions.endRadius !== "number") {
227
+ throw new Error("Invalid gradient options for radial gradient. Numeric values are required for startX, startY, startRadius, endX, endY, and endRadius.");
228
+ }
229
+ }
230
+ else {
231
+ throw new Error('Unsupported gradient type. Use "linear" or "radial".');
232
+ }
233
+ const gradient = gradientOptions.type === "linear"
234
+ ? ctx.createLinearGradient(startX, startY, endX, endY)
235
+ : ctx.createRadialGradient(gradientOptions.startX, gradientOptions.startY, gradientOptions.startRadius, gradientOptions.endX, gradientOptions.endY, gradientOptions.endRadius);
236
+ for (const colorStop of gradientOptions.colors) {
237
+ gradient.addColorStop(colorStop.stop, colorStop.color);
238
+ }
239
+ return gradient;
240
+ }
241
+ exports.createGradient = createGradient;
242
+ /**
243
+ * Applies rotation to the canvas context.
244
+ * @param ctx The canvas rendering context.
245
+ * @param rotation The rotation angle in degrees.
246
+ * @param x The x-coordinate of the center of rotation.
247
+ * @param y The y-coordinate of the center of rotation.
248
+ * @param width The width of the shape.
249
+ * @param height The height of the shape.
250
+ */
251
+ function applyRotation(ctx, rotation, x, y, width, height) {
252
+ if (rotation !== undefined) {
253
+ const rotationX = x + width / 2;
254
+ const rotationY = y + height / 2;
255
+ ctx.translate(rotationX, rotationY);
256
+ ctx.rotate(rotation * Math.PI / 180);
257
+ ctx.translate(-rotationX, -rotationY);
258
+ }
259
+ }
260
+ exports.applyRotation = applyRotation;
261
+ /**
262
+ * Applies border radius to the canvas context.
263
+ * @param ctx The canvas rendering context.
264
+ * @param image The image properties containing the border radius.
265
+ * @param x The x-coordinate of the shape.
266
+ * @param y The y-coordinate of the shape.
267
+ * @param width The width of the shape.
268
+ * @param height The height of the shape.
269
+ * @param borderRadius The border radius value.
270
+ */
271
+ function imageRadius(ctx, image, x, y, width, height, borderRadius) {
272
+ ctx.save();
273
+ ctx.beginPath();
274
+ if (borderRadius === "circular") {
275
+ const circleRadius = Math.min(width, height) / 2;
276
+ ctx.arc(x + width / 2, y + height / 2, circleRadius, 0, 2 * Math.PI);
277
+ }
278
+ else {
279
+ ctx.moveTo(x + borderRadius, y);
280
+ ctx.lineTo(x + width - borderRadius, y);
281
+ ctx.quadraticCurveTo(x + width, y, x + width, y + borderRadius);
282
+ ctx.lineTo(x + width, y + height - borderRadius);
283
+ ctx.quadraticCurveTo(x + width, y + height, x + width - borderRadius, y + height);
284
+ ctx.lineTo(x + borderRadius, y + height);
285
+ ctx.quadraticCurveTo(x, y + height, x, y + height - borderRadius);
286
+ ctx.lineTo(x, y + borderRadius);
287
+ ctx.quadraticCurveTo(x, y, x + borderRadius, y);
288
+ }
289
+ ctx.closePath();
290
+ ctx.clip();
291
+ ctx.drawImage(image, x, y, width, height);
292
+ ctx.restore();
293
+ }
294
+ exports.imageRadius = imageRadius;
295
+ /**
296
+ * Applies border radius to the canvas context for objects.
297
+ * @param ctx The canvas rendering context.
298
+ * @param x The x-coordinate of the object.
299
+ * @param y The y-coordinate of the object.
300
+ * @param width The width of the object.
301
+ * @param height The height of the object.
302
+ * @param borderRadius The border radius value.
303
+ */
304
+ function objectRadius(ctx, x, y, width, height, borderRadius = 0.1) {
305
+ ctx.save();
306
+ if (borderRadius === "circular") {
307
+ const circleRadius = Math.min(width, height) / 2;
308
+ ctx.beginPath();
309
+ ctx.arc(x + width / 2, y + height / 2, circleRadius, 0, 2 * Math.PI);
310
+ ctx.closePath();
311
+ }
312
+ else if (borderRadius) {
313
+ ctx.beginPath();
314
+ ctx.moveTo(x + borderRadius, y);
315
+ ctx.lineTo(x + width - borderRadius, y);
316
+ ctx.quadraticCurveTo(x + width, y, x + width, y + borderRadius);
317
+ ctx.lineTo(x + width, y + height - borderRadius);
318
+ ctx.quadraticCurveTo(x + width, y + height, x + width - borderRadius, y + height);
319
+ ctx.lineTo(x + borderRadius, y + height);
320
+ ctx.quadraticCurveTo(x, y + height, x, y + height - borderRadius);
321
+ ctx.lineTo(x, y + borderRadius);
322
+ ctx.quadraticCurveTo(x, y, x + borderRadius, y);
323
+ ctx.closePath();
324
+ }
325
+ else {
326
+ ctx.fillRect(x, y, width, height);
327
+ }
328
+ ctx.restore();
329
+ }
330
+ exports.objectRadius = objectRadius;
331
+ //# sourceMappingURL=imageProperties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageProperties.js","sourceRoot":"","sources":["../../../lib/canvas/utils/imageProperties.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,GAAQ,EAAE,MAAiC,EAAE,CAAS,EAAE,CAAS,EAAE,KAAa,EAAE,MAAc;IAExH,GAAG,CAAC,IAAI,EAAE,CAAC;IAEX,IACI,MAAM,EACN,CAAC;QACD,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC;QACzC,GAAG,CAAC,MAAM,GAAG,QAAQ,MAAM,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC;QAE9C,MAAM,OAAO,GACX,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;QAC5B,MAAM,OAAO,GACX,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;QAE5B,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC,CAAA;QAE5E,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,KAAK,IAAI,aAAa,CAAC;QAC9C,GAAG,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IAED,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;IACpB,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC;IACpB,GAAG,CAAC,OAAO,EAAE,CAAC;AAEpB,CAAC;AAzBD,kCAyBC;AAID;;;;;;;;GAQG;AACH,SAAgB,WAAW,C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oCA4BC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Applies a radius border to the canvas context.
3
+ * @param ctx The canvas rendering context.
4
+ * @param width The width of the canvas.
5
+ * @param height The height of the canvas.
6
+ * @param radius The radius of the border.
7
+ * @returns A void.
8
+ */
9
+ export declare function radiusBorder(ctx: any, x: number | undefined, y: number | undefined, width: number, height: number, radius?: number): void;
10
+ //# sourceMappingURL=radius.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radius.d.ts","sourceRoot":"","sources":["../../../lib/canvas/utils/radius.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,oBAAY,EAAE,CAAC,oBAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,IAAI,CAiB5H"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.radiusBorder = void 0;
4
+ /**
5
+ * Applies a radius border to the canvas context.
6
+ * @param ctx The canvas rendering context.
7
+ * @param width The width of the canvas.
8
+ * @param height The height of the canvas.
9
+ * @param radius The radius of the border.
10
+ * @returns A void.
11
+ */
12
+ function radiusBorder(ctx, x = 0, y = 0, width, height, radius = 0) {
13
+ const minDimension = Math.min(width, height);
14
+ const maxRadius = minDimension / 2;
15
+ const clipRadius = Math.min(radius, maxRadius);
16
+ ctx.save();
17
+ ctx.beginPath();
18
+ ctx.moveTo(x + clipRadius, y);
19
+ ctx.lineTo(x + width - clipRadius, y);
20
+ ctx.quadraticCurveTo(x + width, y, x + width, y + clipRadius);
21
+ ctx.lineTo(x + width, y + height - clipRadius);
22
+ ctx.quadraticCurveTo(x + width, y + height, x + width - clipRadius, y + height);
23
+ ctx.lineTo(x + clipRadius, y + height);
24
+ ctx.quadraticCurveTo(x, y + height, x, y + height - clipRadius);
25
+ ctx.lineTo(x, y + clipRadius);
26
+ ctx.quadraticCurveTo(x, y, x + clipRadius, y);
27
+ ctx.closePath();
28
+ ctx.clip();
29
+ }
30
+ exports.radiusBorder = radiusBorder;
31
+ //# sourceMappingURL=radius.js.map