apexify.js 4.9.30 → 5.0.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 (129) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/README.md +119 -4
  3. package/apex-banner.png +0 -0
  4. package/dist/cjs/Canvas/ApexPainter.d.ts +158 -145
  5. package/dist/cjs/Canvas/ApexPainter.d.ts.map +1 -1
  6. package/dist/cjs/Canvas/ApexPainter.js +1443 -418
  7. package/dist/cjs/Canvas/ApexPainter.js.map +1 -1
  8. package/dist/cjs/Canvas/utils/Charts/charts.d.ts +7 -2
  9. package/dist/cjs/Canvas/utils/Charts/charts.d.ts.map +1 -1
  10. package/dist/cjs/Canvas/utils/Charts/charts.js +3 -1
  11. package/dist/cjs/Canvas/utils/Charts/charts.js.map +1 -1
  12. package/dist/cjs/Canvas/utils/Custom/advancedLines.d.ts +75 -0
  13. package/dist/cjs/Canvas/utils/Custom/advancedLines.d.ts.map +1 -0
  14. package/dist/cjs/Canvas/utils/Custom/advancedLines.js +263 -0
  15. package/dist/cjs/Canvas/utils/Custom/advancedLines.js.map +1 -0
  16. package/dist/cjs/Canvas/utils/Custom/customLines.d.ts +2 -1
  17. package/dist/cjs/Canvas/utils/Custom/customLines.d.ts.map +1 -1
  18. package/dist/cjs/Canvas/utils/Custom/customLines.js +73 -6
  19. package/dist/cjs/Canvas/utils/Custom/customLines.js.map +1 -1
  20. package/dist/cjs/Canvas/utils/General/batchOperations.d.ts +17 -0
  21. package/dist/cjs/Canvas/utils/General/batchOperations.d.ts.map +1 -0
  22. package/dist/cjs/Canvas/utils/General/batchOperations.js +88 -0
  23. package/dist/cjs/Canvas/utils/General/batchOperations.js.map +1 -0
  24. package/dist/cjs/Canvas/utils/General/general functions.d.ts +25 -3
  25. package/dist/cjs/Canvas/utils/General/general functions.d.ts.map +1 -1
  26. package/dist/cjs/Canvas/utils/General/general functions.js +37 -9
  27. package/dist/cjs/Canvas/utils/General/general functions.js.map +1 -1
  28. package/dist/cjs/Canvas/utils/General/imageCompression.d.ts +19 -0
  29. package/dist/cjs/Canvas/utils/General/imageCompression.d.ts.map +1 -0
  30. package/dist/cjs/Canvas/utils/General/imageCompression.js +262 -0
  31. package/dist/cjs/Canvas/utils/General/imageCompression.js.map +1 -0
  32. package/dist/cjs/Canvas/utils/General/imageStitching.d.ts +20 -0
  33. package/dist/cjs/Canvas/utils/General/imageStitching.d.ts.map +1 -0
  34. package/dist/cjs/Canvas/utils/General/imageStitching.js +227 -0
  35. package/dist/cjs/Canvas/utils/General/imageStitching.js.map +1 -0
  36. package/dist/cjs/Canvas/utils/Image/imageEffects.d.ts +37 -0
  37. package/dist/cjs/Canvas/utils/Image/imageEffects.d.ts.map +1 -0
  38. package/dist/cjs/Canvas/utils/Image/imageEffects.js +128 -0
  39. package/dist/cjs/Canvas/utils/Image/imageEffects.js.map +1 -0
  40. package/dist/cjs/Canvas/utils/Image/imageMasking.d.ts +67 -0
  41. package/dist/cjs/Canvas/utils/Image/imageMasking.d.ts.map +1 -0
  42. package/dist/cjs/Canvas/utils/Image/imageMasking.js +276 -0
  43. package/dist/cjs/Canvas/utils/Image/imageMasking.js.map +1 -0
  44. package/dist/cjs/Canvas/utils/Patterns/enhancedPatternRenderer.d.ts.map +1 -1
  45. package/dist/cjs/Canvas/utils/Patterns/enhancedPatternRenderer.js +16 -8
  46. package/dist/cjs/Canvas/utils/Patterns/enhancedPatternRenderer.js.map +1 -1
  47. package/dist/cjs/Canvas/utils/Texts/textPathRenderer.d.ts +17 -0
  48. package/dist/cjs/Canvas/utils/Texts/textPathRenderer.d.ts.map +1 -0
  49. package/dist/cjs/Canvas/utils/Texts/textPathRenderer.js +233 -0
  50. package/dist/cjs/Canvas/utils/Texts/textPathRenderer.js.map +1 -0
  51. package/dist/cjs/Canvas/utils/types.d.ts +153 -0
  52. package/dist/cjs/Canvas/utils/types.d.ts.map +1 -1
  53. package/dist/cjs/Canvas/utils/types.js.map +1 -1
  54. package/dist/cjs/Canvas/utils/utils.d.ts +9 -2
  55. package/dist/cjs/Canvas/utils/utils.d.ts.map +1 -1
  56. package/dist/cjs/Canvas/utils/utils.js +32 -1
  57. package/dist/cjs/Canvas/utils/utils.js.map +1 -1
  58. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  59. package/dist/esm/Canvas/ApexPainter.d.ts +158 -145
  60. package/dist/esm/Canvas/ApexPainter.d.ts.map +1 -1
  61. package/dist/esm/Canvas/ApexPainter.js +1443 -418
  62. package/dist/esm/Canvas/ApexPainter.js.map +1 -1
  63. package/dist/esm/Canvas/utils/Charts/charts.d.ts +7 -2
  64. package/dist/esm/Canvas/utils/Charts/charts.d.ts.map +1 -1
  65. package/dist/esm/Canvas/utils/Charts/charts.js +3 -1
  66. package/dist/esm/Canvas/utils/Charts/charts.js.map +1 -1
  67. package/dist/esm/Canvas/utils/Custom/advancedLines.d.ts +75 -0
  68. package/dist/esm/Canvas/utils/Custom/advancedLines.d.ts.map +1 -0
  69. package/dist/esm/Canvas/utils/Custom/advancedLines.js +263 -0
  70. package/dist/esm/Canvas/utils/Custom/advancedLines.js.map +1 -0
  71. package/dist/esm/Canvas/utils/Custom/customLines.d.ts +2 -1
  72. package/dist/esm/Canvas/utils/Custom/customLines.d.ts.map +1 -1
  73. package/dist/esm/Canvas/utils/Custom/customLines.js +73 -6
  74. package/dist/esm/Canvas/utils/Custom/customLines.js.map +1 -1
  75. package/dist/esm/Canvas/utils/General/batchOperations.d.ts +17 -0
  76. package/dist/esm/Canvas/utils/General/batchOperations.d.ts.map +1 -0
  77. package/dist/esm/Canvas/utils/General/batchOperations.js +88 -0
  78. package/dist/esm/Canvas/utils/General/batchOperations.js.map +1 -0
  79. package/dist/esm/Canvas/utils/General/general functions.d.ts +25 -3
  80. package/dist/esm/Canvas/utils/General/general functions.d.ts.map +1 -1
  81. package/dist/esm/Canvas/utils/General/general functions.js +37 -9
  82. package/dist/esm/Canvas/utils/General/general functions.js.map +1 -1
  83. package/dist/esm/Canvas/utils/General/imageCompression.d.ts +19 -0
  84. package/dist/esm/Canvas/utils/General/imageCompression.d.ts.map +1 -0
  85. package/dist/esm/Canvas/utils/General/imageCompression.js +262 -0
  86. package/dist/esm/Canvas/utils/General/imageCompression.js.map +1 -0
  87. package/dist/esm/Canvas/utils/General/imageStitching.d.ts +20 -0
  88. package/dist/esm/Canvas/utils/General/imageStitching.d.ts.map +1 -0
  89. package/dist/esm/Canvas/utils/General/imageStitching.js +227 -0
  90. package/dist/esm/Canvas/utils/General/imageStitching.js.map +1 -0
  91. package/dist/esm/Canvas/utils/Image/imageEffects.d.ts +37 -0
  92. package/dist/esm/Canvas/utils/Image/imageEffects.d.ts.map +1 -0
  93. package/dist/esm/Canvas/utils/Image/imageEffects.js +128 -0
  94. package/dist/esm/Canvas/utils/Image/imageEffects.js.map +1 -0
  95. package/dist/esm/Canvas/utils/Image/imageMasking.d.ts +67 -0
  96. package/dist/esm/Canvas/utils/Image/imageMasking.d.ts.map +1 -0
  97. package/dist/esm/Canvas/utils/Image/imageMasking.js +276 -0
  98. package/dist/esm/Canvas/utils/Image/imageMasking.js.map +1 -0
  99. package/dist/esm/Canvas/utils/Patterns/enhancedPatternRenderer.d.ts.map +1 -1
  100. package/dist/esm/Canvas/utils/Patterns/enhancedPatternRenderer.js +16 -8
  101. package/dist/esm/Canvas/utils/Patterns/enhancedPatternRenderer.js.map +1 -1
  102. package/dist/esm/Canvas/utils/Texts/textPathRenderer.d.ts +17 -0
  103. package/dist/esm/Canvas/utils/Texts/textPathRenderer.d.ts.map +1 -0
  104. package/dist/esm/Canvas/utils/Texts/textPathRenderer.js +233 -0
  105. package/dist/esm/Canvas/utils/Texts/textPathRenderer.js.map +1 -0
  106. package/dist/esm/Canvas/utils/types.d.ts +153 -0
  107. package/dist/esm/Canvas/utils/types.d.ts.map +1 -1
  108. package/dist/esm/Canvas/utils/types.js.map +1 -1
  109. package/dist/esm/Canvas/utils/utils.d.ts +9 -2
  110. package/dist/esm/Canvas/utils/utils.d.ts.map +1 -1
  111. package/dist/esm/Canvas/utils/utils.js +32 -1
  112. package/dist/esm/Canvas/utils/utils.js.map +1 -1
  113. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  114. package/lib/Canvas/ApexPainter.ts +1327 -266
  115. package/lib/Canvas/utils/Charts/charts.ts +16 -7
  116. package/lib/Canvas/utils/Custom/advancedLines.ts +335 -0
  117. package/lib/Canvas/utils/Custom/customLines.ts +84 -9
  118. package/lib/Canvas/utils/General/batchOperations.ts +103 -0
  119. package/lib/Canvas/utils/General/general functions.ts +85 -41
  120. package/lib/Canvas/utils/General/imageCompression.ts +316 -0
  121. package/lib/Canvas/utils/General/imageStitching.ts +252 -0
  122. package/lib/Canvas/utils/Image/imageEffects.ts +175 -0
  123. package/lib/Canvas/utils/Image/imageMasking.ts +335 -0
  124. package/lib/Canvas/utils/Patterns/enhancedPatternRenderer.ts +455 -444
  125. package/lib/Canvas/utils/Texts/textPathRenderer.ts +320 -0
  126. package/lib/Canvas/utils/types.ts +156 -0
  127. package/lib/Canvas/utils/utils.ts +52 -2
  128. package/package.json +75 -35
  129. package/types/imgur.d.ts +65 -0
@@ -0,0 +1,320 @@
1
+ import { SKRSContext2D } from '@napi-rs/canvas';
2
+
3
+ /**
4
+ * Renders text along a path
5
+ * @param ctx - Canvas 2D context
6
+ * @param text - Text to render
7
+ * @param pathConfig - Path configuration
8
+ * @param offset - Distance from path
9
+ */
10
+ export function renderTextOnPath(
11
+ ctx: SKRSContext2D,
12
+ text: string,
13
+ pathConfig: {
14
+ type: 'line' | 'arc' | 'bezier' | 'quadratic';
15
+ points: Array<{ x: number; y: number }>;
16
+ offset?: number;
17
+ },
18
+ offset: number = 0
19
+ ): void {
20
+ const path = createPath(ctx, pathConfig);
21
+ const pathLength = getPathLength(path, pathConfig);
22
+
23
+ ctx.save();
24
+
25
+ // Measure text to distribute along path
26
+ const metrics = ctx.measureText(text);
27
+ const textWidth = metrics.width;
28
+ const charWidth = textWidth / text.length;
29
+
30
+ let currentDistance = 0;
31
+
32
+ for (let i = 0; i < text.length; i++) {
33
+ const char = text[i];
34
+ const charDistance = currentDistance + charWidth / 2;
35
+
36
+ if (charDistance <= pathLength) {
37
+ const point = getPointOnPath(path, pathConfig, charDistance);
38
+ const angle = getAngleOnPath(path, pathConfig, charDistance);
39
+
40
+ ctx.save();
41
+ ctx.translate(point.x, point.y);
42
+ ctx.rotate(angle);
43
+ ctx.fillText(char, 0, offset);
44
+ ctx.restore();
45
+ }
46
+
47
+ currentDistance += charWidth;
48
+ }
49
+
50
+ ctx.restore();
51
+ }
52
+
53
+ /**
54
+ * Creates a path based on configuration
55
+ */
56
+ function createPath(
57
+ ctx: SKRSContext2D,
58
+ pathConfig: {
59
+ type: 'line' | 'arc' | 'bezier' | 'quadratic';
60
+ points: Array<{ x: number; y: number }>;
61
+ }
62
+ ): Path2D {
63
+ const path = new Path2D();
64
+
65
+ switch (pathConfig.type) {
66
+ case 'line':
67
+ if (pathConfig.points.length >= 2) {
68
+ path.moveTo(pathConfig.points[0].x, pathConfig.points[0].y);
69
+ for (let i = 1; i < pathConfig.points.length; i++) {
70
+ path.lineTo(pathConfig.points[i].x, pathConfig.points[i].y);
71
+ }
72
+ }
73
+ break;
74
+
75
+ case 'arc':
76
+ if (pathConfig.points.length >= 3) {
77
+ const center = pathConfig.points[0];
78
+ const start = pathConfig.points[1];
79
+ const end = pathConfig.points[2];
80
+ const radius = Math.sqrt(
81
+ Math.pow(start.x - center.x, 2) + Math.pow(start.y - center.y, 2)
82
+ );
83
+ const startAngle = Math.atan2(start.y - center.y, start.x - center.x);
84
+ const endAngle = Math.atan2(end.y - center.y, end.x - center.x);
85
+ path.arc(center.x, center.y, radius, startAngle, endAngle);
86
+ }
87
+ break;
88
+
89
+ case 'bezier':
90
+ if (pathConfig.points.length >= 4) {
91
+ path.moveTo(pathConfig.points[0].x, pathConfig.points[0].y);
92
+ for (let i = 1; i < pathConfig.points.length - 2; i += 3) {
93
+ if (i + 2 < pathConfig.points.length) {
94
+ path.bezierCurveTo(
95
+ pathConfig.points[i].x, pathConfig.points[i].y,
96
+ pathConfig.points[i + 1].x, pathConfig.points[i + 1].y,
97
+ pathConfig.points[i + 2].x, pathConfig.points[i + 2].y
98
+ );
99
+ }
100
+ }
101
+ }
102
+ break;
103
+
104
+ case 'quadratic':
105
+ if (pathConfig.points.length >= 3) {
106
+ path.moveTo(pathConfig.points[0].x, pathConfig.points[0].y);
107
+ for (let i = 1; i < pathConfig.points.length - 1; i += 2) {
108
+ if (i + 1 < pathConfig.points.length) {
109
+ path.quadraticCurveTo(
110
+ pathConfig.points[i].x, pathConfig.points[i].y,
111
+ pathConfig.points[i + 1].x, pathConfig.points[i + 1].y
112
+ );
113
+ }
114
+ }
115
+ }
116
+ break;
117
+ }
118
+
119
+ return path;
120
+ }
121
+
122
+ /**
123
+ * Gets approximate path length
124
+ */
125
+ function getPathLength(
126
+ path: Path2D,
127
+ pathConfig: {
128
+ type: 'line' | 'arc' | 'bezier' | 'quadratic';
129
+ points: Array<{ x: number; y: number }>;
130
+ }
131
+ ): number {
132
+ let length = 0;
133
+
134
+ switch (pathConfig.type) {
135
+ case 'line':
136
+ for (let i = 0; i < pathConfig.points.length - 1; i++) {
137
+ const dx = pathConfig.points[i + 1].x - pathConfig.points[i].x;
138
+ const dy = pathConfig.points[i + 1].y - pathConfig.points[i].y;
139
+ length += Math.sqrt(dx * dx + dy * dy);
140
+ }
141
+ break;
142
+
143
+ case 'arc':
144
+ if (pathConfig.points.length >= 3) {
145
+ const center = pathConfig.points[0];
146
+ const start = pathConfig.points[1];
147
+ const end = pathConfig.points[2];
148
+ const radius = Math.sqrt(
149
+ Math.pow(start.x - center.x, 2) + Math.pow(start.y - center.y, 2)
150
+ );
151
+ const startAngle = Math.atan2(start.y - center.y, start.x - center.x);
152
+ const endAngle = Math.atan2(end.y - center.y, end.x - center.x);
153
+ let angle = endAngle - startAngle;
154
+ if (angle < 0) angle += Math.PI * 2;
155
+ length = radius * angle;
156
+ }
157
+ break;
158
+
159
+ case 'bezier':
160
+ case 'quadratic':
161
+ // Approximate by sampling points along the curve
162
+ const samples = 100;
163
+ let prevPoint = pathConfig.points[0];
164
+ for (let i = 1; i <= samples; i++) {
165
+ const t = i / samples;
166
+ const point = getPointOnPath(path, pathConfig, t * 1000); // Approximate
167
+ const dx = point.x - prevPoint.x;
168
+ const dy = point.y - prevPoint.y;
169
+ length += Math.sqrt(dx * dx + dy * dy);
170
+ prevPoint = point;
171
+ }
172
+ break;
173
+ }
174
+
175
+ return length;
176
+ }
177
+
178
+ /**
179
+ * Gets a point on the path at a given distance
180
+ */
181
+ function getPointOnPath(
182
+ path: Path2D,
183
+ pathConfig: {
184
+ type: 'line' | 'arc' | 'bezier' | 'quadratic';
185
+ points: Array<{ x: number; y: number }>;
186
+ },
187
+ distance: number
188
+ ): { x: number; y: number } {
189
+ const pathLength = getPathLength(path, pathConfig);
190
+ const t = Math.min(1, distance / pathLength);
191
+
192
+ switch (pathConfig.type) {
193
+ case 'line':
194
+ return getPointOnLine(pathConfig.points, t);
195
+
196
+ case 'arc':
197
+ return getPointOnArc(pathConfig.points, t);
198
+
199
+ case 'bezier':
200
+ return getPointOnBezier(pathConfig.points, t);
201
+
202
+ case 'quadratic':
203
+ return getPointOnQuadratic(pathConfig.points, t);
204
+
205
+ default:
206
+ return { x: 0, y: 0 };
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Gets angle on path at a given distance
212
+ */
213
+ function getAngleOnPath(
214
+ path: Path2D,
215
+ pathConfig: {
216
+ type: 'line' | 'arc' | 'bezier' | 'quadratic';
217
+ points: Array<{ x: number; y: number }>;
218
+ },
219
+ distance: number
220
+ ): number {
221
+ const pathLength = getPathLength(path, pathConfig);
222
+ const t = Math.min(1, distance / pathLength);
223
+ const epsilon = 0.01;
224
+ const t2 = Math.min(1, (distance + epsilon) / pathLength);
225
+
226
+ const p1 = getPointOnPath(path, pathConfig, distance);
227
+ const p2 = getPointOnPath(path, pathConfig, distance + epsilon);
228
+
229
+ return Math.atan2(p2.y - p1.y, p2.x - p1.x);
230
+ }
231
+
232
+ function getPointOnLine(points: Array<{ x: number; y: number }>, t: number): { x: number; y: number } {
233
+ if (points.length < 2) return { x: 0, y: 0 };
234
+
235
+ const totalLength = points.reduce((sum, p, i) => {
236
+ if (i === 0) return 0;
237
+ const dx = p.x - points[i - 1].x;
238
+ const dy = p.y - points[i - 1].y;
239
+ return sum + Math.sqrt(dx * dx + dy * dy);
240
+ }, 0);
241
+
242
+ let currentLength = 0;
243
+ const targetLength = totalLength * t;
244
+
245
+ for (let i = 1; i < points.length; i++) {
246
+ const dx = points[i].x - points[i - 1].x;
247
+ const dy = points[i].y - points[i - 1].y;
248
+ const segmentLength = Math.sqrt(dx * dx + dy * dy);
249
+
250
+ if (currentLength + segmentLength >= targetLength) {
251
+ const segmentT = (targetLength - currentLength) / segmentLength;
252
+ return {
253
+ x: points[i - 1].x + dx * segmentT,
254
+ y: points[i - 1].y + dy * segmentT
255
+ };
256
+ }
257
+
258
+ currentLength += segmentLength;
259
+ }
260
+
261
+ return points[points.length - 1];
262
+ }
263
+
264
+ function getPointOnArc(points: Array<{ x: number; y: number }>, t: number): { x: number; y: number } {
265
+ if (points.length < 3) return { x: 0, y: 0 };
266
+
267
+ const center = points[0];
268
+ const start = points[1];
269
+ const end = points[2];
270
+ const radius = Math.sqrt(
271
+ Math.pow(start.x - center.x, 2) + Math.pow(start.y - center.y, 2)
272
+ );
273
+ const startAngle = Math.atan2(start.y - center.y, start.x - center.x);
274
+ const endAngle = Math.atan2(end.y - center.y, end.x - center.x);
275
+ let angle = startAngle + (endAngle - startAngle) * t;
276
+
277
+ return {
278
+ x: center.x + Math.cos(angle) * radius,
279
+ y: center.y + Math.sin(angle) * radius
280
+ };
281
+ }
282
+
283
+ function getPointOnBezier(points: Array<{ x: number; y: number }>, t: number): { x: number; y: number } {
284
+ if (points.length < 4) return { x: 0, y: 0 };
285
+
286
+ // Use first bezier curve
287
+ const p0 = points[0];
288
+ const p1 = points[1];
289
+ const p2 = points[2];
290
+ const p3 = points[3];
291
+
292
+ const mt = 1 - t;
293
+ const mt2 = mt * mt;
294
+ const mt3 = mt2 * mt;
295
+ const t2 = t * t;
296
+ const t3 = t2 * t;
297
+
298
+ return {
299
+ x: mt3 * p0.x + 3 * mt2 * t * p1.x + 3 * mt * t2 * p2.x + t3 * p3.x,
300
+ y: mt3 * p0.y + 3 * mt2 * t * p1.y + 3 * mt * t2 * p2.y + t3 * p3.y
301
+ };
302
+ }
303
+
304
+ function getPointOnQuadratic(points: Array<{ x: number; y: number }>, t: number): { x: number; y: number } {
305
+ if (points.length < 3) return { x: 0, y: 0 };
306
+
307
+ const p0 = points[0];
308
+ const p1 = points[1];
309
+ const p2 = points[2];
310
+
311
+ const mt = 1 - t;
312
+ const mt2 = mt * mt;
313
+ const t2 = t * t;
314
+
315
+ return {
316
+ x: mt2 * p0.x + 2 * mt * t * p1.x + t2 * p2.x,
317
+ y: mt2 * p0.y + 2 * mt * t * p1.y + t2 * p2.y
318
+ };
319
+ }
320
+
@@ -87,6 +87,15 @@ export interface CanvasConfig {
87
87
  fit?: 'fill' | 'contain' | 'cover';
88
88
  align?: 'center' | 'top' | 'bottom' | 'left' | 'right'
89
89
  | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
90
+ filters?: ImageFilter[]; // NEW: Apply filters to background image
91
+ opacity?: number; // NEW: Background image opacity
92
+ };
93
+ videoBg?: {
94
+ source: string;
95
+ frame?: number; // Extract specific frame (default: 0)
96
+ loop?: boolean; // Loop video (default: false)
97
+ autoplay?: boolean; // Autoplay (default: false)
98
+ opacity?: number; // Video opacity (default: 1)
90
99
  };
91
100
 
92
101
  colorBg?: string;
@@ -199,6 +208,35 @@ export interface ImageProperties {
199
208
 
200
209
  // image filters
201
210
  filters?: ImageFilter[];
211
+ filterIntensity?: number; // Global filter intensity multiplier (default: 1)
212
+ filterOrder?: 'pre' | 'post'; // Apply before or after transformations (default: 'post')
213
+
214
+ // image masking
215
+ mask?: {
216
+ source: string | Buffer; // Mask image
217
+ mode?: 'alpha' | 'luminance' | 'inverse'; // Mask mode (default: 'alpha')
218
+ };
219
+ clipPath?: Array<{ x: number; y: number }>; // Custom clipping path polygon
220
+
221
+ // image distortion/transform
222
+ distortion?: {
223
+ type: 'perspective' | 'warp' | 'bulge' | 'pinch';
224
+ points?: Array<{ x: number; y: number }>; // Control points for perspective/warp
225
+ intensity?: number; // Intensity for bulge/pinch (default: 0.5)
226
+ };
227
+ meshWarp?: {
228
+ gridX?: number; // Grid divisions X (default: 10)
229
+ gridY?: number; // Grid divisions Y (default: 10)
230
+ controlPoints?: Array<Array<{ x: number; y: number }>>; // Control point grid
231
+ };
232
+
233
+ // image effects stack
234
+ effects?: {
235
+ vignette?: { intensity: number; size: number }; // Vignette effect (0-1, 0-1)
236
+ lensFlare?: { x: number; y: number; intensity: number }; // Lens flare position and intensity
237
+ chromaticAberration?: { intensity: number }; // Chromatic aberration (0-1)
238
+ filmGrain?: { intensity: number }; // Film grain effect (0-1)
239
+ };
202
240
 
203
241
  // shape properties (when source is a shape)
204
242
  shape?: ShapeProperties;
@@ -370,6 +408,16 @@ export interface TextProperties {
370
408
  // === TRANSFORMATIONS ===
371
409
  /** Text rotation in degrees */
372
410
  rotation?: number;
411
+
412
+ // === TEXT PATH/CURVE FOLLOWING ===
413
+ /** Path for text to follow */
414
+ path?: {
415
+ type: 'line' | 'arc' | 'bezier' | 'quadratic';
416
+ points: Array<{ x: number; y: number }>;
417
+ offset?: number; // Distance from path (default: 0)
418
+ };
419
+ /** Render text along path */
420
+ textOnPath?: boolean;
373
421
  }
374
422
 
375
423
  /**
@@ -447,6 +495,27 @@ export interface CustomOptions {
447
495
  x: number;
448
496
  y: number;
449
497
  };
498
+ // Advanced path options
499
+ path?: {
500
+ type: 'smooth' | 'bezier' | 'catmull-rom';
501
+ tension?: number; // For smooth/catmull-rom (default: 0.5)
502
+ closed?: boolean; // Close the path (default: false)
503
+ };
504
+ // Arrow markers
505
+ arrow?: {
506
+ start?: boolean; // Arrow at start (default: false)
507
+ end?: boolean; // Arrow at end (default: false)
508
+ size?: number; // Arrow size (default: 10)
509
+ style?: 'filled' | 'outline'; // Arrow style (default: 'filled')
510
+ color?: string; // Arrow color (default: line color)
511
+ };
512
+ // Path markers
513
+ markers?: Array<{
514
+ position: number; // 0-1 along path
515
+ shape: 'circle' | 'square' | 'diamond' | 'arrow';
516
+ size: number;
517
+ color: string;
518
+ }>;
450
519
  lineStyle?: {
451
520
  width?: number;
452
521
  color?: string;
@@ -459,6 +528,13 @@ export interface CustomOptions {
459
528
  dashArray?: number[];
460
529
  offset?: number;
461
530
  };
531
+ // Line patterns
532
+ pattern?: {
533
+ type: 'dots' | 'dashes' | 'custom';
534
+ segments?: number[]; // For custom pattern
535
+ offset?: number; // Pattern offset
536
+ };
537
+ texture?: string | Buffer; // Texture image for line
462
538
  stroke?: {
463
539
  color?: string;
464
540
  gradient?: gradient;
@@ -765,6 +841,51 @@ export interface GradientConfig{
765
841
  }
766
842
 
767
843
 
844
+ // Batch operation types
845
+ export interface BatchOperation {
846
+ type: 'canvas' | 'image' | 'text' | 'chart';
847
+ config: any;
848
+ }
849
+
850
+ export interface ChainOperation {
851
+ method: string;
852
+ args: any[];
853
+ }
854
+
855
+ // Image stitching options
856
+ export interface StitchOptions {
857
+ direction?: 'horizontal' | 'vertical' | 'grid';
858
+ overlap?: number; // Percentage overlap for auto-alignment (0-100)
859
+ blend?: boolean; // Blend overlapping areas (default: false)
860
+ spacing?: number; // Spacing between images in pixels (default: 0)
861
+ }
862
+
863
+ // Collage layout options
864
+ export interface CollageLayout {
865
+ type: 'grid' | 'masonry' | 'carousel' | 'custom';
866
+ columns?: number;
867
+ rows?: number;
868
+ spacing?: number;
869
+ background?: string;
870
+ borderRadius?: number;
871
+ }
872
+
873
+ // Image compression options
874
+ export interface CompressionOptions {
875
+ quality?: number; // 0-100 (default: 90)
876
+ format?: 'jpeg' | 'webp' | 'avif';
877
+ maxWidth?: number;
878
+ maxHeight?: number;
879
+ progressive?: boolean; // For JPEG (default: false)
880
+ }
881
+
882
+ // Color palette extraction options
883
+ export interface PaletteOptions {
884
+ count?: number; // Number of colors (default: 10)
885
+ method?: 'kmeans' | 'median-cut' | 'octree';
886
+ format?: 'hex' | 'rgb' | 'hsl';
887
+ }
888
+
768
889
  export interface ExtractFramesOptions {
769
890
  interval: number;
770
891
  outputFormat?: 'jpg' | 'png';
@@ -821,3 +942,38 @@ export interface GradientConfig{
821
942
  blendMode?: "multiply" | "overlay" | "screen" | "darken" | "lighten" | "difference";
822
943
  maskSource?: string | Buffer | PathLike | Uint8Array;
823
944
  }
945
+
946
+ // Advanced Save Options
947
+ export interface SaveOptions {
948
+ /** Output directory path (default: './output') */
949
+ directory?: string;
950
+ /** File name or name pattern (default: auto-generated timestamp) */
951
+ filename?: string;
952
+ /** File format/extension (default: 'png') */
953
+ format?: 'png' | 'jpg' | 'jpeg' | 'webp' | 'avif' | 'gif';
954
+ /** Quality for JPEG/WebP (0-100, default: 90) */
955
+ quality?: number;
956
+ /** Auto-create directory if it doesn't exist (default: true) */
957
+ createDirectory?: boolean;
958
+ /** Naming pattern: 'timestamp' | 'counter' | 'custom' (default: 'timestamp') */
959
+ naming?: 'timestamp' | 'counter' | 'custom';
960
+ /** Counter starting value (for 'counter' naming, default: 1) */
961
+ counterStart?: number;
962
+ /** Prefix for filename (default: '') */
963
+ prefix?: string;
964
+ /** Suffix for filename (default: '') */
965
+ suffix?: string;
966
+ /** Overwrite existing files (default: false) */
967
+ overwrite?: boolean;
968
+ }
969
+
970
+ export interface SaveResult {
971
+ /** Full path to saved file */
972
+ path: string;
973
+ /** File name */
974
+ filename: string;
975
+ /** File size in bytes */
976
+ size: number;
977
+ /** File format */
978
+ format: string;
979
+ }
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- import { OutputFormat, CanvasConfig, ImageProperties, TextObject, TextProperties, GIFOptions, GIFResults, CustomOptions, cropOptions, GradientConfig, Frame, PatternOptions, ExtractFramesOptions, ResizeOptions, CropOptions, MaskOptions, BlendOptions, ShapeType, ShapeProperties, ImageFilter } from "./types";
13
+ import { OutputFormat, CanvasConfig, ImageProperties, TextObject, TextProperties, GIFOptions, GIFResults, CustomOptions, cropOptions, GradientConfig, Frame, PatternOptions, ExtractFramesOptions, ResizeOptions, CropOptions, MaskOptions, BlendOptions, ShapeType, ShapeProperties, ImageFilter, barChart_1, PieChartData, LineChartConfig, BatchOperation, ChainOperation, StitchOptions, CollageLayout, CompressionOptions, PaletteOptions, SaveOptions, SaveResult } from "./types";
14
14
  import { drawBackgroundColor, drawBackgroundGradient, customBackground, applyCanvasZoom, drawPattern, applyNoise } from "./Background/bg";
15
15
  import { buildPath, applyRotation, createGradientFill, fitInto, loadImageCached, applyStroke, drawBoxBackground, applyShadow } from './Image/imageProperties'
16
16
  import { applyImageFilters } from './Image/imageFilters'
@@ -21,6 +21,13 @@ import { customLines } from "./Custom/customLines";
21
21
  import { verticalBarChart, pieChart, lineChart } from './Charts/charts'
22
22
  import { url, arrayBuffer, base64, dataURL, blob } from "./General/conversion";
23
23
  import { drawShape, isShapeSource, createShapePath } from "./Shapes/shapes";
24
+ import { applyImageMask, applyClipPath, applyPerspectiveDistortion, applyBulgeDistortion, applyMeshWarp } from "./Image/imageMasking";
25
+ import { applyVignette, applyLensFlare, applyChromaticAberration, applyFilmGrain } from "./Image/imageEffects";
26
+ import { renderTextOnPath } from "./Texts/textPathRenderer";
27
+ import { drawArrow, drawMarker, createSmoothPath, createCatmullRomPath, applyLinePattern, applyLineTexture, getPointOnLinePath } from "./Custom/advancedLines";
28
+ import { batchOperations, chainOperations } from "./General/batchOperations";
29
+ import { stitchImages, createCollage } from "./General/imageStitching";
30
+ import { compressImage, extractPalette } from "./General/imageCompression";
24
31
 
25
32
  export {
26
33
  url,
@@ -81,5 +88,48 @@ export {
81
88
  isShapeSource,
82
89
  createShapePath,
83
90
  applyImageFilters,
84
- applySimpleProfessionalFilters
91
+ applySimpleProfessionalFilters,
92
+ barChart_1,
93
+ PieChartData,
94
+ LineChartConfig,
95
+ // New image masking and distortion
96
+ applyImageMask,
97
+ applyClipPath,
98
+ applyPerspectiveDistortion,
99
+ applyBulgeDistortion,
100
+ applyMeshWarp,
101
+ // New image effects
102
+ applyVignette,
103
+ applyLensFlare,
104
+ applyChromaticAberration,
105
+ applyFilmGrain,
106
+ // New text path rendering
107
+ renderTextOnPath,
108
+ // New custom lines features
109
+ drawArrow,
110
+ drawMarker,
111
+ createSmoothPath,
112
+ createCatmullRomPath,
113
+ applyLinePattern,
114
+ applyLineTexture,
115
+ getPointOnLinePath,
116
+ // Batch operations
117
+ batchOperations,
118
+ chainOperations,
119
+ // Image stitching and collage
120
+ stitchImages,
121
+ createCollage,
122
+ // Image compression and palette
123
+ compressImage,
124
+ extractPalette,
125
+ // New types
126
+ BatchOperation,
127
+ ChainOperation,
128
+ StitchOptions,
129
+ CollageLayout,
130
+ CompressionOptions,
131
+ PaletteOptions,
132
+ // Save options
133
+ SaveOptions,
134
+ SaveResult
85
135
  };