@meonode/canvas 1.0.0-beta.4 → 1.0.0-beta.5
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/canvas/canvas.helper.d.ts +9 -11
- package/dist/cjs/canvas/canvas.helper.d.ts.map +1 -1
- package/dist/cjs/canvas/canvas.helper.js +39 -47
- package/dist/cjs/canvas/canvas.helper.js.map +1 -1
- package/dist/cjs/canvas/canvas.type.d.ts +1 -1
- package/dist/cjs/canvas/canvas.type.d.ts.map +1 -1
- package/dist/cjs/canvas/grid.canvas.util.d.ts +4 -4
- package/dist/cjs/canvas/grid.canvas.util.d.ts.map +1 -1
- package/dist/cjs/canvas/grid.canvas.util.js +21 -4
- package/dist/cjs/canvas/grid.canvas.util.js.map +1 -1
- package/dist/cjs/canvas/image.canvas.util.d.ts +0 -1
- package/dist/cjs/canvas/image.canvas.util.d.ts.map +1 -1
- package/dist/cjs/canvas/image.canvas.util.js +72 -72
- package/dist/cjs/canvas/image.canvas.util.js.map +1 -1
- package/dist/cjs/canvas/layout.canvas.util.d.ts +16 -17
- package/dist/cjs/canvas/layout.canvas.util.d.ts.map +1 -1
- package/dist/cjs/canvas/layout.canvas.util.js +17 -24
- package/dist/cjs/canvas/layout.canvas.util.js.map +1 -1
- package/dist/cjs/canvas/root.canvas.util.d.ts +4 -2
- package/dist/cjs/canvas/root.canvas.util.d.ts.map +1 -1
- package/dist/cjs/canvas/root.canvas.util.js +7 -3
- package/dist/cjs/canvas/root.canvas.util.js.map +1 -1
- package/dist/cjs/canvas/text.canvas.util.d.ts +20 -27
- package/dist/cjs/canvas/text.canvas.util.d.ts.map +1 -1
- package/dist/cjs/canvas/text.canvas.util.js +27 -45
- package/dist/cjs/canvas/text.canvas.util.js.map +1 -1
- package/dist/esm/canvas/canvas.helper.d.ts +9 -11
- package/dist/esm/canvas/canvas.helper.d.ts.map +1 -1
- package/dist/esm/canvas/canvas.helper.js +39 -47
- package/dist/esm/canvas/canvas.type.d.ts +1 -1
- package/dist/esm/canvas/canvas.type.d.ts.map +1 -1
- package/dist/esm/canvas/grid.canvas.util.d.ts +4 -4
- package/dist/esm/canvas/grid.canvas.util.d.ts.map +1 -1
- package/dist/esm/canvas/grid.canvas.util.js +21 -4
- package/dist/esm/canvas/image.canvas.util.d.ts +0 -1
- package/dist/esm/canvas/image.canvas.util.d.ts.map +1 -1
- package/dist/esm/canvas/image.canvas.util.js +72 -72
- package/dist/esm/canvas/layout.canvas.util.d.ts +16 -17
- package/dist/esm/canvas/layout.canvas.util.d.ts.map +1 -1
- package/dist/esm/canvas/layout.canvas.util.js +17 -24
- package/dist/esm/canvas/root.canvas.util.d.ts +4 -2
- package/dist/esm/canvas/root.canvas.util.d.ts.map +1 -1
- package/dist/esm/canvas/root.canvas.util.js +7 -3
- package/dist/esm/canvas/text.canvas.util.d.ts +20 -27
- package/dist/esm/canvas/text.canvas.util.d.ts.map +1 -1
- package/dist/esm/canvas/text.canvas.util.js +27 -45
- package/package.json +5 -9
|
@@ -21,13 +21,12 @@ export declare const drawBorders: ({ ctx, node, x, y, width, height, radii, bord
|
|
|
21
21
|
* Draws an optimized rounded rectangle path on the canvas context.
|
|
22
22
|
* Automatically clamps radius values to prevent visual artifacts based on box dimensions.
|
|
23
23
|
* Uses arc-based rendering for crisp corners and consistent border appearance.
|
|
24
|
-
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @param radii - Corner radius values for each corner. Values are clamped to box constraints.
|
|
24
|
+
* @param ctx The canvas 2D rendering context to draw on
|
|
25
|
+
* @param x Left position of the rectangle
|
|
26
|
+
* @param y Top position of the rectangle
|
|
27
|
+
* @param width Width of the rectangle
|
|
28
|
+
* @param height Height of the rectangle
|
|
29
|
+
* @param radii Corner radius values for each corner. Values are clamped to box constraints.
|
|
31
30
|
*/
|
|
32
31
|
export declare const drawRoundedRectPath: (ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radii: {
|
|
33
32
|
TopLeft: number;
|
|
@@ -37,7 +36,7 @@ export declare const drawRoundedRectPath: (ctx: CanvasRenderingContext2D, x: num
|
|
|
37
36
|
}) => void;
|
|
38
37
|
/**
|
|
39
38
|
* Calculates border radius values from props
|
|
40
|
-
* @param radiusProp
|
|
39
|
+
* @param radiusProp Border radius property value
|
|
41
40
|
* @returns Calculated border radii for all corners
|
|
42
41
|
*/
|
|
43
42
|
export declare const parseBorderRadius: (radiusProp: BoxProps["borderRadius"]) => {
|
|
@@ -48,9 +47,8 @@ export declare const parseBorderRadius: (radiusProp: BoxProps["borderRadius"]) =
|
|
|
48
47
|
};
|
|
49
48
|
/**
|
|
50
49
|
* Parses a percentage value or a number, returning the calculated value based on the base.
|
|
51
|
-
*
|
|
52
|
-
* @param
|
|
53
|
-
* @param base - The base value to calculate the percentage from.
|
|
50
|
+
* @param value The value to parse, can be a number, a percentage string, or undefined.
|
|
51
|
+
* @param base The base value to calculate the percentage from.
|
|
54
52
|
* @returns The parsed number, or 0 if the value is not a number or a valid percentage.
|
|
55
53
|
*/
|
|
56
54
|
export declare function parsePercentage(value: number | string | undefined, base: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.helper.d.ts","sourceRoot":"","sources":["../../../src/canvas/canvas.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AAExC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD,eAAO,MAAM,WAAW,GAAI,sEAUzB;IACD,GAAG,EAAE,wBAAwB,CAAA;IAC7B,IAAI,EAAE,SAAS,CAAC,IAAI,CAAA;IACpB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EA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AAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,SAoCtF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,QAAQ,CAAC,cAAc,CAAC,KACnC;IACD,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CAYnB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQxF"}
|
|
@@ -53,14 +53,13 @@ const drawBorders = ({ ctx, node, x, y, width, height, radii, borderColor, borde
|
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
55
|
* Draws a rounded corner arc for the border.
|
|
56
|
-
*
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @param
|
|
61
|
-
* @param
|
|
62
|
-
* @param
|
|
63
|
-
* @param border2 - The border width leading out of the corner.
|
|
56
|
+
* @param cx The x-coordinate of the visual center of the corner curve.
|
|
57
|
+
* @param cy The y-coordinate of the visual center of the corner curve.
|
|
58
|
+
* @param radius The visual radius of the corner curve.
|
|
59
|
+
* @param startAngle The starting angle of the arc in radians.
|
|
60
|
+
* @param endAngle The ending angle of the arc in radians.
|
|
61
|
+
* @param border1 The border width leading into the corner.
|
|
62
|
+
* @param border2 The border width leading out of the corner.
|
|
64
63
|
*/
|
|
65
64
|
const drawCornerArc = (cx, cy, radius, startAngle, endAngle, border1, border2) => {
|
|
66
65
|
if (radius <= 0)
|
|
@@ -96,12 +95,11 @@ const drawBorders = ({ ctx, node, x, y, width, height, radii, borderColor, borde
|
|
|
96
95
|
};
|
|
97
96
|
/**
|
|
98
97
|
* Draws a straight line segment for the border.
|
|
99
|
-
*
|
|
100
|
-
* @param
|
|
101
|
-
* @param
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @param borderWidth - The width of the border.
|
|
98
|
+
* @param x1 The x-coordinate of the starting point.
|
|
99
|
+
* @param y1 The y-coordinate of the starting point.
|
|
100
|
+
* @param x2 The x-coordinate of the ending point.
|
|
101
|
+
* @param y2 The y-coordinate of the ending point.
|
|
102
|
+
* @param borderWidth The width of the border.
|
|
105
103
|
*/
|
|
106
104
|
const drawLine = (x1, y1, x2, y2, borderWidth) => {
|
|
107
105
|
if (borderWidth <= 0)
|
|
@@ -129,34 +127,34 @@ const drawBorders = ({ ctx, node, x, y, width, height, radii, borderColor, borde
|
|
|
129
127
|
// For content-box, coordinates are offset *outwards* from x, y, width, height
|
|
130
128
|
if (boxSizing === common_const.Style.BoxSizing.ContentBox) {
|
|
131
129
|
// Top line segment
|
|
132
|
-
drawLine(x + rTL, y - halfBt, x + width - rTR, y - halfBt, borderTop);
|
|
130
|
+
void drawLine(x + rTL, y - halfBt, x + width - rTR, y - halfBt, borderTop);
|
|
133
131
|
// Right line segment
|
|
134
|
-
drawLine(x + width + halfBr, y + rTR, x + width + halfBr, y + height - rBR, borderRight);
|
|
132
|
+
void drawLine(x + width + halfBr, y + rTR, x + width + halfBr, y + height - rBR, borderRight);
|
|
135
133
|
// Bottom line segment
|
|
136
|
-
drawLine(x + width - rBR, y + height + halfBb, x + rBL, y + height + halfBb, borderBottom);
|
|
134
|
+
void drawLine(x + width - rBR, y + height + halfBb, x + rBL, y + height + halfBb, borderBottom);
|
|
137
135
|
// Left line segment
|
|
138
|
-
drawLine(x - halfBl, y + height - rBL, x - halfBl, y + rTL, borderLeft);
|
|
139
|
-
drawCornerArc(x + rTL, y + rTL, rTL, Math.PI, 1.5 * Math.PI, borderLeft, borderTop);
|
|
140
|
-
drawCornerArc(x + width - rTR, y + rTR, rTR, 1.5 * Math.PI, 2 * Math.PI, borderTop, borderRight);
|
|
141
|
-
drawCornerArc(x + width - rBR, y + height - rBR, rBR, 0, 0.5 * Math.PI, borderRight, borderBottom);
|
|
142
|
-
drawCornerArc(x + rBL, y + height - rBL, rBL, 0.5 * Math.PI, Math.PI, borderBottom, borderLeft);
|
|
136
|
+
void drawLine(x - halfBl, y + height - rBL, x - halfBl, y + rTL, borderLeft);
|
|
137
|
+
void drawCornerArc(x + rTL, y + rTL, rTL, Math.PI, 1.5 * Math.PI, borderLeft, borderTop);
|
|
138
|
+
void drawCornerArc(x + width - rTR, y + rTR, rTR, 1.5 * Math.PI, 2 * Math.PI, borderTop, borderRight);
|
|
139
|
+
void drawCornerArc(x + width - rBR, y + height - rBR, rBR, 0, 0.5 * Math.PI, borderRight, borderBottom);
|
|
140
|
+
void drawCornerArc(x + rBL, y + height - rBL, rBL, 0.5 * Math.PI, Math.PI, borderBottom, borderLeft);
|
|
143
141
|
}
|
|
144
142
|
else {
|
|
145
143
|
// For border-box, coordinates are offset *inwards* from x, y, width, height
|
|
146
144
|
// Top line segment
|
|
147
|
-
drawLine(x + rTL, y + halfBt, x + width - rTR, y + halfBt, borderTop);
|
|
145
|
+
void drawLine(x + rTL, y + halfBt, x + width - rTR, y + halfBt, borderTop);
|
|
148
146
|
// Right line segment
|
|
149
|
-
drawLine(x + width - halfBr, y + rTR, x + width - halfBr, y + height - rBR, borderRight);
|
|
147
|
+
void drawLine(x + width - halfBr, y + rTR, x + width - halfBr, y + height - rBR, borderRight);
|
|
150
148
|
// Bottom line segment
|
|
151
|
-
drawLine(x + width - rBR, y + height - halfBb, x + rBL, y + height - halfBb, borderBottom);
|
|
149
|
+
void drawLine(x + width - rBR, y + height - halfBb, x + rBL, y + height - halfBb, borderBottom);
|
|
152
150
|
// Left line segment
|
|
153
|
-
drawLine(x + halfBl, y + height - rBL, x + halfBl, y + rTL, borderLeft);
|
|
151
|
+
void drawLine(x + halfBl, y + height - rBL, x + halfBl, y + rTL, borderLeft);
|
|
154
152
|
// Draw corner arcs (centers relative to layout box corners, adjusted for inward border)
|
|
155
153
|
// Pass visual radius (rTL, rTR etc.) to drawCornerArc
|
|
156
|
-
drawCornerArc(x + rTL, y + rTL, rTL, Math.PI, 1.5 * Math.PI, borderLeft, borderTop); // Top-Left
|
|
157
|
-
drawCornerArc(x + width - rTR, y + rTR, rTR, 1.5 * Math.PI, 2 * Math.PI, borderTop, borderRight); // Top-Right
|
|
158
|
-
drawCornerArc(x + width - rBR, y + height - rBR, rBR, 0, 0.5 * Math.PI, borderRight, borderBottom); // Bottom-Right
|
|
159
|
-
drawCornerArc(x + rBL, y + height - rBL, rBL, 0.5 * Math.PI, Math.PI, borderBottom, borderLeft); // Bottom-Left
|
|
154
|
+
void drawCornerArc(x + rTL, y + rTL, rTL, Math.PI, 1.5 * Math.PI, borderLeft, borderTop); // Top-Left
|
|
155
|
+
void drawCornerArc(x + width - rTR, y + rTR, rTR, 1.5 * Math.PI, 2 * Math.PI, borderTop, borderRight); // Top-Right
|
|
156
|
+
void drawCornerArc(x + width - rBR, y + height - rBR, rBR, 0, 0.5 * Math.PI, borderRight, borderBottom); // Bottom-Right
|
|
157
|
+
void drawCornerArc(x + rBL, y + height - rBL, rBL, 0.5 * Math.PI, Math.PI, borderBottom, borderLeft); // Bottom-Left
|
|
160
158
|
}
|
|
161
159
|
}
|
|
162
160
|
};
|
|
@@ -164,13 +162,12 @@ const drawBorders = ({ ctx, node, x, y, width, height, radii, borderColor, borde
|
|
|
164
162
|
* Draws an optimized rounded rectangle path on the canvas context.
|
|
165
163
|
* Automatically clamps radius values to prevent visual artifacts based on box dimensions.
|
|
166
164
|
* Uses arc-based rendering for crisp corners and consistent border appearance.
|
|
167
|
-
*
|
|
168
|
-
* @param
|
|
169
|
-
* @param
|
|
170
|
-
* @param
|
|
171
|
-
* @param
|
|
172
|
-
* @param
|
|
173
|
-
* @param radii - Corner radius values for each corner. Values are clamped to box constraints.
|
|
165
|
+
* @param ctx The canvas 2D rendering context to draw on
|
|
166
|
+
* @param x Left position of the rectangle
|
|
167
|
+
* @param y Top position of the rectangle
|
|
168
|
+
* @param width Width of the rectangle
|
|
169
|
+
* @param height Height of the rectangle
|
|
170
|
+
* @param radii Corner radius values for each corner. Values are clamped to box constraints.
|
|
174
171
|
*/
|
|
175
172
|
const drawRoundedRectPath = (ctx, x, y, width, height, radii) => {
|
|
176
173
|
if (width <= 0 || height <= 0) {
|
|
@@ -191,14 +188,10 @@ const drawRoundedRectPath = (ctx, x, y, width, height, radii) => {
|
|
|
191
188
|
clampedTR > 0 ? ctx.arc(x + width - clampedTR, y + clampedTR, clampedTR, 1.5 * Math.PI, 0) : ctx.lineTo(x + width, y);
|
|
192
189
|
// Draw right edge and bottom-right corner
|
|
193
190
|
ctx.lineTo(x + width, y + height - clampedBR);
|
|
194
|
-
clampedBR > 0
|
|
195
|
-
? ctx.arc(x + width - clampedBR, y + height - clampedBR, clampedBR, 0, 0.5 * Math.PI)
|
|
196
|
-
: ctx.lineTo(x + width, y + height);
|
|
191
|
+
clampedBR > 0 ? ctx.arc(x + width - clampedBR, y + height - clampedBR, clampedBR, 0, 0.5 * Math.PI) : ctx.lineTo(x + width, y + height);
|
|
197
192
|
// Draw bottom edge and bottom-left corner
|
|
198
193
|
ctx.lineTo(x + clampedBL, y + height);
|
|
199
|
-
clampedBL > 0
|
|
200
|
-
? ctx.arc(x + clampedBL, y + height - clampedBL, clampedBL, 0.5 * Math.PI, Math.PI)
|
|
201
|
-
: ctx.lineTo(x, y + height);
|
|
194
|
+
clampedBL > 0 ? ctx.arc(x + clampedBL, y + height - clampedBL, clampedBL, 0.5 * Math.PI, Math.PI) : ctx.lineTo(x, y + height);
|
|
202
195
|
// Draw left edge and top-left corner
|
|
203
196
|
ctx.lineTo(x, y + clampedTL);
|
|
204
197
|
clampedTL > 0 ? ctx.arc(x + clampedTL, y + clampedTL, clampedTL, Math.PI, 1.5 * Math.PI) : ctx.lineTo(x, y);
|
|
@@ -206,7 +199,7 @@ const drawRoundedRectPath = (ctx, x, y, width, height, radii) => {
|
|
|
206
199
|
};
|
|
207
200
|
/**
|
|
208
201
|
* Calculates border radius values from props
|
|
209
|
-
* @param radiusProp
|
|
202
|
+
* @param radiusProp Border radius property value
|
|
210
203
|
* @returns Calculated border radii for all corners
|
|
211
204
|
*/
|
|
212
205
|
const parseBorderRadius = (radiusProp) => {
|
|
@@ -224,9 +217,8 @@ const parseBorderRadius = (radiusProp) => {
|
|
|
224
217
|
};
|
|
225
218
|
/**
|
|
226
219
|
* Parses a percentage value or a number, returning the calculated value based on the base.
|
|
227
|
-
*
|
|
228
|
-
* @param
|
|
229
|
-
* @param base - The base value to calculate the percentage from.
|
|
220
|
+
* @param value The value to parse, can be a number, a percentage string, or undefined.
|
|
221
|
+
* @param base The base value to calculate the percentage from.
|
|
230
222
|
* @returns The parsed number, or 0 if the value is not a number or a valid percentage.
|
|
231
223
|
*/
|
|
232
224
|
function parsePercentage(value, base) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.helper.js","sources":["../../../../src/canvas/canvas.helper.ts"],"sourcesContent":["import type { CanvasRenderingContext2D } from 'skia-canvas'\nimport * as YogaTypes from 'yoga-layout'\nimport { Style } from '@/constant/common.const.js'\nimport type { BoxProps } from '@/canvas/canvas.type.js'\n\nexport const drawBorders = ({\n ctx,\n node,\n x,\n y,\n width,\n height,\n radii,\n borderColor,\n borderStyle,\n}: {\n ctx: CanvasRenderingContext2D\n node: YogaTypes.Node\n x: number\n y: number\n width: number\n height: number\n radii: {\n TopLeft: number\n TopRight: number\n BottomLeft: number\n BottomRight: number\n }\n borderColor: BoxProps['borderColor']\n borderStyle: BoxProps['borderStyle']\n}) => {\n const borderAll = node.getBorder(YogaTypes.Edge.All) || 0\n const borderTop = Math.max(0, node.getBorder(YogaTypes.Edge.Top) || borderAll)\n const borderRight = Math.max(0, node.getBorder(YogaTypes.Edge.Right) || borderAll)\n const borderBottom = Math.max(0, node.getBorder(YogaTypes.Edge.Bottom) || borderAll)\n const borderLeft = Math.max(0, node.getBorder(YogaTypes.Edge.Left) || borderAll)\n\n const hasBorder = borderTop > 0 || borderRight > 0 || borderBottom > 0 || borderLeft > 0\n const boxSizing = node.getBoxSizing()\n\n if (hasBorder && borderColor) {\n ctx.strokeStyle = borderColor\n ctx.lineCap = 'butt'\n ctx.lineJoin = 'miter' // Use miter for sharp corners unless rounded\n\n const setDash = (width: number) => {\n if (borderStyle === Style.Border.Dotted && width > 0) {\n // Dotted: tight spacing with round caps for circular dots\n ctx.lineCap = 'round'\n ctx.setLineDash([0, width * 2]) // 0-length dash with spacing creates dots with round caps\n } else if (borderStyle === Style.Border.Dashed && width > 0) {\n ctx.lineCap = 'butt'\n const dashLength = Math.max(2, width * 1.5)\n const gapLength = Math.max(1, width)\n ctx.setLineDash([dashLength, gapLength])\n } else {\n ctx.lineCap = 'butt'\n ctx.setLineDash([]) // Solid line\n }\n }\n\n /**\n * Draws a rounded corner arc for the border.\n *\n * @param cx - The x-coordinate of the visual center of the corner curve.\n * @param cy - The y-coordinate of the visual center of the corner curve.\n * @param radius - The visual radius of the corner curve.\n * @param startAngle - The starting angle of the arc in radians.\n * @param endAngle - The ending angle of the arc in radians.\n * @param border1 - The border width leading into the corner.\n * @param border2 - The border width leading out of the corner.\n */\n const drawCornerArc = (\n cx: number,\n cy: number,\n radius: number,\n startAngle: number,\n endAngle: number,\n border1: number,\n border2: number,\n ) => {\n if (radius <= 0) return\n\n const cornerWidth = Math.max(border1, border2)\n if (cornerWidth <= 0) return\n\n let centerlineArcRadius: number\n\n if (boxSizing === Style.BoxSizing.ContentBox) {\n // For content-box, the border is outside the box, so the centerline radius is the visual radius plus half the border width.\n centerlineArcRadius = radius + cornerWidth / 2\n } else {\n // For border-box, the border is inside the box, so the centerline radius is the visual radius minus half the border width.\n // Ensure the centerline radius is not negative.\n centerlineArcRadius = Math.max(0, radius - cornerWidth / 2)\n\n if (centerlineArcRadius <= 0 && radius > 0) {\n // Draw cap for border-box when border is thicker than radius allows for centerline arc\n ctx.fillStyle = borderColor! // Use border color for fill\n ctx.beginPath()\n // Cap is centered on the visual corner center with the visual radius\n ctx.arc(cx, cy, radius, 0, 2 * Math.PI)\n ctx.fill()\n return // Cap drawn, skip arc stroke\n }\n }\n // Draw the normal arc stroke using the calculated centerline radius\n ctx.beginPath()\n ctx.lineWidth = cornerWidth\n setDash(cornerWidth)\n ctx.arc(cx, cy, centerlineArcRadius, startAngle, endAngle)\n ctx.stroke()\n }\n\n /**\n * Draws a straight line segment for the border.\n *\n * @param x1 - The x-coordinate of the starting point.\n * @param y1 - The y-coordinate of the starting point.\n * @param x2 - The x-coordinate of the ending point.\n * @param y2 - The y-coordinate of the ending point.\n * @param borderWidth - The width of the border.\n */\n const drawLine = (x1: number, y1: number, x2: number, y2: number, borderWidth: number) => {\n if (borderWidth <= 0) return\n ctx.beginPath()\n ctx.lineWidth = borderWidth\n setDash(borderWidth)\n ctx.moveTo(x1, y1)\n ctx.lineTo(x2, y2)\n ctx.stroke()\n }\n\n // Calculate half-border widths\n const halfBt = borderTop / 2\n const halfBr = borderRight / 2\n const halfBb = borderBottom / 2\n const halfBl = borderLeft / 2\n\n // Calculate effective visual radii, clamped to half dimensions of the *layout box*\n const maxRadiusX = width / 2 // This matches CSS behavior where radius is relative to the box it's applied to.\n const maxRadiusY = height / 2\n const rTL = Math.max(0, Math.min(radii.TopLeft, maxRadiusX, maxRadiusY))\n const rTR = Math.max(0, Math.min(radii.TopRight, maxRadiusX, maxRadiusY))\n const rBR = Math.max(0, Math.min(radii.BottomRight, maxRadiusX, maxRadiusY))\n const rBL = Math.max(0, Math.min(radii.BottomLeft, maxRadiusX, maxRadiusY))\n\n // --- Draw border segments based on boxSizing ---\n // For content-box, coordinates are offset *outwards* from x, y, width, height\n if (boxSizing === Style.BoxSizing.ContentBox) {\n // Top line segment\n drawLine(x + rTL, y - halfBt, x + width - rTR, y - halfBt, borderTop)\n // Right line segment\n drawLine(x + width + halfBr, y + rTR, x + width + halfBr, y + height - rBR, borderRight)\n // Bottom line segment\n drawLine(x + width - rBR, y + height + halfBb, x + rBL, y + height + halfBb, borderBottom)\n // Left line segment\n drawLine(x - halfBl, y + height - rBL, x - halfBl, y + rTL, borderLeft)\n\n drawCornerArc(x + rTL, y + rTL, rTL, Math.PI, 1.5 * Math.PI, borderLeft, borderTop)\n drawCornerArc(x + width - rTR, y + rTR, rTR, 1.5 * Math.PI, 2 * Math.PI, borderTop, borderRight)\n drawCornerArc(x + width - rBR, y + height - rBR, rBR, 0, 0.5 * Math.PI, borderRight, borderBottom)\n drawCornerArc(x + rBL, y + height - rBL, rBL, 0.5 * Math.PI, Math.PI, borderBottom, borderLeft)\n } else {\n // For border-box, coordinates are offset *inwards* from x, y, width, height\n // Top line segment\n drawLine(x + rTL, y + halfBt, x + width - rTR, y + halfBt, borderTop)\n // Right line segment\n drawLine(x + width - halfBr, y + rTR, x + width - halfBr, y + height - rBR, borderRight)\n // Bottom line segment\n drawLine(x + width - rBR, y + height - halfBb, x + rBL, y + height - halfBb, borderBottom)\n // Left line segment\n drawLine(x + halfBl, y + height - rBL, x + halfBl, y + rTL, borderLeft)\n\n // Draw corner arcs (centers relative to layout box corners, adjusted for inward border)\n // Pass visual radius (rTL, rTR etc.) to drawCornerArc\n drawCornerArc(x + rTL, y + rTL, rTL, Math.PI, 1.5 * Math.PI, borderLeft, borderTop) // Top-Left\n drawCornerArc(x + width - rTR, y + rTR, rTR, 1.5 * Math.PI, 2 * Math.PI, borderTop, borderRight) // Top-Right\n drawCornerArc(x + width - rBR, y + height - rBR, rBR, 0, 0.5 * Math.PI, borderRight, borderBottom) // Bottom-Right\n drawCornerArc(x + rBL, y + height - rBL, rBL, 0.5 * Math.PI, Math.PI, borderBottom, borderLeft) // Bottom-Left\n }\n }\n}\n\n/**\n * Draws an optimized rounded rectangle path on the canvas context.\n * Automatically clamps radius values to prevent visual artifacts based on box dimensions.\n * Uses arc-based rendering for crisp corners and consistent border appearance.\n *\n * @param ctx - The canvas 2D rendering context to draw on\n * @param x - Left position of the rectangle\n * @param y - Top position of the rectangle\n * @param width - Width of the rectangle\n * @param height - Height of the rectangle\n * @param radii - Corner radius values for each corner. Values are clamped to box constraints.\n */\nexport const drawRoundedRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n width: number,\n height: number,\n radii: { TopLeft: number; TopRight: number; BottomRight: number; BottomLeft: number },\n) => {\n if (width <= 0 || height <= 0) {\n ctx.beginPath()\n ctx.rect(x, y, width, height)\n return\n }\n\n ctx.beginPath()\n\n // Clamp radius values to prevent visual artifacts\n const maxRadius = Math.min(width / 2, height / 2)\n const clampedTL = Math.max(0, Math.min(radii.TopLeft, maxRadius))\n const clampedTR = Math.max(0, Math.min(radii.TopRight, maxRadius))\n const clampedBR = Math.max(0, Math.min(radii.BottomRight, maxRadius))\n const clampedBL = Math.max(0, Math.min(radii.BottomLeft, maxRadius))\n\n ctx.moveTo(x + clampedTL, y)\n\n // Draw top edge and top-right corner\n ctx.lineTo(x + width - clampedTR, y)\n clampedTR > 0 ? ctx.arc(x + width - clampedTR, y + clampedTR, clampedTR, 1.5 * Math.PI, 0) : ctx.lineTo(x + width, y)\n\n // Draw right edge and bottom-right corner\n ctx.lineTo(x + width, y + height - clampedBR)\n clampedBR > 0\n ? ctx.arc(x + width - clampedBR, y + height - clampedBR, clampedBR, 0, 0.5 * Math.PI)\n : ctx.lineTo(x + width, y + height)\n\n // Draw bottom edge and bottom-left corner\n ctx.lineTo(x + clampedBL, y + height)\n clampedBL > 0\n ? ctx.arc(x + clampedBL, y + height - clampedBL, clampedBL, 0.5 * Math.PI, Math.PI)\n : ctx.lineTo(x, y + height)\n\n // Draw left edge and top-left corner\n ctx.lineTo(x, y + clampedTL)\n clampedTL > 0 ? ctx.arc(x + clampedTL, y + clampedTL, clampedTL, Math.PI, 1.5 * Math.PI) : ctx.lineTo(x, y)\n\n ctx.closePath()\n}\n\n/**\n * Calculates border radius values from props\n * @param radiusProp - Border radius property value\n * @returns Calculated border radii for all corners\n */\nexport const parseBorderRadius = (\n radiusProp: BoxProps['borderRadius'],\n): {\n TopLeft: number\n TopRight: number\n BottomRight: number\n BottomLeft: number\n} => {\n const radii = { TopLeft: 0, TopRight: 0, BottomRight: 0, BottomLeft: 0 }\n if (typeof radiusProp === 'number') {\n radii.TopLeft = radii.TopRight = radii.BottomRight = radii.BottomLeft = Math.max(0, radiusProp)\n } else if (typeof radiusProp === 'object' && radiusProp !== null) {\n radii.TopLeft = Math.max(0, radiusProp.TopLeft ?? 0)\n radii.TopRight = Math.max(0, radiusProp.TopRight ?? 0)\n radii.BottomRight = Math.max(0, radiusProp.BottomRight ?? 0)\n radii.BottomLeft = Math.max(0, radiusProp.BottomLeft ?? 0)\n }\n return radii\n}\n\n/**\n * Parses a percentage value or a number, returning the calculated value based on the base.\n *\n * @param value - The value to parse, can be a number, a percentage string, or undefined.\n * @param base - The base value to calculate the percentage from.\n * @returns The parsed number, or 0 if the value is not a number or a valid percentage.\n */\nexport function parsePercentage(value: number | string | undefined, base: number): number {\n if (typeof value === 'number') {\n return value\n }\n if (typeof value === 'string' && value.endsWith('%')) {\n return base !== 0 ? (parseFloat(value) / 100) * base : 0\n }\n return 0\n}\n"],"names":["YogaTypes","Style"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKO,MAAM,WAAW,GAAG,CAAC,EAC1B,GAAG,EACH,IAAI,EACJ,CAAC,EACD,CAAC,EACD,KAAK,EACL,MAAM,EACN,KAAK,EACL,WAAW,EACX,WAAW,GAgBZ,KAAI;AACH,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAACA,oBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACzD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAACA,oBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;IAC9E,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAACA,oBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,I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AG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,UAAU,IAAI,CAAC,CAAC;IAC5D;AACA,IAAA,OAAO,KAAK;AACd;AAEA;;;;;;AAMG;AACG,SAAU,eAAe,CAAC,KAAkC,EAAE,IAAY,EAAA;AAC9E,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,KAAK;IACd;AACA,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACpD,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,IAAI,GAAG,CAAC;IAC1D;AACA,IAAA,OAAO,CAAC;AACV;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"canvas.helper.js","sources":["../../../../src/canvas/canvas.helper.ts"],"sourcesContent":["import type { CanvasRenderingContext2D } from 'skia-canvas'\nimport * as YogaTypes from 'yoga-layout'\nimport { Style } from '@/constant/common.const.js'\nimport type { BoxProps } from '@/canvas/canvas.type.js'\n\nexport const drawBorders = ({\n ctx,\n node,\n x,\n y,\n width,\n height,\n radii,\n borderColor,\n borderStyle,\n}: {\n ctx: CanvasRenderingContext2D\n node: YogaTypes.Node\n x: number\n y: number\n width: number\n height: number\n radii: {\n TopLeft: number\n TopRight: number\n BottomLeft: number\n BottomRight: number\n }\n borderColor: BoxProps['borderColor']\n borderStyle: BoxProps['borderStyle']\n}) => {\n const borderAll = node.getBorder(YogaTypes.Edge.All) || 0\n const borderTop = Math.max(0, node.getBorder(YogaTypes.Edge.Top) || borderAll)\n const borderRight = Math.max(0, node.getBorder(YogaTypes.Edge.Right) || borderAll)\n const borderBottom = Math.max(0, node.getBorder(YogaTypes.Edge.Bottom) || borderAll)\n const borderLeft = Math.max(0, node.getBorder(YogaTypes.Edge.Left) || borderAll)\n\n const hasBorder = borderTop > 0 || borderRight > 0 || borderBottom > 0 || borderLeft > 0\n const boxSizing = node.getBoxSizing()\n\n if (hasBorder && borderColor) {\n ctx.strokeStyle = borderColor\n ctx.lineCap = 'butt'\n ctx.lineJoin = 'miter' // Use miter for sharp corners unless rounded\n\n const setDash = (width: number) => {\n if (borderStyle === Style.Border.Dotted && width > 0) {\n // Dotted: tight spacing with round caps for circular dots\n ctx.lineCap = 'round'\n ctx.setLineDash([0, width * 2]) // 0-length dash with spacing creates dots with round caps\n } else if (borderStyle === Style.Border.Dashed && width > 0) {\n ctx.lineCap = 'butt'\n const dashLength = Math.max(2, width * 1.5)\n const gapLength = Math.max(1, width)\n ctx.setLineDash([dashLength, gapLength])\n } else {\n ctx.lineCap = 'butt'\n ctx.setLineDash([]) // Solid line\n }\n }\n\n /**\n * Draws a rounded corner arc for the border.\n * @param cx The x-coordinate of the visual center of the corner curve.\n * @param cy The y-coordinate of the visual center of the corner curve.\n * @param radius The visual radius of the corner curve.\n * @param startAngle The starting angle of the arc in radians.\n * @param endAngle The ending angle of the arc in radians.\n * @param border1 The border width leading into the corner.\n * @param border2 The border width leading out of the corner.\n */\n const drawCornerArc = (cx: number, cy: number, radius: number, startAngle: number, endAngle: number, border1: number, border2: number) => {\n if (radius <= 0) return\n\n const cornerWidth = Math.max(border1, border2)\n if (cornerWidth <= 0) return\n\n let centerlineArcRadius: number\n\n if (boxSizing === Style.BoxSizing.ContentBox) {\n // For content-box, the border is outside the box, so the centerline radius is the visual radius plus half the border width.\n centerlineArcRadius = radius + cornerWidth / 2\n } else {\n // For border-box, the border is inside the box, so the centerline radius is the visual radius minus half the border width.\n // Ensure the centerline radius is not negative.\n centerlineArcRadius = Math.max(0, radius - cornerWidth / 2)\n\n if (centerlineArcRadius <= 0 && radius > 0) {\n // Draw cap for border-box when border is thicker than radius allows for centerline arc\n ctx.fillStyle = borderColor! // Use border color for fill\n ctx.beginPath()\n // Cap is centered on the visual corner center with the visual radius\n ctx.arc(cx, cy, radius, 0, 2 * Math.PI)\n ctx.fill()\n return // Cap drawn, skip arc stroke\n }\n }\n // Draw the normal arc stroke using the calculated centerline radius\n ctx.beginPath()\n ctx.lineWidth = cornerWidth\n setDash(cornerWidth)\n ctx.arc(cx, cy, centerlineArcRadius, startAngle, endAngle)\n ctx.stroke()\n }\n\n /**\n * Draws a straight line segment for the border.\n * @param x1 The x-coordinate of the starting point.\n * @param y1 The y-coordinate of the starting point.\n * @param x2 The x-coordinate of the ending point.\n * @param y2 The y-coordinate of the ending point.\n * @param borderWidth The width of the border.\n */\n const drawLine = (x1: number, y1: number, x2: number, y2: number, borderWidth: number) => {\n if (borderWidth <= 0) return\n ctx.beginPath()\n ctx.lineWidth = borderWidth\n setDash(borderWidth)\n ctx.moveTo(x1, y1)\n ctx.lineTo(x2, y2)\n ctx.stroke()\n }\n\n // Calculate half-border widths\n const halfBt = borderTop / 2\n const halfBr = borderRight / 2\n const halfBb = borderBottom / 2\n const halfBl = borderLeft / 2\n\n // Calculate effective visual radii, clamped to half dimensions of the *layout box*\n const maxRadiusX = width / 2 // This matches CSS behavior where radius is relative to the box it's applied to.\n const maxRadiusY = height / 2\n const rTL = Math.max(0, Math.min(radii.TopLeft, maxRadiusX, maxRadiusY))\n const rTR = Math.max(0, Math.min(radii.TopRight, maxRadiusX, maxRadiusY))\n const rBR = Math.max(0, Math.min(radii.BottomRight, maxRadiusX, maxRadiusY))\n const rBL = Math.max(0, Math.min(radii.BottomLeft, maxRadiusX, maxRadiusY))\n\n // --- Draw border segments based on boxSizing ---\n // For content-box, coordinates are offset *outwards* from x, y, width, height\n if (boxSizing === Style.BoxSizing.ContentBox) {\n // Top line segment\n void drawLine(x + rTL, y - halfBt, x + width - rTR, y - halfBt, borderTop)\n // Right line segment\n void drawLine(x + width + halfBr, y + rTR, x + width + halfBr, y + height - rBR, borderRight)\n // Bottom line segment\n void drawLine(x + width - rBR, y + height + halfBb, x + rBL, y + height + halfBb, borderBottom)\n // Left line segment\n void drawLine(x - halfBl, y + height - rBL, x - halfBl, y + rTL, borderLeft)\n\n void drawCornerArc(x + rTL, y + rTL, rTL, Math.PI, 1.5 * Math.PI, borderLeft, borderTop)\n void drawCornerArc(x + width - rTR, y + rTR, rTR, 1.5 * Math.PI, 2 * Math.PI, borderTop, borderRight)\n void drawCornerArc(x + width - rBR, y + height - rBR, rBR, 0, 0.5 * Math.PI, borderRight, borderBottom)\n void drawCornerArc(x + rBL, y + height - rBL, rBL, 0.5 * Math.PI, Math.PI, borderBottom, borderLeft)\n } else {\n // For border-box, coordinates are offset *inwards* from x, y, width, height\n // Top line segment\n void drawLine(x + rTL, y + halfBt, x + width - rTR, y + halfBt, borderTop)\n // Right line segment\n void drawLine(x + width - halfBr, y + rTR, x + width - halfBr, y + height - rBR, borderRight)\n // Bottom line segment\n void drawLine(x + width - rBR, y + height - halfBb, x + rBL, y + height - halfBb, borderBottom)\n // Left line segment\n void drawLine(x + halfBl, y + height - rBL, x + halfBl, y + rTL, borderLeft)\n\n // Draw corner arcs (centers relative to layout box corners, adjusted for inward border)\n // Pass visual radius (rTL, rTR etc.) to drawCornerArc\n void drawCornerArc(x + rTL, y + rTL, rTL, Math.PI, 1.5 * Math.PI, borderLeft, borderTop) // Top-Left\n void drawCornerArc(x + width - rTR, y + rTR, rTR, 1.5 * Math.PI, 2 * Math.PI, borderTop, borderRight) // Top-Right\n void drawCornerArc(x + width - rBR, y + height - rBR, rBR, 0, 0.5 * Math.PI, borderRight, borderBottom) // Bottom-Right\n void drawCornerArc(x + rBL, y + height - rBL, rBL, 0.5 * Math.PI, Math.PI, borderBottom, borderLeft) // Bottom-Left\n }\n }\n}\n\n/**\n * Draws an optimized rounded rectangle path on the canvas context.\n * Automatically clamps radius values to prevent visual artifacts based on box dimensions.\n * Uses arc-based rendering for crisp corners and consistent border appearance.\n * @param ctx The canvas 2D rendering context to draw on\n * @param x Left position of the rectangle\n * @param y Top position of the rectangle\n * @param width Width of the rectangle\n * @param height Height of the rectangle\n * @param radii Corner radius values for each corner. Values are clamped to box constraints.\n */\nexport const drawRoundedRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n width: number,\n height: number,\n radii: { TopLeft: number; TopRight: number; BottomRight: number; BottomLeft: number },\n) => {\n if (width <= 0 || height <= 0) {\n ctx.beginPath()\n ctx.rect(x, y, width, height)\n return\n }\n\n ctx.beginPath()\n\n // Clamp radius values to prevent visual artifacts\n const maxRadius = Math.min(width / 2, height / 2)\n const clampedTL = Math.max(0, Math.min(radii.TopLeft, maxRadius))\n const clampedTR = Math.max(0, Math.min(radii.TopRight, maxRadius))\n const clampedBR = Math.max(0, Math.min(radii.BottomRight, maxRadius))\n const clampedBL = Math.max(0, Math.min(radii.BottomLeft, maxRadius))\n\n ctx.moveTo(x + clampedTL, y)\n\n // Draw top edge and top-right corner\n ctx.lineTo(x + width - clampedTR, y)\n clampedTR > 0 ? ctx.arc(x + width - clampedTR, y + clampedTR, clampedTR, 1.5 * Math.PI, 0) : ctx.lineTo(x + width, y)\n\n // Draw right edge and bottom-right corner\n ctx.lineTo(x + width, y + height - clampedBR)\n clampedBR > 0 ? ctx.arc(x + width - clampedBR, y + height - clampedBR, clampedBR, 0, 0.5 * Math.PI) : ctx.lineTo(x + width, y + height)\n\n // Draw bottom edge and bottom-left corner\n ctx.lineTo(x + clampedBL, y + height)\n clampedBL > 0 ? ctx.arc(x + clampedBL, y + height - clampedBL, clampedBL, 0.5 * Math.PI, Math.PI) : ctx.lineTo(x, y + height)\n\n // Draw left edge and top-left corner\n ctx.lineTo(x, y + clampedTL)\n clampedTL > 0 ? ctx.arc(x + clampedTL, y + clampedTL, clampedTL, Math.PI, 1.5 * Math.PI) : ctx.lineTo(x, y)\n\n ctx.closePath()\n}\n\n/**\n * Calculates border radius values from props\n * @param radiusProp Border radius property value\n * @returns Calculated border radii for all corners\n */\nexport const parseBorderRadius = (\n radiusProp: BoxProps['borderRadius'],\n): {\n TopLeft: number\n TopRight: number\n BottomRight: number\n BottomLeft: number\n} => {\n const radii = { TopLeft: 0, TopRight: 0, BottomRight: 0, BottomLeft: 0 }\n if (typeof radiusProp === 'number') {\n radii.TopLeft = radii.TopRight = radii.BottomRight = radii.BottomLeft = Math.max(0, radiusProp)\n } else if (typeof radiusProp === 'object' && radiusProp !== null) {\n radii.TopLeft = Math.max(0, radiusProp.TopLeft ?? 0)\n radii.TopRight = Math.max(0, radiusProp.TopRight ?? 0)\n radii.BottomRight = Math.max(0, radiusProp.BottomRight ?? 0)\n radii.BottomLeft = Math.max(0, radiusProp.BottomLeft ?? 0)\n }\n return radii\n}\n\n/**\n * Parses a percentage value or a number, returning the calculated value based on the base.\n * @param value The value to parse, can be a number, a percentage string, or undefined.\n * @param base The base value to calculate the percentage from.\n * @returns The parsed number, or 0 if the value is not a number or a valid percentage.\n */\nexport function parsePercentage(value: number | string | undefined, base: number): number {\n if (typeof value === 'number') {\n return value\n }\n if (typeof value === 'string' && value.endsWith('%')) {\n return base !== 0 ? (parseFloat(value) / 100) * base : 0\n }\n return 0\n}\n"],"names":["YogaTypes","Style"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKO,MAAM,WAAW,GAAG,CAAC,EAC1B,GAAG,EACH,IAAI,EACJ,CAAC,EACD,CAAC,EACD,KAAK,EACL,MAAM,EACN,KAAK,EACL,WAAW,EACX,WAAW,GAgBZ,KAAI;AACH,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAACA,oBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACzD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAACA,oBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;IAC9E,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAACA,oBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC;IAClF,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,I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IAAI,CAAC,CAAC;AAC5D,QAAA,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,UAAU,IAAI,CAAC,CAAC;IAC5D;AACA,IAAA,OAAO,KAAK;AACd;AAEA;;;;;AAKG;AACG,SAAU,eAAe,CAAC,KAAkC,EAAE,IAAY,EAAA;AAC9E,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,KAAK;IACd;AACA,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACpD,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,IAAI,GAAG,CAAC;IAC1D;AACA,IAAA,OAAO,CAAC;AACV;;;;;;;"}
|
|
@@ -650,7 +650,7 @@ export interface ImageProps extends Omit<BoxProps, 'children'> {
|
|
|
650
650
|
onLoad?: () => void;
|
|
651
651
|
/**
|
|
652
652
|
* Callback function that executes when the image fails to load.
|
|
653
|
-
* @param error
|
|
653
|
+
* @param error The error that occurred during loading.
|
|
654
654
|
*/
|
|
655
655
|
onError?: (error: Error) => void;
|
|
656
656
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.type.d.ts","sourceRoot":"","sources":["../../../src/canvas/canvas.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAA;AAEnD,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AEZ;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IAEnB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACjC"}
|
|
@@ -12,14 +12,14 @@ export declare class GridNode extends RowNode {
|
|
|
12
12
|
private readonly isVertical;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new grid layout node
|
|
15
|
-
* @param props
|
|
15
|
+
* @param props Grid configuration properties
|
|
16
16
|
*/
|
|
17
17
|
constructor(props: GridProps);
|
|
18
18
|
/**
|
|
19
19
|
* Appends a child node to this grid.
|
|
20
20
|
* Overridden primarily for documentation/clarity, functionality is inherited.
|
|
21
|
-
* @param child
|
|
22
|
-
* @param index
|
|
21
|
+
* @param child Child node to append
|
|
22
|
+
* @param index Index at which to insert the child
|
|
23
23
|
*/
|
|
24
24
|
protected appendChild(child: BoxNode, index: number): void;
|
|
25
25
|
/**
|
|
@@ -32,7 +32,7 @@ export declare class GridNode extends RowNode {
|
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Factory function to create a new GridNode instance.
|
|
35
|
-
* @param props
|
|
35
|
+
* @param props Grid configuration properties.
|
|
36
36
|
* @returns A new GridNode instance.
|
|
37
37
|
*/
|
|
38
38
|
export declare const Grid: (props: GridProps) => GridNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.canvas.util.d.ts","sourceRoot":"","sources":["../../../src/canvas/grid.canvas.util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grid.canvas.util.d.ts","sourceRoot":"","sources":["../../../src/canvas/grid.canvas.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAGjE;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,OAAO;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAuB;IACtD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IACnD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IAEpC;;;OAGG;gBACS,KAAK,EAAE,SAAS;IAqE5B;;;;;OAKG;cACgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM;IAI5D;;;;;OAKG;cACgB,+BAA+B;CAwLnD;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,SAAS,aAAwB,CAAA"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var layout_canvas_util = require('./layout.canvas.util.js');
|
|
4
4
|
var common_const = require('../constant/common.const.js');
|
|
5
5
|
|
|
6
|
+
// TODO: Add comprehensive unit tests for this file.
|
|
6
7
|
/**
|
|
7
8
|
* Grid layout node that arranges children in a configurable number of columns or rows.
|
|
8
9
|
* Uses Yoga's flexbox capabilities with wrapping and gap properties to simulate a grid.
|
|
@@ -15,7 +16,7 @@ class GridNode extends layout_canvas_util.RowNode {
|
|
|
15
16
|
isVertical; // True if the main axis is vertical (flexDirection: column or column-reverse)
|
|
16
17
|
/**
|
|
17
18
|
* Creates a new grid layout node
|
|
18
|
-
* @param props
|
|
19
|
+
* @param props Grid configuration properties
|
|
19
20
|
*/
|
|
20
21
|
constructor(props) {
|
|
21
22
|
const columns = Math.max(1, props.columns || 1);
|
|
@@ -60,17 +61,33 @@ class GridNode extends layout_canvas_util.RowNode {
|
|
|
60
61
|
...props,
|
|
61
62
|
// Explicitly remove the 'direction' prop passed to super, as it's handled by flexDirection
|
|
62
63
|
direction: undefined,
|
|
64
|
+
// Pass undefined for gap to prevent BoxNode from trying to parse it
|
|
65
|
+
gap: undefined,
|
|
63
66
|
});
|
|
64
67
|
this.columns = columns;
|
|
65
68
|
this.columnGapValue = columnGap;
|
|
66
69
|
this.rowGapValue = rowGap;
|
|
67
70
|
this.isVertical = isVertical;
|
|
71
|
+
// Explicitly set gaps on this.node after super() call
|
|
72
|
+
// These will be updated again in updateLayoutBasedOnComputedSize, but this ensures initial setup
|
|
73
|
+
if (typeof columnGap === 'number') {
|
|
74
|
+
this.node.setGap(common_const.Style.Gutter.Column, columnGap);
|
|
75
|
+
}
|
|
76
|
+
else if (typeof columnGap === 'string' && columnGap.endsWith('%')) {
|
|
77
|
+
this.node.setGapPercent(common_const.Style.Gutter.Column, parseFloat(columnGap));
|
|
78
|
+
}
|
|
79
|
+
if (typeof rowGap === 'number') {
|
|
80
|
+
this.node.setGap(common_const.Style.Gutter.Row, rowGap);
|
|
81
|
+
}
|
|
82
|
+
else if (typeof rowGap === 'string' && rowGap.endsWith('%')) {
|
|
83
|
+
this.node.setGapPercent(common_const.Style.Gutter.Row, parseFloat(rowGap));
|
|
84
|
+
}
|
|
68
85
|
}
|
|
69
86
|
/**
|
|
70
87
|
* Appends a child node to this grid.
|
|
71
88
|
* Overridden primarily for documentation/clarity, functionality is inherited.
|
|
72
|
-
* @param child
|
|
73
|
-
* @param index
|
|
89
|
+
* @param child Child node to append
|
|
90
|
+
* @param index Index at which to insert the child
|
|
74
91
|
*/
|
|
75
92
|
appendChild(child, index) {
|
|
76
93
|
super.appendChild(child, index);
|
|
@@ -253,7 +270,7 @@ class GridNode extends layout_canvas_util.RowNode {
|
|
|
253
270
|
}
|
|
254
271
|
/**
|
|
255
272
|
* Factory function to create a new GridNode instance.
|
|
256
|
-
* @param props
|
|
273
|
+
* @param props Grid configuration properties.
|
|
257
274
|
* @returns A new GridNode instance.
|
|
258
275
|
*/
|
|
259
276
|
const Grid = (props) => new GridNode(props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.canvas.util.js","sources":["../../../../src/canvas/grid.canvas.util.ts"],"sourcesContent":["import type { GridProps } from '@/canvas/canvas.type.js'\nimport { BoxNode, RowNode } from '@/canvas/layout.canvas.util.js'\nimport { Style, FlexDirection } from '@/constant/common.const.js'\n\n/**\n * Grid layout node that arranges children in a configurable number of columns or rows.\n * Uses Yoga's flexbox capabilities with wrapping and gap properties to simulate a grid.\n * @extends RowNode\n */\nexport class GridNode extends RowNode {\n private readonly columns: number\n private readonly columnGapValue: number | `${number}%`\n private readonly rowGapValue: number | `${number}%`\n private readonly isVertical: boolean // True if the main axis is vertical (flexDirection: column or column-reverse)\n\n /**\n * Creates a new grid layout node\n * @param props - Grid configuration properties\n */\n constructor(props: GridProps) {\n const columns = Math.max(1, props.columns || 1)\n const direction = props.direction || 'row' // Default to horizontal row\n const isVertical = direction === 'column' || direction === 'column-reverse'\n\n // Map direction string to Yoga FlexDirection\n let flexDirection: FlexDirection\n switch (direction) {\n case 'row':\n flexDirection = Style.FlexDirection.Row\n break\n case 'column':\n flexDirection = Style.FlexDirection.Column\n break\n case 'row-reverse':\n flexDirection = Style.FlexDirection.RowReverse\n break\n case 'column-reverse':\n flexDirection = Style.FlexDirection.ColumnReverse\n break\n default:\n console.warn(`[GridNode] Invalid direction \"${direction}\". Defaulting to \"row\".`)\n flexDirection = Style.FlexDirection.Row\n }\n\n // Determine the column and row gap values from props\n let columnGap: number | `${number}%` = 0\n let rowGap: number | `${number}%` = 0\n\n if (typeof props.gap === 'number' || (typeof props.gap === 'string' && props.gap.trim() !== '')) {\n // Single value applies to both row and column gaps\n columnGap = props.gap\n rowGap = props.gap\n } else if (props.gap && typeof props.gap === 'object') {\n // Object format: prioritize a specific direction (Column/Row), then All\n columnGap = props.gap.Column ?? props.gap.All ?? 0\n rowGap = props.gap.Row ?? props.gap.All ?? 0\n }\n\n super({\n name: 'Grid',\n flexWrap: Style.Wrap.Wrap, // Essential for grid behavior\n flexDirection,\n ...props,\n // Explicitly remove the 'direction' prop passed to super, as it's handled by flexDirection\n direction: undefined,\n })\n\n this.columns = columns\n this.columnGapValue = columnGap\n this.rowGapValue = rowGap\n this.isVertical = isVertical\n }\n\n /**\n * Appends a child node to this grid.\n * Overridden primarily for documentation/clarity, functionality is inherited.\n * @param child - Child node to append\n * @param index - Index at which to insert the child\n */\n protected override appendChild(child: BoxNode, index: number) {\n super.appendChild(child, index)\n }\n\n /**\n * Update layout calculations after the initial layout is computed.\n * This method calculates the appropriate flex-basis for children based on the\n * number of columns and gaps, respecting the container's padding,\n * and applies the gaps using Yoga's built-in properties.\n */\n protected override updateLayoutBasedOnComputedSize() {\n // Step 1: Early return if the grid is empty or invalid\n if (this.columns <= 0 || this.children.length === 0) {\n return\n }\n\n // Step 2: Get container dimensions and padding after the initial layout\n const width = this.node.getComputedWidth()\n const height = this.node.getComputedHeight()\n const paddingLeft = this.node.getComputedPadding(Style.Edge.Left)\n const paddingRight = this.node.getComputedPadding(Style.Edge.Right)\n const paddingTop = this.node.getComputedPadding(Style.Edge.Top)\n const paddingBottom = this.node.getComputedPadding(Style.Edge.Bottom)\n\n // Calculate content box dimensions\n const contentWidth = Math.max(0, width - paddingLeft - paddingRight)\n const contentHeight = Math.max(0, height - paddingTop - paddingBottom)\n\n // Step 3: Validate dimensions needed for calculations\n if (!this.isVertical && contentWidth <= 0 && width > 0) {\n console.warn(\n `[GridNode ${this.props.key} - Finalize] Grid content width (${contentWidth}) is zero or negative after accounting for padding (${paddingLeft}+${paddingRight}) on total width ${width}. Cannot calculate basis.`,\n )\n if (this.columns > 1) return\n }\n if (this.isVertical && contentHeight <= 0 && height > 0) {\n console.warn(\n `[GridNode ${this.props.key} - Finalize] Grid content height (${contentHeight}) is zero or negative after accounting for padding (${paddingTop}+${paddingBottom}) on total height ${height}. Cannot calculate basis.`,\n )\n if (this.columns > 1) return\n }\n\n // Step 4: Calculate Gap Values in Pixels\n let columnGapPixels = 0\n if (typeof this.columnGapValue === 'number') {\n columnGapPixels = this.columnGapValue\n } else if (typeof this.columnGapValue === 'string' && this.columnGapValue.trim().endsWith('%')) {\n try {\n const percent = parseFloat(this.columnGapValue)\n if (!isNaN(percent) && contentWidth > 0) {\n columnGapPixels = (percent / 100) * contentWidth\n } else if (isNaN(percent)) {\n console.warn(\n `[GridNode ${this.props.key}] Invalid percentage column gap format: \"${this.columnGapValue}\". Using 0px.`,\n )\n } else if (contentWidth <= 0) {\n console.warn(\n `[GridNode ${this.props.key}] Cannot calculate percentage column gap (${this.columnGapValue}) because content width is zero. Using 0px.`,\n )\n }\n } catch (e) {\n console.warn(\n `[GridNode ${this.props.key}] Error parsing percentage column gap: \"${this.columnGapValue}\". Using 0px.`,\n e,\n )\n }\n } else if (typeof this.columnGapValue === 'string' && this.columnGapValue.trim() !== '') {\n console.warn(\n `[GridNode ${this.props.key}] Unsupported string column gap format: \"${this.columnGapValue}\". Using 0px. Only numbers and percentages ('%') are supported.`,\n )\n }\n\n let rowGapPixels = 0\n if (typeof this.rowGapValue === 'number') {\n rowGapPixels = this.rowGapValue\n } else if (typeof this.rowGapValue === 'string' && this.rowGapValue.trim().endsWith('%')) {\n try {\n const percent = parseFloat(this.rowGapValue)\n if (!isNaN(percent) && contentHeight > 0) {\n rowGapPixels = (percent / 100) * contentHeight\n } else if (isNaN(percent)) {\n console.warn(\n `[GridNode ${this.props.key}] Invalid percentage row gap format: \"${this.rowGapValue}\". Using 0px.`,\n )\n } else if (contentHeight <= 0) {\n console.warn(\n `[GridNode ${this.props.key}] Cannot calculate percentage row gap (${this.rowGapValue}) because content height is zero. Using 0px.`,\n )\n }\n } catch (e) {\n console.warn(\n `[GridNode ${this.props.key}] Error parsing percentage row gap: \"${this.rowGapValue}\". Using 0px.`,\n e,\n )\n }\n } else if (typeof this.rowGapValue === 'string' && this.rowGapValue.trim() !== '') {\n console.warn(\n `[GridNode ${this.props.key}] Unsupported string row gap format: \"${this.rowGapValue}\". Using 0px. Only numbers and percentages ('%') are supported.`,\n )\n }\n\n // Ensure gaps are not negative\n columnGapPixels = Math.max(0, columnGapPixels)\n rowGapPixels = Math.max(0, rowGapPixels)\n\n // Step 5: Calculate flex-basis percentage for children\n const mainAxisGapPixels = this.isVertical ? rowGapPixels : columnGapPixels\n const mainAxisContentSize = this.isVertical ? contentHeight : contentWidth\n let childWidth = 0\n\n if (mainAxisContentSize > 0 && this.columns > 0) {\n // Total space taken up by gaps on the main axis\n const totalGapSpaceOnMainAxis = this.columns > 1 ? mainAxisGapPixels * (this.columns - 1) : 0\n\n // Calculate the space available *only* for the items themselves\n const availableSpaceOnMainAxis = Math.max(0, mainAxisContentSize - totalGapSpaceOnMainAxis)\n\n // Calculate the exact pixel of the total content size that each item should occupy\n const exactItemWidth = availableSpaceOnMainAxis / this.columns\n\n // Ensure it's not negative (shouldn't happen, but safety)\n childWidth = Math.max(0, exactItemWidth - 0.5) // Slightly reduce to avoid rounding issues\n } else if (this.columns === 1) {\n // If only one column, it takes up the full basis (gaps don't apply)\n childWidth = mainAxisContentSize\n }\n\n // Clamp basis percentage between 0 and 100 (mostly redundant after floor/max(0) but safe)\n childWidth = Math.max(0, Math.min(mainAxisContentSize, childWidth))\n\n // Step 6: Apply layout properties to children\n let childrenNeedRecalculation = false\n for (const child of this.children) {\n let childChanged = false\n const currentLayoutWidth = child.node.getWidth()\n const currentWidthValue = currentLayoutWidth.value\n const currentWidthUnit = currentLayoutWidth.unit\n\n let widthNeedsUpdate = false\n if (currentWidthUnit === Style.Unit.Point) {\n // If current width is in points, check if the value is significantly different\n if (Math.abs(currentWidthValue - childWidth) > 0.01) {\n widthNeedsUpdate = true\n }\n } else {\n // If current width is not in points (e.g., Auto, Percent, Undefined), it needs to be set to points\n widthNeedsUpdate = true\n }\n\n if (widthNeedsUpdate) {\n child.node.setWidth(childWidth)\n childChanged = true\n }\n\n // Ensure grow/shrink are set correctly for grid items\n if (child.node.getFlexGrow() !== 0) {\n child.node.setFlexGrow(0)\n childChanged = true\n }\n if (child.node.getFlexShrink() !== 1) {\n child.node.setFlexShrink(1) // Allow shrinking\n childChanged = true\n }\n\n // Remove margins that might interfere with gap property\n if (child.node.getMargin(Style.Edge.Bottom).unit !== Style.Unit.Undefined) {\n child.node.setMargin(Style.Edge.Bottom, undefined)\n childChanged = true\n }\n if (child.node.getMargin(Style.Edge.Right).unit !== Style.Unit.Undefined) {\n child.node.setMargin(Style.Edge.Right, undefined)\n childChanged = true\n }\n if (child.node.getMargin(Style.Edge.Top).unit !== Style.Unit.Undefined) {\n child.node.setMargin(Style.Edge.Top, undefined)\n childChanged = true\n }\n if (child.node.getMargin(Style.Edge.Left).unit !== Style.Unit.Undefined) {\n child.node.setMargin(Style.Edge.Left, undefined)\n childChanged = true\n }\n\n if (childChanged && !child.node.isDirty()) {\n child.node.markDirty()\n childrenNeedRecalculation = true\n }\n }\n\n // Step 7: Apply gaps using Yoga's built-in gap properties\n const currentColumnGap = this.node.getGap(Style.Gutter.Column).value\n const currentRowGap = this.node.getGap(Style.Gutter.Row).value\n let gapsChanged = false\n\n // Use a small tolerance for comparing gap pixels\n if (Math.abs(currentColumnGap - columnGapPixels) > 0.001) {\n this.node.setGap(Style.Gutter.Column, columnGapPixels)\n gapsChanged = true\n }\n if (Math.abs(currentRowGap - rowGapPixels) > 0.001) {\n this.node.setGap(Style.Gutter.Row, rowGapPixels)\n gapsChanged = true\n }\n\n // Step 8: Mark the grid node itself as dirty if gaps changed or children changed\n if ((gapsChanged || childrenNeedRecalculation) && !this.node.isDirty()) {\n this.node.markDirty()\n }\n }\n}\n\n/**\n * Factory function to create a new GridNode instance.\n * @param props - Grid configuration properties.\n * @returns A new GridNode instance.\n */\nexport const Grid = (props: GridProps) => new GridNode(props)\n"],"names":["RowNode","Style"],"mappings":";;;;;AAIA;;;;AAIG;AACG,MAAO,QAAS,SAAQA,0BAAO,CAAA;AAClB,IAAA,OAAO;AACP,IAAA,cAAc;AACd,IAAA,WAAW;IACX,UAAU,CAAS;AAEpC;;;AAGG;AACH,IAAA,WAAA,CAAY,KAAgB,EAAA;AAC1B,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,KAAK,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,QAAA,IAAI,CAAC,WAAW,IAAI,yBAAyB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;AACtE,YAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;QACvB;IACF;AACD;AAED;;;;AAIG;AACI,MAAM,IAAI,GAAG,CAAC,KAAgB,KAAK,IAAI,QAAQ,CAAC,KAAK;;;;;"}
|
|
1
|
+
{"version":3,"file":"grid.canvas.util.js","sources":["../../../../src/canvas/grid.canvas.util.ts"],"sourcesContent":["// TODO: Add comprehensive unit tests for this file.\n\nimport type { GridProps } from '@/canvas/canvas.type.js'\nimport { BoxNode, RowNode } from '@/canvas/layout.canvas.util.js'\nimport { Style, FlexDirection } from '@/constant/common.const.js'\n\n/**\n * Grid layout node that arranges children in a configurable number of columns or rows.\n * Uses Yoga's flexbox capabilities with wrapping and gap properties to simulate a grid.\n * @extends RowNode\n */\nexport class GridNode extends RowNode {\n private readonly columns: number\n private readonly columnGapValue: number | `${number}%`\n private readonly rowGapValue: number | `${number}%`\n private readonly isVertical: boolean // True if the main axis is vertical (flexDirection: column or column-reverse)\n\n /**\n * Creates a new grid layout node\n * @param props Grid configuration properties\n */\n constructor(props: GridProps) {\n const columns = Math.max(1, props.columns || 1)\n const direction = props.direction || 'row' // Default to horizontal row\n const isVertical = direction === 'column' || direction === 'column-reverse'\n\n // Map direction string to Yoga FlexDirection\n let flexDirection: FlexDirection\n switch (direction) {\n case 'row':\n flexDirection = Style.FlexDirection.Row\n break\n case 'column':\n flexDirection = Style.FlexDirection.Column\n break\n case 'row-reverse':\n flexDirection = Style.FlexDirection.RowReverse\n break\n case 'column-reverse':\n flexDirection = Style.FlexDirection.ColumnReverse\n break\n default:\n console.warn(`[GridNode] Invalid direction \"${direction}\". Defaulting to \"row\".`)\n flexDirection = Style.FlexDirection.Row\n }\n\n // Determine the column and row gap values from props\n let columnGap: number | `${number}%` = 0\n let rowGap: number | `${number}%` = 0\n\n if (typeof props.gap === 'number' || (typeof props.gap === 'string' && props.gap.trim() !== '')) {\n // Single value applies to both row and column gaps\n columnGap = props.gap\n rowGap = props.gap\n } else if (props.gap && typeof props.gap === 'object') {\n // Object format: prioritize a specific direction (Column/Row), then All\n columnGap = props.gap.Column ?? props.gap.All ?? 0\n rowGap = props.gap.Row ?? props.gap.All ?? 0\n }\n\n super({\n name: 'Grid',\n flexWrap: Style.Wrap.Wrap, // Essential for grid behavior\n flexDirection,\n ...props,\n // Explicitly remove the 'direction' prop passed to super, as it's handled by flexDirection\n direction: undefined,\n // Pass undefined for gap to prevent BoxNode from trying to parse it\n gap: undefined,\n })\n\n this.columns = columns\n this.columnGapValue = columnGap\n this.rowGapValue = rowGap\n this.isVertical = isVertical\n\n // Explicitly set gaps on this.node after super() call\n // These will be updated again in updateLayoutBasedOnComputedSize, but this ensures initial setup\n if (typeof columnGap === 'number') {\n this.node.setGap(Style.Gutter.Column, columnGap)\n } else if (typeof columnGap === 'string' && columnGap.endsWith('%')) {\n this.node.setGapPercent(Style.Gutter.Column, parseFloat(columnGap))\n }\n if (typeof rowGap === 'number') {\n this.node.setGap(Style.Gutter.Row, rowGap)\n } else if (typeof rowGap === 'string' && rowGap.endsWith('%')) {\n this.node.setGapPercent(Style.Gutter.Row, parseFloat(rowGap))\n }\n }\n\n /**\n * Appends a child node to this grid.\n * Overridden primarily for documentation/clarity, functionality is inherited.\n * @param child Child node to append\n * @param index Index at which to insert the child\n */\n protected override appendChild(child: BoxNode, index: number) {\n super.appendChild(child, index)\n }\n\n /**\n * Update layout calculations after the initial layout is computed.\n * This method calculates the appropriate flex-basis for children based on the\n * number of columns and gaps, respecting the container's padding,\n * and applies the gaps using Yoga's built-in properties.\n */\n protected override updateLayoutBasedOnComputedSize() {\n // Step 1: Early return if the grid is empty or invalid\n if (this.columns <= 0 || this.children.length === 0) {\n return\n }\n\n // Step 2: Get container dimensions and padding after the initial layout\n const width = this.node.getComputedWidth()\n const height = this.node.getComputedHeight()\n const paddingLeft = this.node.getComputedPadding(Style.Edge.Left)\n const paddingRight = this.node.getComputedPadding(Style.Edge.Right)\n const paddingTop = this.node.getComputedPadding(Style.Edge.Top)\n const paddingBottom = this.node.getComputedPadding(Style.Edge.Bottom)\n\n // Calculate content box dimensions\n const contentWidth = Math.max(0, width - paddingLeft - paddingRight)\n const contentHeight = Math.max(0, height - paddingTop - paddingBottom)\n\n // Step 3: Validate dimensions needed for calculations\n if (!this.isVertical && contentWidth <= 0 && width > 0) {\n console.warn(\n `[GridNode ${this.props.key} - Finalize] Grid content width (${contentWidth}) is zero or negative after accounting for padding (${paddingLeft}+${paddingRight}) on total width ${width}. Cannot calculate basis.`,\n )\n if (this.columns > 1) return\n }\n if (this.isVertical && contentHeight <= 0 && height > 0) {\n console.warn(\n `[GridNode ${this.props.key} - Finalize] Grid content height (${contentHeight}) is zero or negative after accounting for padding (${paddingTop}+${paddingBottom}) on total height ${height}. Cannot calculate basis.`,\n )\n if (this.columns > 1) return\n }\n\n // Step 4: Calculate Gap Values in Pixels\n let columnGapPixels = 0\n if (typeof this.columnGapValue === 'number') {\n columnGapPixels = this.columnGapValue\n } else if (typeof this.columnGapValue === 'string' && this.columnGapValue.trim().endsWith('%')) {\n try {\n const percent = parseFloat(this.columnGapValue)\n if (!isNaN(percent) && contentWidth > 0) {\n columnGapPixels = (percent / 100) * contentWidth\n } else if (isNaN(percent)) {\n console.warn(`[GridNode ${this.props.key}] Invalid percentage column gap format: \"${this.columnGapValue}\". Using 0px.`)\n } else if (contentWidth <= 0) {\n console.warn(`[GridNode ${this.props.key}] Cannot calculate percentage column gap (${this.columnGapValue}) because content width is zero. Using 0px.`)\n }\n } catch (e) {\n console.warn(`[GridNode ${this.props.key}] Error parsing percentage column gap: \"${this.columnGapValue}\". Using 0px.`, e)\n }\n } else if (typeof this.columnGapValue === 'string' && this.columnGapValue.trim() !== '') {\n console.warn(\n `[GridNode ${this.props.key}] Unsupported string column gap format: \"${this.columnGapValue}\". Using 0px. Only numbers and percentages ('%') are supported.`,\n )\n }\n\n let rowGapPixels = 0\n if (typeof this.rowGapValue === 'number') {\n rowGapPixels = this.rowGapValue\n } else if (typeof this.rowGapValue === 'string' && this.rowGapValue.trim().endsWith('%')) {\n try {\n const percent = parseFloat(this.rowGapValue)\n if (!isNaN(percent) && contentHeight > 0) {\n rowGapPixels = (percent / 100) * contentHeight\n } else if (isNaN(percent)) {\n console.warn(`[GridNode ${this.props.key}] Invalid percentage row gap format: \"${this.rowGapValue}\". Using 0px.`)\n } else if (contentHeight <= 0) {\n console.warn(`[GridNode ${this.props.key}] Cannot calculate percentage row gap (${this.rowGapValue}) because content height is zero. Using 0px.`)\n }\n } catch (e) {\n console.warn(`[GridNode ${this.props.key}] Error parsing percentage row gap: \"${this.rowGapValue}\". Using 0px.`, e)\n }\n } else if (typeof this.rowGapValue === 'string' && this.rowGapValue.trim() !== '') {\n console.warn(\n `[GridNode ${this.props.key}] Unsupported string row gap format: \"${this.rowGapValue}\". Using 0px. Only numbers and percentages ('%') are supported.`,\n )\n }\n\n // Ensure gaps are not negative\n columnGapPixels = Math.max(0, columnGapPixels)\n rowGapPixels = Math.max(0, rowGapPixels)\n\n // Step 5: Calculate flex-basis percentage for children\n const mainAxisGapPixels = this.isVertical ? rowGapPixels : columnGapPixels\n const mainAxisContentSize = this.isVertical ? contentHeight : contentWidth\n let childWidth = 0\n\n if (mainAxisContentSize > 0 && this.columns > 0) {\n // Total space taken up by gaps on the main axis\n const totalGapSpaceOnMainAxis = this.columns > 1 ? mainAxisGapPixels * (this.columns - 1) : 0\n\n // Calculate the space available *only* for the items themselves\n const availableSpaceOnMainAxis = Math.max(0, mainAxisContentSize - totalGapSpaceOnMainAxis)\n\n // Calculate the exact pixel of the total content size that each item should occupy\n const exactItemWidth = availableSpaceOnMainAxis / this.columns\n\n // Ensure it's not negative (shouldn't happen, but safety)\n childWidth = Math.max(0, exactItemWidth - 0.5) // Slightly reduce to avoid rounding issues\n } else if (this.columns === 1) {\n // If only one column, it takes up the full basis (gaps don't apply)\n childWidth = mainAxisContentSize\n }\n\n // Clamp basis percentage between 0 and 100 (mostly redundant after floor/max(0) but safe)\n childWidth = Math.max(0, Math.min(mainAxisContentSize, childWidth))\n\n // Step 6: Apply layout properties to children\n let childrenNeedRecalculation = false\n for (const child of this.children) {\n let childChanged = false\n const currentLayoutWidth = child.node.getWidth()\n const currentWidthValue = currentLayoutWidth.value\n const currentWidthUnit = currentLayoutWidth.unit\n\n let widthNeedsUpdate = false\n if (currentWidthUnit === Style.Unit.Point) {\n // If current width is in points, check if the value is significantly different\n if (Math.abs(currentWidthValue - childWidth) > 0.01) {\n widthNeedsUpdate = true\n }\n } else {\n // If current width is not in points (e.g., Auto, Percent, Undefined), it needs to be set to points\n widthNeedsUpdate = true\n }\n\n if (widthNeedsUpdate) {\n child.node.setWidth(childWidth)\n childChanged = true\n }\n\n // Ensure grow/shrink are set correctly for grid items\n if (child.node.getFlexGrow() !== 0) {\n child.node.setFlexGrow(0)\n childChanged = true\n }\n if (child.node.getFlexShrink() !== 1) {\n child.node.setFlexShrink(1) // Allow shrinking\n childChanged = true\n }\n\n // Remove margins that might interfere with gap property\n if (child.node.getMargin(Style.Edge.Bottom).unit !== Style.Unit.Undefined) {\n child.node.setMargin(Style.Edge.Bottom, undefined)\n childChanged = true\n }\n if (child.node.getMargin(Style.Edge.Right).unit !== Style.Unit.Undefined) {\n child.node.setMargin(Style.Edge.Right, undefined)\n childChanged = true\n }\n if (child.node.getMargin(Style.Edge.Top).unit !== Style.Unit.Undefined) {\n child.node.setMargin(Style.Edge.Top, undefined)\n childChanged = true\n }\n if (child.node.getMargin(Style.Edge.Left).unit !== Style.Unit.Undefined) {\n child.node.setMargin(Style.Edge.Left, undefined)\n childChanged = true\n }\n\n if (childChanged && !child.node.isDirty()) {\n child.node.markDirty()\n childrenNeedRecalculation = true\n }\n }\n\n // Step 7: Apply gaps using Yoga's built-in gap properties\n const currentColumnGap = this.node.getGap(Style.Gutter.Column).value\n const currentRowGap = this.node.getGap(Style.Gutter.Row).value\n let gapsChanged = false\n\n // Use a small tolerance for comparing gap pixels\n if (Math.abs(currentColumnGap - columnGapPixels) > 0.001) {\n this.node.setGap(Style.Gutter.Column, columnGapPixels)\n gapsChanged = true\n }\n if (Math.abs(currentRowGap - rowGapPixels) > 0.001) {\n this.node.setGap(Style.Gutter.Row, rowGapPixels)\n gapsChanged = true\n }\n\n // Step 8: Mark the grid node itself as dirty if gaps changed or children changed\n if ((gapsChanged || childrenNeedRecalculation) && !this.node.isDirty()) {\n this.node.markDirty()\n }\n }\n}\n\n/**\n * Factory function to create a new GridNode instance.\n * @param props Grid configuration properties.\n * @returns A new GridNode instance.\n */\nexport const Grid = (props: GridProps) => new GridNode(props)\n"],"names":["RowNode","Style"],"mappings":";;;;;AAAA;AAMA;;;;AAIG;AACG,MAAO,QAAS,SAAQA,0BAAO,CAAA;AAClB,IAAA,OAAO;AACP,IAAA,cAAc;AACd,IAAA,WAAW;IACX,UAAU,CAAS;AAEpC;;;AAGG;AACH,IAAA,WAAA,CAAY,KAAgB,EAAA;AAC1B,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,KAAK,CAAA;QAC1C,MAAM,UAAU,GAAG,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,gBAAgB;;AAG3E,QAAA,IAAI,aAA4B;QAChC,QAAQ,SAAS;AACf,YAAA,KAAK,KAAK;AACR,gBAAA,aAAa,GAAGC,kBAAK,CAAC,aAAa,CAAC,GAAG;gBACvC;AACF,YAAA,KAAK,QAAQ;AACX,gBAAA,aAAa,GAAGA,kBAAK,CAAC,aAAa,CAAC,MAAM;gBAC1C;AACF,YAAA,KAAK,aAAa;AAChB,gBAAA,aAAa,GAAGA,kBAAK,CAAC,aAAa,CAAC,UAAU;gBAC9C;AACF,YAAA,KAAK,gBAAgB;AACnB,gBAAA,aA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AC,GAAG,KAAK,EAAE;AACxD,YAAA,IAAI,CAAC,IAAI,CAAC,MAAM,CAACA,kBAAK,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;YACtD,WAAW,GAAG,IAAI;QACpB;QACA,IAAI,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,YAAY,CAAC,GAAG,KAAK,EAAE;AAClD,YAAA,IAAI,CAAC,IAAI,CAAC,MAAM,CAACA,kBAAK,CAAC,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC;YAChD,WAAW,GAAG,IAAI;QACpB;;AAGA,QAAA,IAAI,CAAC,WAAW,IAAI,yBAAyB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;AACtE,YAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;QACvB;IACF;AACD;AAED;;;;AAIG;AACI,MAAM,IAAI,GAAG,CAAC,KAAgB,KAAK,IAAI,QAAQ,CAAC,KAAK;;;;;"}
|
|
@@ -15,7 +15,6 @@ export declare class ImageNode extends BoxNode {
|
|
|
15
15
|
/**
|
|
16
16
|
* Loads and processes an image from various sources (URL, file path, or Buffer).
|
|
17
17
|
* Handles SVG color modifications and sets natural dimensions with an aspect ratio.
|
|
18
|
-
*
|
|
19
18
|
* @returns Promise that resolves when image loading completes
|
|
20
19
|
* @throws Error if image loading fails
|
|
21
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.canvas.util.d.ts","sourceRoot":"","sources":["../../../src/canvas/image.canvas.util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"image.canvas.util.d.ts","sourceRoot":"","sources":["../../../src/canvas/image.canvas.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,KAAK,wBAAwB,EAAmC,MAAM,aAAa,CAAA;AAC5F,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAsBxD;;;GAGG;AACH,qBAAa,SAAU,SAAQ,OAAO;IAC5B,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;IACrC,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,YAAY,CAAI;IACxB,OAAO,CAAC,aAAa,CAAI;IACzB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6B;gBAEhD,KAAK,EAAE,UAAU;IAc7B;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IA8GX,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzC;;;OAGG;cACgB,cAAc,CAAC,GAAG,EAAE,wBAAwB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAoJrH;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,UAAU,cAAyB,CAAA"}
|