apexify.js 4.5.54 → 4.5.56
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.
- package/dist/cjs/ai/ApexAI.d.ts +1 -164
- package/dist/cjs/ai/ApexAI.d.ts.map +1 -1
- package/dist/cjs/ai/ApexAI.js +190 -373
- package/dist/cjs/ai/ApexAI.js.map +1 -1
- package/dist/cjs/ai/ApexModules.d.ts +1 -1
- package/dist/cjs/ai/ApexModules.d.ts.map +1 -1
- package/dist/cjs/ai/ApexModules.js +6 -18
- package/dist/cjs/ai/ApexModules.js.map +1 -1
- package/dist/cjs/ai/functions/draw.d.ts.map +1 -1
- package/dist/cjs/ai/functions/draw.js +6 -6
- package/dist/cjs/ai/functions/draw.js.map +1 -1
- package/dist/cjs/ai/modals-chat/electronHub/imageModels.d.ts +1 -1
- package/dist/cjs/ai/modals-chat/electronHub/imageModels.d.ts.map +1 -1
- package/dist/cjs/ai/modals-chat/electronHub/imageModels.js +1 -4
- package/dist/cjs/ai/modals-chat/electronHub/imageModels.js.map +1 -1
- package/dist/cjs/ai/utils.d.ts +1 -4
- package/dist/cjs/ai/utils.d.ts.map +1 -1
- package/dist/cjs/ai/utils.js +1 -7
- package/dist/cjs/ai/utils.js.map +1 -1
- package/dist/cjs/canvas/ApexPainter.d.ts +17 -14
- package/dist/cjs/canvas/ApexPainter.d.ts.map +1 -1
- package/dist/cjs/canvas/ApexPainter.js +29 -11
- package/dist/cjs/canvas/ApexPainter.js.map +1 -1
- package/dist/cjs/canvas/utils/Background/bg.d.ts +24 -0
- package/dist/cjs/canvas/utils/Background/bg.d.ts.map +1 -0
- package/dist/{esm/canvas/utils → cjs/canvas/utils/Background}/bg.js +27 -52
- package/dist/cjs/canvas/utils/Background/bg.js.map +1 -0
- package/dist/cjs/canvas/utils/Background/circular.d.ts +3 -0
- package/dist/cjs/canvas/utils/Background/circular.d.ts.map +1 -0
- package/dist/{esm/canvas/utils → cjs/canvas/utils/Background}/circular.js +0 -8
- package/dist/cjs/canvas/utils/{circular.js.map → Background/circular.js.map} +1 -1
- package/dist/cjs/canvas/utils/Background/radius.d.ts +18 -0
- package/dist/cjs/canvas/utils/Background/radius.d.ts.map +1 -0
- package/dist/cjs/canvas/utils/Background/radius.js +115 -0
- package/dist/cjs/canvas/utils/Background/radius.js.map +1 -0
- package/dist/cjs/canvas/utils/{charts.d.ts → Charts/charts.d.ts} +1 -1
- package/dist/cjs/canvas/utils/Charts/charts.d.ts.map +1 -0
- package/dist/cjs/canvas/utils/Charts/charts.js.map +1 -0
- package/dist/cjs/canvas/utils/Custom/customLines.d.ts +3 -0
- package/dist/cjs/canvas/utils/Custom/customLines.d.ts.map +1 -0
- package/dist/cjs/canvas/utils/Custom/customLines.js.map +1 -0
- package/dist/cjs/canvas/utils/General/conversion.d.ts.map +1 -0
- package/dist/cjs/canvas/utils/General/conversion.js.map +1 -0
- package/dist/cjs/canvas/utils/{general functions.d.ts → General/general functions.d.ts } +18 -4
- package/dist/cjs/canvas/utils/General/general functions.d.ts.map +1 -0
- package/dist/{esm/canvas/utils → cjs/canvas/utils/General}/general functions.js +89 -58
- package/dist/cjs/canvas/utils/General/general functions.js.map +1 -0
- package/dist/cjs/canvas/utils/Image/imageProperties.d.ts +81 -0
- package/dist/cjs/canvas/utils/Image/imageProperties.d.ts.map +1 -0
- package/dist/{esm/canvas/utils → cjs/canvas/utils/Image}/imageProperties.js +224 -45
- package/dist/cjs/canvas/utils/Image/imageProperties.js.map +1 -0
- package/dist/{esm/canvas/utils → cjs/canvas/utils/Texts}/textProperties.d.ts +1 -1
- package/dist/cjs/canvas/utils/Texts/textProperties.d.ts.map +1 -0
- package/dist/cjs/canvas/utils/Texts/textProperties.js.map +1 -0
- package/dist/cjs/canvas/utils/types.d.ts +41 -1
- package/dist/cjs/canvas/utils/types.d.ts.map +1 -1
- package/dist/cjs/canvas/utils/types.js.map +1 -1
- package/dist/cjs/canvas/utils/utils.d.ts +11 -11
- package/dist/cjs/canvas/utils/utils.d.ts.map +1 -1
- package/dist/cjs/canvas/utils/utils.js +11 -10
- package/dist/cjs/canvas/utils/utils.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/ai/ApexAI.d.ts +1 -164
- package/dist/esm/ai/ApexAI.d.ts.map +1 -1
- package/dist/esm/ai/ApexAI.js +190 -373
- package/dist/esm/ai/ApexAI.js.map +1 -1
- package/dist/esm/ai/ApexModules.d.ts +1 -1
- package/dist/esm/ai/ApexModules.d.ts.map +1 -1
- package/dist/esm/ai/ApexModules.js +6 -18
- package/dist/esm/ai/ApexModules.js.map +1 -1
- package/dist/esm/ai/functions/draw.d.ts.map +1 -1
- package/dist/esm/ai/functions/draw.js +6 -6
- package/dist/esm/ai/functions/draw.js.map +1 -1
- package/dist/esm/ai/modals-chat/electronHub/imageModels.d.ts +1 -1
- package/dist/esm/ai/modals-chat/electronHub/imageModels.d.ts.map +1 -1
- package/dist/esm/ai/modals-chat/electronHub/imageModels.js +1 -4
- package/dist/esm/ai/modals-chat/electronHub/imageModels.js.map +1 -1
- package/dist/esm/ai/utils.d.ts +1 -4
- package/dist/esm/ai/utils.d.ts.map +1 -1
- package/dist/esm/ai/utils.js +1 -7
- package/dist/esm/ai/utils.js.map +1 -1
- package/dist/esm/canvas/ApexPainter.d.ts +17 -14
- package/dist/esm/canvas/ApexPainter.d.ts.map +1 -1
- package/dist/esm/canvas/ApexPainter.js +29 -11
- package/dist/esm/canvas/ApexPainter.js.map +1 -1
- package/dist/esm/canvas/utils/Background/bg.d.ts +24 -0
- package/dist/esm/canvas/utils/Background/bg.d.ts.map +1 -0
- package/dist/{cjs/canvas/utils → esm/canvas/utils/Background}/bg.js +27 -52
- package/dist/esm/canvas/utils/Background/bg.js.map +1 -0
- package/dist/esm/canvas/utils/Background/circular.d.ts +3 -0
- package/dist/esm/canvas/utils/Background/circular.d.ts.map +1 -0
- package/dist/{cjs/canvas/utils → esm/canvas/utils/Background}/circular.js +0 -8
- package/dist/esm/canvas/utils/{circular.js.map → Background/circular.js.map} +1 -1
- package/dist/esm/canvas/utils/Background/radius.d.ts +18 -0
- package/dist/esm/canvas/utils/Background/radius.d.ts.map +1 -0
- package/dist/esm/canvas/utils/Background/radius.js +115 -0
- package/dist/esm/canvas/utils/Background/radius.js.map +1 -0
- package/dist/esm/canvas/utils/{charts.d.ts → Charts/charts.d.ts} +1 -1
- package/dist/esm/canvas/utils/Charts/charts.d.ts.map +1 -0
- package/dist/esm/canvas/utils/Charts/charts.js.map +1 -0
- package/dist/esm/canvas/utils/Custom/customLines.d.ts +3 -0
- package/dist/esm/canvas/utils/Custom/customLines.d.ts.map +1 -0
- package/dist/esm/canvas/utils/Custom/customLines.js.map +1 -0
- package/dist/esm/canvas/utils/General/conversion.d.ts.map +1 -0
- package/dist/esm/canvas/utils/General/conversion.js.map +1 -0
- package/dist/esm/canvas/utils/{general functions.d.ts → General/general functions.d.ts } +18 -4
- package/dist/esm/canvas/utils/General/general functions.d.ts.map +1 -0
- package/dist/{cjs/canvas/utils → esm/canvas/utils/General}/general functions.js +89 -58
- package/dist/esm/canvas/utils/General/general functions.js.map +1 -0
- package/dist/esm/canvas/utils/Image/imageProperties.d.ts +81 -0
- package/dist/esm/canvas/utils/Image/imageProperties.d.ts.map +1 -0
- package/dist/{cjs/canvas/utils → esm/canvas/utils/Image}/imageProperties.js +224 -45
- package/dist/esm/canvas/utils/Image/imageProperties.js.map +1 -0
- package/dist/{cjs/canvas/utils → esm/canvas/utils/Texts}/textProperties.d.ts +1 -1
- package/dist/esm/canvas/utils/Texts/textProperties.d.ts.map +1 -0
- package/dist/esm/canvas/utils/Texts/textProperties.js.map +1 -0
- package/dist/esm/canvas/utils/types.d.ts +41 -1
- package/dist/esm/canvas/utils/types.d.ts.map +1 -1
- package/dist/esm/canvas/utils/types.js.map +1 -1
- package/dist/esm/canvas/utils/utils.d.ts +11 -11
- package/dist/esm/canvas/utils/utils.d.ts.map +1 -1
- package/dist/esm/canvas/utils/utils.js +11 -10
- package/dist/esm/canvas/utils/utils.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/ai/ApexAI.ts +195 -697
- package/lib/ai/ApexModules.ts +7 -17
- package/lib/ai/functions/draw.ts +6 -8
- package/lib/ai/modals-chat/electronHub/imageModels.ts +2 -5
- package/lib/ai/utils.ts +0 -6
- package/lib/canvas/ApexPainter.ts +73 -38
- package/lib/canvas/utils/Background/bg.ts +97 -0
- package/lib/canvas/utils/Background/circular.ts +17 -0
- package/lib/canvas/utils/Background/radius.ts +113 -0
- package/lib/canvas/utils/{charts.ts → Charts/charts.ts} +1 -1
- package/lib/canvas/utils/{customLines.ts → Custom/customLines.ts} +1 -1
- package/lib/canvas/utils/{conversion.ts → General/conversion.ts} +1 -1
- package/lib/canvas/utils/{general functions.ts → General/general functions.ts } +143 -121
- package/lib/canvas/utils/Image/imageProperties.ts +631 -0
- package/lib/canvas/utils/{textProperties.ts → Texts/textProperties.ts} +1 -1
- package/lib/canvas/utils/types.ts +45 -2
- package/lib/canvas/utils/utils.ts +14 -11
- package/package.json +1 -4
- package/dist/cjs/ai/functions/generateVoiceResponse.d.ts +0 -10
- package/dist/cjs/ai/functions/generateVoiceResponse.d.ts.map +0 -1
- package/dist/cjs/ai/functions/generateVoiceResponse.js +0 -161
- package/dist/cjs/ai/functions/generateVoiceResponse.js.map +0 -1
- package/dist/cjs/ai/modals-chat/gemini/Gemini-flash.d.ts +0 -13
- package/dist/cjs/ai/modals-chat/gemini/Gemini-flash.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/gemini/Gemini-flash.js +0 -185
- package/dist/cjs/ai/modals-chat/gemini/Gemini-flash.js.map +0 -1
- package/dist/cjs/ai/modals-chat/gemini/Gemini-pro.d.ts +0 -13
- package/dist/cjs/ai/modals-chat/gemini/Gemini-pro.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/gemini/Gemini-pro.js +0 -185
- package/dist/cjs/ai/modals-chat/gemini/Gemini-pro.js.map +0 -1
- package/dist/cjs/ai/modals-chat/gemini/config.d.ts +0 -5
- package/dist/cjs/ai/modals-chat/gemini/config.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/gemini/config.js +0 -13
- package/dist/cjs/ai/modals-chat/gemini/config.js.map +0 -1
- package/dist/cjs/ai/modals-chat/gemini/geminiFast.d.ts +0 -15
- package/dist/cjs/ai/modals-chat/gemini/geminiFast.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/gemini/geminiFast.js +0 -146
- package/dist/cjs/ai/modals-chat/gemini/geminiFast.js.map +0 -1
- package/dist/cjs/canvas/utils/bg.d.ts +0 -23
- package/dist/cjs/canvas/utils/bg.d.ts.map +0 -1
- package/dist/cjs/canvas/utils/bg.js.map +0 -1
- package/dist/cjs/canvas/utils/charts.d.ts.map +0 -1
- package/dist/cjs/canvas/utils/charts.js.map +0 -1
- package/dist/cjs/canvas/utils/circular.d.ts +0 -10
- package/dist/cjs/canvas/utils/circular.d.ts.map +0 -1
- package/dist/cjs/canvas/utils/conversion.d.ts.map +0 -1
- package/dist/cjs/canvas/utils/conversion.js.map +0 -1
- package/dist/cjs/canvas/utils/customLines.d.ts +0 -3
- package/dist/cjs/canvas/utils/customLines.d.ts.map +0 -1
- package/dist/cjs/canvas/utils/customLines.js.map +0 -1
- package/dist/cjs/canvas/utils/general functions.d.ts.map +0 -1
- package/dist/cjs/canvas/utils/general functions.js.map +0 -1
- package/dist/cjs/canvas/utils/imageProperties.d.ts +0 -62
- package/dist/cjs/canvas/utils/imageProperties.d.ts.map +0 -1
- package/dist/cjs/canvas/utils/imageProperties.js.map +0 -1
- package/dist/cjs/canvas/utils/radius.d.ts +0 -10
- package/dist/cjs/canvas/utils/radius.d.ts.map +0 -1
- package/dist/cjs/canvas/utils/radius.js +0 -30
- package/dist/cjs/canvas/utils/radius.js.map +0 -1
- package/dist/cjs/canvas/utils/textProperties.d.ts.map +0 -1
- package/dist/cjs/canvas/utils/textProperties.js.map +0 -1
- package/dist/esm/ai/functions/generateVoiceResponse.d.ts +0 -10
- package/dist/esm/ai/functions/generateVoiceResponse.d.ts.map +0 -1
- package/dist/esm/ai/functions/generateVoiceResponse.js +0 -161
- package/dist/esm/ai/functions/generateVoiceResponse.js.map +0 -1
- package/dist/esm/ai/modals-chat/gemini/Gemini-flash.d.ts +0 -13
- package/dist/esm/ai/modals-chat/gemini/Gemini-flash.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/gemini/Gemini-flash.js +0 -185
- package/dist/esm/ai/modals-chat/gemini/Gemini-flash.js.map +0 -1
- package/dist/esm/ai/modals-chat/gemini/Gemini-pro.d.ts +0 -13
- package/dist/esm/ai/modals-chat/gemini/Gemini-pro.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/gemini/Gemini-pro.js +0 -185
- package/dist/esm/ai/modals-chat/gemini/Gemini-pro.js.map +0 -1
- package/dist/esm/ai/modals-chat/gemini/config.d.ts +0 -5
- package/dist/esm/ai/modals-chat/gemini/config.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/gemini/config.js +0 -13
- package/dist/esm/ai/modals-chat/gemini/config.js.map +0 -1
- package/dist/esm/ai/modals-chat/gemini/geminiFast.d.ts +0 -15
- package/dist/esm/ai/modals-chat/gemini/geminiFast.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/gemini/geminiFast.js +0 -146
- package/dist/esm/ai/modals-chat/gemini/geminiFast.js.map +0 -1
- package/dist/esm/canvas/utils/bg.d.ts +0 -23
- package/dist/esm/canvas/utils/bg.d.ts.map +0 -1
- package/dist/esm/canvas/utils/bg.js.map +0 -1
- package/dist/esm/canvas/utils/charts.d.ts.map +0 -1
- package/dist/esm/canvas/utils/charts.js.map +0 -1
- package/dist/esm/canvas/utils/circular.d.ts +0 -10
- package/dist/esm/canvas/utils/circular.d.ts.map +0 -1
- package/dist/esm/canvas/utils/conversion.d.ts.map +0 -1
- package/dist/esm/canvas/utils/conversion.js.map +0 -1
- package/dist/esm/canvas/utils/customLines.d.ts +0 -3
- package/dist/esm/canvas/utils/customLines.d.ts.map +0 -1
- package/dist/esm/canvas/utils/customLines.js.map +0 -1
- package/dist/esm/canvas/utils/general functions.d.ts.map +0 -1
- package/dist/esm/canvas/utils/general functions.js.map +0 -1
- package/dist/esm/canvas/utils/imageProperties.d.ts +0 -62
- package/dist/esm/canvas/utils/imageProperties.d.ts.map +0 -1
- package/dist/esm/canvas/utils/imageProperties.js.map +0 -1
- package/dist/esm/canvas/utils/radius.d.ts +0 -10
- package/dist/esm/canvas/utils/radius.d.ts.map +0 -1
- package/dist/esm/canvas/utils/radius.js +0 -30
- package/dist/esm/canvas/utils/radius.js.map +0 -1
- package/dist/esm/canvas/utils/textProperties.d.ts.map +0 -1
- package/dist/esm/canvas/utils/textProperties.js.map +0 -1
- package/lib/ai/functions/generateVoiceResponse.ts +0 -186
- package/lib/ai/modals-chat/gemini/Gemini-flash.ts +0 -200
- package/lib/ai/modals-chat/gemini/Gemini-pro.ts +0 -203
- package/lib/ai/modals-chat/gemini/config.ts +0 -11
- package/lib/ai/modals-chat/gemini/geminiFast.ts +0 -169
- package/lib/canvas/utils/bg.ts +0 -120
- package/lib/canvas/utils/circular.ts +0 -17
- package/lib/canvas/utils/imageProperties.ts +0 -418
- package/lib/canvas/utils/radius.ts +0 -26
- /package/dist/cjs/canvas/utils/{charts.js → Charts/charts.js} +0 -0
- /package/dist/cjs/canvas/utils/{customLines.js → Custom/customLines.js} +0 -0
- /package/dist/cjs/canvas/utils/{conversion.d.ts → General/conversion.d.ts} +0 -0
- /package/dist/cjs/canvas/utils/{conversion.js → General/conversion.js} +0 -0
- /package/dist/cjs/canvas/utils/{textProperties.js → Texts/textProperties.js} +0 -0
- /package/dist/esm/canvas/utils/{charts.js → Charts/charts.js} +0 -0
- /package/dist/esm/canvas/utils/{customLines.js → Custom/customLines.js} +0 -0
- /package/dist/esm/canvas/utils/{conversion.d.ts → General/conversion.d.ts} +0 -0
- /package/dist/esm/canvas/utils/{conversion.js → General/conversion.js} +0 -0
- /package/dist/esm/canvas/utils/{textProperties.js → Texts/textProperties.js} +0 -0
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
import { ImageProperties } from "./utils";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Applies shadow to the canvas context.
|
|
5
|
-
* @param ctx The canvas rendering context.
|
|
6
|
-
* @param shadow The shadow properties.
|
|
7
|
-
* @param x The x-coordinate of the shape.
|
|
8
|
-
* @param y The y-coordinate of the shape.
|
|
9
|
-
* @param width The width of the shape.
|
|
10
|
-
* @param height The height of the shape.
|
|
11
|
-
*/
|
|
12
|
-
export function applyShadow(ctx: any, shadow: ImageProperties['shadow'], x: number, y: number, width: number, height: number): void {
|
|
13
|
-
|
|
14
|
-
ctx.save();
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
shadow
|
|
18
|
-
) {
|
|
19
|
-
ctx.globalAlpha = shadow.opacity || null;
|
|
20
|
-
ctx.filter = `blur(${shadow.blur || null}px)`;
|
|
21
|
-
|
|
22
|
-
const shadowX =
|
|
23
|
-
x + (shadow.offsetX || 0);
|
|
24
|
-
const shadowY =
|
|
25
|
-
y + (shadow.offsetY || 0);
|
|
26
|
-
|
|
27
|
-
objectRadius(ctx, shadowX, shadowY, width, height, shadow.borderRadius || 2, shadow.borderPosition)
|
|
28
|
-
|
|
29
|
-
ctx.fillStyle = shadow.color || "transparent";
|
|
30
|
-
ctx.fill();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
ctx.filter = "none";
|
|
34
|
-
ctx.globalAlpha = 1;
|
|
35
|
-
ctx.restore();
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Applies stroke to the canvas context.
|
|
43
|
-
* @param ctx The canvas rendering context.
|
|
44
|
-
* @param stroke The stroke properties.
|
|
45
|
-
* @param x The x-coordinate of the shape.
|
|
46
|
-
* @param y The y-coordinate of the shape.
|
|
47
|
-
* @param width The width of the shape.
|
|
48
|
-
* @param height The height of the shape.
|
|
49
|
-
*/
|
|
50
|
-
export function applyStroke(ctx: any, stroke: ImageProperties['stroke'], x: number, y: number, width: number, height: number): void {
|
|
51
|
-
ctx.save();
|
|
52
|
-
|
|
53
|
-
if (stroke) {
|
|
54
|
-
if (stroke.gradient) {
|
|
55
|
-
const gradientFill = createGradient(
|
|
56
|
-
ctx,
|
|
57
|
-
stroke.gradient,
|
|
58
|
-
x,
|
|
59
|
-
y,
|
|
60
|
-
x + width,
|
|
61
|
-
y + height
|
|
62
|
-
);
|
|
63
|
-
ctx.strokeStyle = gradientFill;
|
|
64
|
-
} else {
|
|
65
|
-
ctx.strokeStyle = stroke.color || "transparent";
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
ctx.lineWidth = stroke.width || 0;
|
|
69
|
-
|
|
70
|
-
const adjustedX = x - (stroke.position || 0);
|
|
71
|
-
const adjustedY = y - (stroke.position || 0);
|
|
72
|
-
const adjustedWidth = width + (stroke.position || 0) * 2;
|
|
73
|
-
const adjustedHeight = height + (stroke.position || 0) * 2;
|
|
74
|
-
|
|
75
|
-
objectRadius(ctx, adjustedX, adjustedY, adjustedWidth, adjustedHeight, stroke.borderRadius || 2, stroke.borderPosition);
|
|
76
|
-
|
|
77
|
-
ctx.stroke();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
ctx.restore();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Draws a shape on the canvas context.
|
|
85
|
-
* @param ctx The canvas rendering context.
|
|
86
|
-
* @param shapeSettings The settings for the shape.
|
|
87
|
-
*/
|
|
88
|
-
export function drawShape(ctx: any, shapeSettings: any) {
|
|
89
|
-
const { source, x, y, width, height, rotation, borderRadius, borderPosition, stroke, shadow, isFilled, color, gradient } = shapeSettings;
|
|
90
|
-
|
|
91
|
-
const shapeName = source.toLowerCase();
|
|
92
|
-
|
|
93
|
-
switch (shapeName) {
|
|
94
|
-
case 'circle':
|
|
95
|
-
ctx.save();
|
|
96
|
-
applyShadow(ctx, shadow, x, y, width, height);
|
|
97
|
-
applyRotation(ctx, rotation, x, y, width, height);
|
|
98
|
-
ctx.beginPath();
|
|
99
|
-
ctx.arc(x + width / 2, y + height / 2, width / 2, 0, Math.PI * 2);
|
|
100
|
-
break;
|
|
101
|
-
case 'square':
|
|
102
|
-
ctx.save();
|
|
103
|
-
applyRotation(ctx, rotation, x, y, width, height);
|
|
104
|
-
applyShadow(ctx, shadow, x, y, width, height);
|
|
105
|
-
break;
|
|
106
|
-
case 'triangle':
|
|
107
|
-
ctx.save();
|
|
108
|
-
applyRotation(ctx, rotation, x, y, width, height);
|
|
109
|
-
applyShadow(ctx, shadow, x, y, width, height);
|
|
110
|
-
ctx.beginPath();
|
|
111
|
-
ctx.moveTo(x, y + height);
|
|
112
|
-
ctx.lineTo(x + width / 2, y);
|
|
113
|
-
ctx.lineTo(x + width, y + height);
|
|
114
|
-
ctx.closePath();
|
|
115
|
-
break;
|
|
116
|
-
case 'pentagon':
|
|
117
|
-
ctx.save();
|
|
118
|
-
applyRotation(ctx, rotation, x, y, width, height);
|
|
119
|
-
applyShadow(ctx, shadow, x, y, width, height);
|
|
120
|
-
ctx.beginPath();
|
|
121
|
-
for (let i = 0; i < 5; i++) {
|
|
122
|
-
ctx.lineTo(x + width / 2 + width / 2 * Math.sin(i * 2 * Math.PI / 5),
|
|
123
|
-
y + height / 2 - height / 2 * Math.cos(i * 2 * Math.PI / 5));
|
|
124
|
-
}
|
|
125
|
-
ctx.closePath();
|
|
126
|
-
break;
|
|
127
|
-
case 'hexagon':
|
|
128
|
-
ctx.save();
|
|
129
|
-
applyRotation(ctx, rotation, x, y, width, height);
|
|
130
|
-
applyShadow(ctx, shadow, x, y, width, height);
|
|
131
|
-
ctx.beginPath();
|
|
132
|
-
for (let i = 0; i < 6; i++) {
|
|
133
|
-
ctx.lineTo(x + width / 2 + width / 2 * Math.sin(i * 2 * Math.PI / 6),
|
|
134
|
-
y + height / 2 - height / 2 * Math.cos(i * 2 * Math.PI / 6));
|
|
135
|
-
}
|
|
136
|
-
ctx.closePath();
|
|
137
|
-
break;
|
|
138
|
-
case 'heptagon':
|
|
139
|
-
ctx.save();
|
|
140
|
-
applyRotation(ctx, rotation, x, y, width, height);
|
|
141
|
-
applyShadow(ctx, shadow, x, y, width, height);
|
|
142
|
-
ctx.beginPath();
|
|
143
|
-
for (let i = 0; i < 7; i++) {
|
|
144
|
-
ctx.lineTo(x + width / 2 + width / 2 * Math.sin(i * 2 * Math.PI / 7),
|
|
145
|
-
y + height / 2 - height / 2 * Math.cos(i * 2 * Math.PI / 7));
|
|
146
|
-
}
|
|
147
|
-
ctx.closePath();
|
|
148
|
-
break;
|
|
149
|
-
case 'octagon':
|
|
150
|
-
ctx.save();
|
|
151
|
-
applyRotation(ctx, rotation, x, y, width, height);
|
|
152
|
-
applyShadow(ctx, shadow, x, y, width, height);
|
|
153
|
-
ctx.beginPath();
|
|
154
|
-
for (let i = 0; i < 8; i++) {
|
|
155
|
-
ctx.lineTo(x + width / 2 + width / 2 * Math.sin(i * 2 * Math.PI / 8),
|
|
156
|
-
y + height / 2 - height / 2 * Math.cos(i * 2 * Math.PI / 8));
|
|
157
|
-
}
|
|
158
|
-
ctx.closePath();
|
|
159
|
-
case 'star':
|
|
160
|
-
ctx.save();
|
|
161
|
-
applyRotation(ctx, rotation, x, y, width, height);
|
|
162
|
-
applyShadow(ctx, shadow, x, y, width, height);
|
|
163
|
-
ctx.beginPath();
|
|
164
|
-
const numPoints = 5;
|
|
165
|
-
const outerRadius = Math.min(width, height) / 2;
|
|
166
|
-
const innerRadius = outerRadius / 2;
|
|
167
|
-
for (let i = 0; i < numPoints * 2; i++) {
|
|
168
|
-
const radius = i % 2 === 0 ? outerRadius : innerRadius;
|
|
169
|
-
const angle = Math.PI / numPoints * i;
|
|
170
|
-
ctx.lineTo(x + width / 2 + radius * Math.sin(angle),
|
|
171
|
-
y + height / 2 - radius * Math.cos(angle));
|
|
172
|
-
}
|
|
173
|
-
ctx.closePath();
|
|
174
|
-
break;
|
|
175
|
-
case 'oval':
|
|
176
|
-
ctx.save();
|
|
177
|
-
applyRotation(ctx, rotation, x, y, width, height);
|
|
178
|
-
applyShadow(ctx, shadow, x, y, width, height);
|
|
179
|
-
|
|
180
|
-
ctx.beginPath();
|
|
181
|
-
ctx.ellipse(x + width / 2, y + height / 2, width / 2, height / 2, 0, 0, Math.PI * 2);
|
|
182
|
-
ctx.closePath();
|
|
183
|
-
if (isFilled) {
|
|
184
|
-
ctx.fillStyle = color;
|
|
185
|
-
ctx.fill();
|
|
186
|
-
} else {
|
|
187
|
-
applyStroke(ctx, stroke, x, y, width, height);
|
|
188
|
-
}
|
|
189
|
-
ctx.restore();
|
|
190
|
-
break;
|
|
191
|
-
default:
|
|
192
|
-
throw new Error(`Unsupported shape: ${shapeName}`);
|
|
193
|
-
}
|
|
194
|
-
if (isFilled) {
|
|
195
|
-
if (borderRadius) {
|
|
196
|
-
objectRadius(ctx, x, y, width, height, borderRadius, borderPosition);
|
|
197
|
-
if (gradient) {
|
|
198
|
-
const gradientFill = createGradient(
|
|
199
|
-
ctx,
|
|
200
|
-
gradient,
|
|
201
|
-
x,
|
|
202
|
-
y,
|
|
203
|
-
x + width,
|
|
204
|
-
y + height,
|
|
205
|
-
);
|
|
206
|
-
ctx.fillStyle = gradientFill;
|
|
207
|
-
} else {
|
|
208
|
-
ctx.fillStyle = color || "transparent";
|
|
209
|
-
}
|
|
210
|
-
ctx.fill();
|
|
211
|
-
} else {
|
|
212
|
-
if (gradient) {
|
|
213
|
-
const gradientFill = createGradient(
|
|
214
|
-
ctx,
|
|
215
|
-
gradient,
|
|
216
|
-
x,
|
|
217
|
-
y,
|
|
218
|
-
x + width,
|
|
219
|
-
y + height,
|
|
220
|
-
);
|
|
221
|
-
ctx.fillStyle = gradientFill;
|
|
222
|
-
} else {
|
|
223
|
-
ctx.fillStyle = color || "transparent";
|
|
224
|
-
}
|
|
225
|
-
if (shapeName === 'square') {
|
|
226
|
-
ctx.fillRect(x, y, width, height);
|
|
227
|
-
} else if (shapeName === 'circle') {
|
|
228
|
-
ctx.fill();
|
|
229
|
-
} else {
|
|
230
|
-
ctx.fill()
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
applyStroke(ctx, stroke, x, y, width, height);
|
|
234
|
-
} else {
|
|
235
|
-
if (gradient) {
|
|
236
|
-
const gradientFill = createGradient(
|
|
237
|
-
ctx,
|
|
238
|
-
gradient,
|
|
239
|
-
x,
|
|
240
|
-
y,
|
|
241
|
-
x + width,
|
|
242
|
-
y + height,
|
|
243
|
-
);
|
|
244
|
-
ctx.fillStyle = gradientFill;
|
|
245
|
-
}
|
|
246
|
-
applyStroke(ctx, stroke, x, y, width, height);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
ctx.restore();
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export function createGradient(ctx: any, gradientOptions: any, startX: number, startY: number, endX: number, endY: number) {
|
|
253
|
-
if (!gradientOptions || !gradientOptions.type || !gradientOptions.colors) {
|
|
254
|
-
throw new Error("Invalid gradient options. Provide a valid object with type and colors properties.");
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (!Array.isArray(gradientOptions.colors)) {
|
|
258
|
-
throw new Error("Invalid gradient options. The colors property should be an array of color stops.");
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (gradientOptions.type === "linear") {
|
|
262
|
-
if (
|
|
263
|
-
typeof startX !== "number" ||
|
|
264
|
-
typeof startY !== "number" ||
|
|
265
|
-
typeof endX !== "number" ||
|
|
266
|
-
typeof endY !== "number"
|
|
267
|
-
) {
|
|
268
|
-
throw new Error("Invalid gradient options for linear gradient. Numeric values are required for startX, startY, endX, and endY.");
|
|
269
|
-
}
|
|
270
|
-
const gradient = ctx.createLinearGradient(startX, startY, endX, endY);
|
|
271
|
-
|
|
272
|
-
for (const colorStop of gradientOptions.colors) {
|
|
273
|
-
if (typeof colorStop.stop !== "number" || typeof colorStop.color !== "string") {
|
|
274
|
-
throw new Error("Invalid color stop. Each color stop should have a numeric stop value and a color string.");
|
|
275
|
-
}
|
|
276
|
-
gradient.addColorStop(colorStop.stop, colorStop.color);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return gradient;
|
|
280
|
-
|
|
281
|
-
} else if (gradientOptions.type === "radial") {
|
|
282
|
-
if (
|
|
283
|
-
typeof gradientOptions.startX !== "number" ||
|
|
284
|
-
typeof gradientOptions.startY !== "number" ||
|
|
285
|
-
typeof gradientOptions.startRadius !== "number" ||
|
|
286
|
-
typeof gradientOptions.endX !== "number" ||
|
|
287
|
-
typeof gradientOptions.endY !== "number" ||
|
|
288
|
-
typeof gradientOptions.endRadius !== "number"
|
|
289
|
-
) {
|
|
290
|
-
throw new Error("Invalid gradient options for radial gradient. Numeric values are required for startX, startY, startRadius, endX, endY, and endRadius.");
|
|
291
|
-
}
|
|
292
|
-
const gradient = ctx.createRadialGradient(
|
|
293
|
-
gradientOptions.startX,
|
|
294
|
-
gradientOptions.startY,
|
|
295
|
-
gradientOptions.startRadius,
|
|
296
|
-
gradientOptions.endX,
|
|
297
|
-
gradientOptions.endY,
|
|
298
|
-
gradientOptions.endRadius
|
|
299
|
-
);
|
|
300
|
-
|
|
301
|
-
for (const colorStop of gradientOptions.colors) {
|
|
302
|
-
if (typeof colorStop.stop !== "number" || typeof colorStop.color !== "string") {
|
|
303
|
-
throw new Error("Invalid color stop. Each color stop should have a numeric stop value and a color string.");
|
|
304
|
-
}
|
|
305
|
-
gradient.addColorStop(colorStop.stop, colorStop.color);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return gradient;
|
|
309
|
-
|
|
310
|
-
} else {
|
|
311
|
-
throw new Error('Unsupported gradient type. Use "linear" or "radial".');
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Applies rotation to the canvas context.
|
|
318
|
-
* @param ctx The canvas rendering context.
|
|
319
|
-
* @param rotation The rotation angle in degrees.
|
|
320
|
-
* @param x The x-coordinate of the center of rotation.
|
|
321
|
-
* @param y The y-coordinate of the center of rotation.
|
|
322
|
-
* @param width The width of the shape.
|
|
323
|
-
* @param height The height of the shape.
|
|
324
|
-
*/
|
|
325
|
-
export function applyRotation(ctx: any, rotation: number, x: number, y: number, width: number, height: number): void {
|
|
326
|
-
if (rotation !== undefined) {
|
|
327
|
-
const rotationX = x + width / 2;
|
|
328
|
-
const rotationY = y + height / 2;
|
|
329
|
-
ctx.translate(rotationX, rotationY);
|
|
330
|
-
ctx.rotate(rotation * Math.PI / 180);
|
|
331
|
-
ctx.translate(-rotationX, -rotationY);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Applies border radius to the canvas context.
|
|
337
|
-
* @param ctx The canvas rendering context.
|
|
338
|
-
* @param image The image properties containing the border radius.
|
|
339
|
-
* @param x The x-coordinate of the shape.
|
|
340
|
-
* @param y The y-coordinate of the shape.
|
|
341
|
-
* @param width The width of the shape.
|
|
342
|
-
* @param height The height of the shape.
|
|
343
|
-
* @param borderRadius The border radius value.
|
|
344
|
-
* @param borderPosition The border radius position to be applied on.
|
|
345
|
-
*/
|
|
346
|
-
export function imageRadius(ctx: any, image: any, x: number, y: number, width: number, height: number, borderRadius: any, borderPosition: string = 'all'): void {
|
|
347
|
-
ctx.save();
|
|
348
|
-
ctx.beginPath();
|
|
349
|
-
|
|
350
|
-
if (borderRadius === "circular") {
|
|
351
|
-
const circleRadius = Math.min(width, height) / 2;
|
|
352
|
-
ctx.arc(x + width / 2, y + height / 2, circleRadius, 0, 2 * Math.PI);
|
|
353
|
-
} else {
|
|
354
|
-
ctx.moveTo(x + borderRadius, y);
|
|
355
|
-
ctx.lineTo(x + width - borderRadius, y);
|
|
356
|
-
ctx.quadraticCurveTo(x + width, y, x + width, y + borderRadius);
|
|
357
|
-
ctx.lineTo(x + width, y + height - borderRadius);
|
|
358
|
-
ctx.quadraticCurveTo(
|
|
359
|
-
x + width,
|
|
360
|
-
y + height,
|
|
361
|
-
x + width - borderRadius,
|
|
362
|
-
y + height,
|
|
363
|
-
);
|
|
364
|
-
ctx.lineTo(x + borderRadius, y + height);
|
|
365
|
-
ctx.quadraticCurveTo(x, y + height, x, y + height - borderRadius);
|
|
366
|
-
ctx.lineTo(x, y + borderRadius);
|
|
367
|
-
ctx.quadraticCurveTo(x, y, x + borderRadius, y);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
ctx.closePath();
|
|
371
|
-
ctx.clip();
|
|
372
|
-
ctx.drawImage(image, x, y, width, height);
|
|
373
|
-
ctx.restore();
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Applies border radius to the canvas context for objects.
|
|
381
|
-
* @param ctx The canvas rendering context.
|
|
382
|
-
* @param x The x-coordinate of the object.
|
|
383
|
-
* @param y The y-coordinate of the object.
|
|
384
|
-
* @param width The width of the object.
|
|
385
|
-
* @param height The height of the object.
|
|
386
|
-
* @param borderRadius The border radius value.
|
|
387
|
-
* @param borderPosition The border radius position to be applied on.
|
|
388
|
-
*/
|
|
389
|
-
export function objectRadius(ctx: any, x: any, y: any, width: number, height: number, borderRadius: any = 0.1, borderPosition: string = 'all'): void {
|
|
390
|
-
ctx.save();
|
|
391
|
-
if (borderRadius === "circular") {
|
|
392
|
-
const circleRadius = Math.min(width, height) / 2;
|
|
393
|
-
ctx.beginPath();
|
|
394
|
-
ctx.arc(x + width / 2, y + height / 2, circleRadius, 0, 2 * Math.PI);
|
|
395
|
-
ctx.closePath();
|
|
396
|
-
} else if (borderRadius) {
|
|
397
|
-
ctx.beginPath();
|
|
398
|
-
ctx.moveTo(x + borderRadius, y);
|
|
399
|
-
ctx.lineTo(x + width - borderRadius, y);
|
|
400
|
-
ctx.quadraticCurveTo(x + width, y, x + width, y + borderRadius);
|
|
401
|
-
ctx.lineTo(x + width, y + height - borderRadius);
|
|
402
|
-
ctx.quadraticCurveTo(
|
|
403
|
-
x + width,
|
|
404
|
-
y + height,
|
|
405
|
-
x + width - borderRadius,
|
|
406
|
-
y + height,
|
|
407
|
-
);
|
|
408
|
-
ctx.lineTo(x + borderRadius, y + height);
|
|
409
|
-
ctx.quadraticCurveTo(x, y + height, x, y + height - borderRadius);
|
|
410
|
-
ctx.lineTo(x, y + borderRadius);
|
|
411
|
-
ctx.quadraticCurveTo(x, y, x + borderRadius, y);
|
|
412
|
-
ctx.closePath();
|
|
413
|
-
} else {
|
|
414
|
-
ctx.fillRect(x, y, width, height);
|
|
415
|
-
}
|
|
416
|
-
ctx.restore();
|
|
417
|
-
}
|
|
418
|
-
|
|
@@ -1,26 +0,0 @@
|
|
|
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 function radiusBorder(ctx: any, x: number = 0, y: number = 0, width: number, height: number, radius: number = 0): void {
|
|
10
|
-
const minDimension = Math.min(width, height);
|
|
11
|
-
const maxRadius = minDimension / 2;
|
|
12
|
-
const clipRadius = Math.min(radius, maxRadius);
|
|
13
|
-
ctx.save();
|
|
14
|
-
ctx.beginPath();
|
|
15
|
-
ctx.moveTo(x + clipRadius, y);
|
|
16
|
-
ctx.lineTo(x + width - clipRadius, y);
|
|
17
|
-
ctx.quadraticCurveTo(x + width, y, x + width, y + clipRadius);
|
|
18
|
-
ctx.lineTo(x + width, y + height - clipRadius);
|
|
19
|
-
ctx.quadraticCurveTo(x + width, y + height, x + width - clipRadius, y + height);
|
|
20
|
-
ctx.lineTo(x + clipRadius, y + height);
|
|
21
|
-
ctx.quadraticCurveTo(x, y + height, x, y + height - clipRadius);
|
|
22
|
-
ctx.lineTo(x, y + clipRadius);
|
|
23
|
-
ctx.quadraticCurveTo(x, y, x + clipRadius, y);
|
|
24
|
-
ctx.closePath();
|
|
25
|
-
ctx.clip();
|
|
26
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|