graphics-debug 0.0.83 → 0.0.84
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/{chunk-NYENUFOW.js → chunk-7236NVI2.js} +5 -1
- package/dist/chunk-7236NVI2.js.map +1 -0
- package/dist/{chunk-PPB7D4OE.js → chunk-AKONCUCE.js} +47 -8
- package/dist/chunk-AKONCUCE.js.map +1 -0
- package/dist/chunk-FLFF6QXL.js +89 -0
- package/dist/chunk-FLFF6QXL.js.map +1 -0
- package/dist/{chunk-HU5LL4ZE.js → chunk-HPNVGPHJ.js} +2 -2
- package/dist/chunk-HPNVGPHJ.js.map +1 -0
- package/dist/{chunk-BQ3ZHEQO.js → chunk-K37Y2KHE.js} +5 -1
- package/dist/chunk-K37Y2KHE.js.map +1 -0
- package/dist/{chunk-MXOATGTD.js → chunk-MYMDOAQN.js} +4 -4
- package/dist/{chunk-GZRUE2GP.js → chunk-OB4CGOL3.js} +6 -1
- package/dist/chunk-OB4CGOL3.js.map +1 -0
- package/dist/{chunk-7NMLOZRC.js → chunk-ZWAXHWX2.js} +56 -4
- package/dist/chunk-ZWAXHWX2.js.map +1 -0
- package/dist/cli/cli.js +8 -7
- package/dist/cli/cli.js.map +1 -1
- package/dist/lib/drawGraphicsToCanvas.js +2 -1
- package/dist/lib/getSvgFromGraphicsObject.d.ts +1 -1
- package/dist/lib/getSvgFromGraphicsObject.js +2 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +8 -7
- package/dist/lib/infiniteLineHelpers.d.ts +7 -0
- package/dist/lib/infiniteLineHelpers.js +9 -0
- package/dist/lib/infiniteLineHelpers.js.map +1 -0
- package/dist/lib/matcher.js +2 -1
- package/dist/lib/matcher.js.map +1 -1
- package/dist/lib/mergeGraphics.js +1 -1
- package/dist/lib/react.d.ts +1 -1
- package/dist/lib/react.js +194 -99
- package/dist/lib/react.js.map +1 -1
- package/dist/lib/setStepOfAllObjects.js +1 -1
- package/dist/lib/stackGraphics.js +5 -4
- package/dist/lib/translateGraphics.js +1 -1
- package/dist/lib/types.d.ts +18 -1
- package/package.json +1 -1
- package/dist/chunk-7NMLOZRC.js.map +0 -1
- package/dist/chunk-BQ3ZHEQO.js.map +0 -1
- package/dist/chunk-GZRUE2GP.js.map +0 -1
- package/dist/chunk-HU5LL4ZE.js.map +0 -1
- package/dist/chunk-NYENUFOW.js.map +0 -1
- package/dist/chunk-PPB7D4OE.js.map +0 -1
- /package/dist/{chunk-MXOATGTD.js.map → chunk-MYMDOAQN.js.map} +0 -0
|
@@ -11,6 +11,10 @@ function translateGraphics(graphics, dx, dy) {
|
|
|
11
11
|
...line,
|
|
12
12
|
points: line.points.map((pt) => ({ x: pt.x + dx, y: pt.y + dy }))
|
|
13
13
|
})),
|
|
14
|
+
infiniteLines: graphics.infiniteLines?.map((line) => ({
|
|
15
|
+
...line,
|
|
16
|
+
origin: { x: line.origin.x + dx, y: line.origin.y + dy }
|
|
17
|
+
})),
|
|
14
18
|
polygons: graphics.polygons?.map((polygon) => ({
|
|
15
19
|
...polygon,
|
|
16
20
|
points: polygon.points.map((pt) => ({ x: pt.x + dx, y: pt.y + dy }))
|
|
@@ -39,4 +43,4 @@ function translateGraphics(graphics, dx, dy) {
|
|
|
39
43
|
export {
|
|
40
44
|
translateGraphics
|
|
41
45
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
46
|
+
//# sourceMappingURL=chunk-7236NVI2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/translateGraphics.ts"],"sourcesContent":["import type { GraphicsObject } from \"./types\"\n\nexport function translateGraphics(\n graphics: GraphicsObject,\n dx: number,\n dy: number,\n): GraphicsObject {\n return {\n ...graphics,\n points: graphics.points?.map((p) => ({\n ...p,\n x: p.x + dx,\n y: p.y + dy,\n })),\n lines: graphics.lines?.map((line) => ({\n ...line,\n points: line.points.map((pt) => ({ x: pt.x + dx, y: pt.y + dy })),\n })),\n infiniteLines: graphics.infiniteLines?.map((line) => ({\n ...line,\n origin: { x: line.origin.x + dx, y: line.origin.y + dy },\n })),\n polygons: graphics.polygons?.map((polygon) => ({\n ...polygon,\n points: polygon.points.map((pt) => ({ x: pt.x + dx, y: pt.y + dy })),\n })),\n rects: graphics.rects?.map((rect) => ({\n ...rect,\n center: { x: rect.center.x + dx, y: rect.center.y + dy },\n })),\n circles: graphics.circles?.map((circle) => ({\n ...circle,\n center: { x: circle.center.x + dx, y: circle.center.y + dy },\n })),\n arrows: graphics.arrows?.map((arrow) => ({\n ...arrow,\n start: { x: arrow.start.x + dx, y: arrow.start.y + dy },\n end: { x: arrow.end.x + dx, y: arrow.end.y + dy },\n })),\n texts: graphics.texts?.map((text) => ({\n ...text,\n x: text.x + dx,\n y: text.y + dy,\n })),\n }\n}\n"],"mappings":";AAEO,SAAS,kBACd,UACA,IACA,IACgB;AAChB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,QAAQ,SAAS,QAAQ,IAAI,CAAC,OAAO;AAAA,MACnC,GAAG;AAAA,MACH,GAAG,EAAE,IAAI;AAAA,MACT,GAAG,EAAE,IAAI;AAAA,IACX,EAAE;AAAA,IACF,OAAO,SAAS,OAAO,IAAI,CAAC,UAAU;AAAA,MACpC,GAAG;AAAA,MACH,QAAQ,KAAK,OAAO,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI,GAAG,EAAE;AAAA,IAClE,EAAE;AAAA,IACF,eAAe,SAAS,eAAe,IAAI,CAAC,UAAU;AAAA,MACpD,GAAG;AAAA,MACH,QAAQ,EAAE,GAAG,KAAK,OAAO,IAAI,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG;AAAA,IACzD,EAAE;AAAA,IACF,UAAU,SAAS,UAAU,IAAI,CAAC,aAAa;AAAA,MAC7C,GAAG;AAAA,MACH,QAAQ,QAAQ,OAAO,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI,GAAG,EAAE;AAAA,IACrE,EAAE;AAAA,IACF,OAAO,SAAS,OAAO,IAAI,CAAC,UAAU;AAAA,MACpC,GAAG;AAAA,MACH,QAAQ,EAAE,GAAG,KAAK,OAAO,IAAI,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG;AAAA,IACzD,EAAE;AAAA,IACF,SAAS,SAAS,SAAS,IAAI,CAAC,YAAY;AAAA,MAC1C,GAAG;AAAA,MACH,QAAQ,EAAE,GAAG,OAAO,OAAO,IAAI,IAAI,GAAG,OAAO,OAAO,IAAI,GAAG;AAAA,IAC7D,EAAE;AAAA,IACF,QAAQ,SAAS,QAAQ,IAAI,CAAC,WAAW;AAAA,MACvC,GAAG;AAAA,MACH,OAAO,EAAE,GAAG,MAAM,MAAM,IAAI,IAAI,GAAG,MAAM,MAAM,IAAI,GAAG;AAAA,MACtD,KAAK,EAAE,GAAG,MAAM,IAAI,IAAI,IAAI,GAAG,MAAM,IAAI,IAAI,GAAG;AAAA,IAClD,EAAE;AAAA,IACF,OAAO,SAAS,OAAO,IAAI,CAAC,UAAU;AAAA,MACpC,GAAG;AAAA,MACH,GAAG,KAAK,IAAI;AAAA,MACZ,GAAG,KAAK,IAAI;AAAA,IACd,EAAE;AAAA,EACJ;AACF;","names":[]}
|
|
@@ -6,14 +6,10 @@ import {
|
|
|
6
6
|
FONT_SIZE_HEIGHT_RATIO,
|
|
7
7
|
FONT_SIZE_WIDTH_RATIO
|
|
8
8
|
} from "./chunk-ZGI74PYD.js";
|
|
9
|
-
|
|
10
|
-
// lib/drawGraphicsToCanvas.ts
|
|
11
9
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
applyToPoint
|
|
16
|
-
} from "transformation-matrix";
|
|
10
|
+
clipInfiniteLineToBounds,
|
|
11
|
+
getViewportBoundsFromMatrix
|
|
12
|
+
} from "./chunk-FLFF6QXL.js";
|
|
17
13
|
|
|
18
14
|
// site/components/InteractiveGraphics/defaultColors.ts
|
|
19
15
|
var defaultColors = [
|
|
@@ -56,6 +52,12 @@ var defaultColors = [
|
|
|
56
52
|
];
|
|
57
53
|
|
|
58
54
|
// lib/drawGraphicsToCanvas.ts
|
|
55
|
+
import {
|
|
56
|
+
applyToPoint,
|
|
57
|
+
compose,
|
|
58
|
+
scale,
|
|
59
|
+
translate
|
|
60
|
+
} from "transformation-matrix";
|
|
59
61
|
function computeTransformFromViewbox(viewbox, canvasWidth, canvasHeight, options = {}) {
|
|
60
62
|
const padding = options.padding ?? 40;
|
|
61
63
|
const yFlip = options.yFlip ?? false;
|
|
@@ -321,6 +323,43 @@ function drawGraphicsToCanvas(graphics, target, options = {}) {
|
|
|
321
323
|
ctx.stroke();
|
|
322
324
|
});
|
|
323
325
|
}
|
|
326
|
+
if (graphics.infiniteLines && graphics.infiniteLines.length > 0) {
|
|
327
|
+
const viewportBounds = getViewportBoundsFromMatrix(
|
|
328
|
+
matrix,
|
|
329
|
+
canvasWidth,
|
|
330
|
+
canvasHeight
|
|
331
|
+
);
|
|
332
|
+
graphics.infiniteLines.forEach((line, lineIndex) => {
|
|
333
|
+
const segment = clipInfiniteLineToBounds(line, viewportBounds);
|
|
334
|
+
if (!segment) return;
|
|
335
|
+
const [start, end] = segment;
|
|
336
|
+
const projectedStart = applyToPoint(matrix, start);
|
|
337
|
+
const projectedEnd = applyToPoint(matrix, end);
|
|
338
|
+
ctx.beginPath();
|
|
339
|
+
ctx.moveTo(projectedStart.x, projectedStart.y);
|
|
340
|
+
ctx.lineTo(projectedEnd.x, projectedEnd.y);
|
|
341
|
+
ctx.strokeStyle = line.strokeColor || defaultColors[lineIndex % defaultColors.length];
|
|
342
|
+
ctx.lineWidth = line.strokeWidth ? line.strokeWidth * Math.abs(matrix.a) : 2;
|
|
343
|
+
ctx.lineCap = "round";
|
|
344
|
+
if (line.strokeDash) {
|
|
345
|
+
if (typeof line.strokeDash === "string") {
|
|
346
|
+
let dashArray;
|
|
347
|
+
if (line.strokeDash.includes(",")) {
|
|
348
|
+
dashArray = line.strokeDash.split(",").map((s) => parseFloat(s.trim())).filter((n) => !Number.isNaN(n));
|
|
349
|
+
} else {
|
|
350
|
+
const value = parseFloat(line.strokeDash.trim());
|
|
351
|
+
dashArray = !Number.isNaN(value) ? [value] : [];
|
|
352
|
+
}
|
|
353
|
+
ctx.setLineDash(dashArray);
|
|
354
|
+
} else {
|
|
355
|
+
ctx.setLineDash(line.strokeDash.map((n) => n * Math.abs(matrix.a)));
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
ctx.setLineDash([]);
|
|
359
|
+
}
|
|
360
|
+
ctx.stroke();
|
|
361
|
+
});
|
|
362
|
+
}
|
|
324
363
|
if (graphics.points && graphics.points.length > 0) {
|
|
325
364
|
graphics.points.forEach((point, pointIndex) => {
|
|
326
365
|
const projected = applyToPoint(matrix, point);
|
|
@@ -377,4 +416,4 @@ export {
|
|
|
377
416
|
getBounds,
|
|
378
417
|
drawGraphicsToCanvas
|
|
379
418
|
};
|
|
380
|
-
//# sourceMappingURL=chunk-
|
|
419
|
+
//# sourceMappingURL=chunk-AKONCUCE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../site/components/InteractiveGraphics/defaultColors.ts","../lib/drawGraphicsToCanvas.ts"],"sourcesContent":["// These are default colors if no color is provided\n// colors are made based on the index of the item in the array\n\nexport const defaultColors = [\n \"rgba(239, 68, 68, 0.8)\", // red-300\n \"rgba(249, 115, 22, 0.8)\", // orange-300\n \"rgba(245, 158, 11, 0.8)\", // amber-300\n \"rgba(234, 179, 8, 0.8)\", // yellow-300\n \"rgba(132, 204, 22, 0.8)\", // lime-300\n \"rgba(34, 197, 94, 0.8)\", // green-300\n \"rgba(16, 185, 129, 0.8)\", // emerald-300\n \"rgba(20, 184, 166, 0.8)\", // teal-300\n \"rgba(6, 182, 212, 0.8)\", // cyan-300\n \"rgba(14, 165, 233, 0.8)\", // sky-300\n \"rgba(59, 130, 246, 0.8)\", // blue-300\n \"rgba(99, 102, 241, 0.8)\", // indigo-300\n \"rgba(139, 92, 246, 0.8)\", // violet-300\n \"rgba(168, 85, 247, 0.8)\", // purple-300\n \"rgba(217, 70, 239, 0.8)\", // fuchsia-300\n \"rgba(236, 72, 153, 0.8)\", // pink-300\n \"rgba(249, 168, 212, 0.8)\", // rose-300\n \"rgba(161, 161, 170, 0.8)\", // zinc-300\n]\n","import { defaultColors } from \"site/components/InteractiveGraphics/defaultColors\"\nimport {\n type Matrix,\n applyToPoint,\n compose,\n scale,\n translate,\n} from \"transformation-matrix\"\nimport { getArrowBoundingBox, getArrowGeometry } from \"./arrowHelpers\"\nimport { FONT_SIZE_HEIGHT_RATIO, FONT_SIZE_WIDTH_RATIO } from \"./constants\"\nimport {\n clipInfiniteLineToBounds,\n getViewportBoundsFromMatrix,\n} from \"./infiniteLineHelpers\"\nimport type {\n CenterViewbox,\n GraphicsObject,\n TransformOptions,\n Viewbox,\n} from \"./types\"\n\n/**\n * Computes a transformation matrix based on a provided viewbox\n * Handles both min/max style viewboxes and center/width/height style viewboxes\n */\nexport function computeTransformFromViewbox(\n viewbox: Viewbox | CenterViewbox,\n canvasWidth: number,\n canvasHeight: number,\n options: { padding?: number; yFlip?: boolean } = {},\n): Matrix {\n const padding = options.padding ?? 40\n const yFlip = options.yFlip ?? false\n\n // Convert CenterViewbox to Viewbox if needed\n let bounds: Viewbox\n if (\"center\" in viewbox) {\n const halfWidth = viewbox.width / 2\n const halfHeight = viewbox.height / 2\n bounds = {\n minX: viewbox.center.x - halfWidth,\n maxX: viewbox.center.x + halfWidth,\n minY: viewbox.center.y - halfHeight,\n maxY: viewbox.center.y + halfHeight,\n }\n } else {\n bounds = viewbox\n }\n\n const width = bounds.maxX - bounds.minX || 1\n const height = bounds.maxY - bounds.minY || 1\n\n const scale_factor = Math.min(\n (canvasWidth - 2 * padding) / width,\n (canvasHeight - 2 * padding) / height,\n )\n\n return compose(\n translate(canvasWidth / 2, canvasHeight / 2),\n scale(scale_factor, yFlip ? -scale_factor : scale_factor),\n translate(-(bounds.minX + width / 2), -(bounds.minY + height / 2)),\n )\n}\n\n/**\n * Computes bounds for a graphics object\n */\nexport function getBounds(graphics: GraphicsObject): Viewbox {\n const points = [\n ...(graphics.points || []),\n ...(graphics.lines || []).flatMap((line) => line.points),\n ...(graphics.polygons || []).flatMap((polygon) => polygon.points),\n ...(graphics.rects || []).flatMap((rect) => {\n const halfWidth = rect.width / 2\n const halfHeight = rect.height / 2\n return [\n { x: rect.center.x - halfWidth, y: rect.center.y - halfHeight },\n { x: rect.center.x + halfWidth, y: rect.center.y - halfHeight },\n { x: rect.center.x - halfWidth, y: rect.center.y + halfHeight },\n { x: rect.center.x + halfWidth, y: rect.center.y + halfHeight },\n ]\n }),\n ...(graphics.circles || []).flatMap((circle) => [\n { x: circle.center.x - circle.radius, y: circle.center.y }, // left\n { x: circle.center.x + circle.radius, y: circle.center.y }, // right\n { x: circle.center.x, y: circle.center.y - circle.radius }, // top\n { x: circle.center.x, y: circle.center.y + circle.radius }, // bottom\n ]),\n ...(graphics.arrows || []).flatMap((arrow) => {\n const bounds = getArrowBoundingBox(arrow)\n return [\n { x: bounds.minX, y: bounds.minY },\n { x: bounds.maxX, y: bounds.maxY },\n ]\n }),\n ...(graphics.texts || []).flatMap((text) => {\n const fontSize = text.fontSize ?? 12\n const width = text.text.length * fontSize * FONT_SIZE_WIDTH_RATIO\n const height = fontSize * FONT_SIZE_HEIGHT_RATIO\n const anchor = text.anchorSide ?? \"center\"\n const offsetMap: Record<string, { dx: number; dy: number }> = {\n top_left: { dx: 0, dy: 0 },\n top_center: { dx: -width / 2, dy: 0 },\n top_right: { dx: -width, dy: 0 },\n center_left: { dx: 0, dy: -height / 2 },\n center: { dx: -width / 2, dy: -height / 2 },\n center_right: { dx: -width, dy: -height / 2 },\n bottom_left: { dx: 0, dy: -height },\n bottom_center: { dx: -width / 2, dy: -height },\n bottom_right: { dx: -width, dy: -height },\n }\n const { dx, dy } = offsetMap[anchor]\n const x0 = text.x + dx\n const y0 = text.y + dy\n return [\n { x: x0, y: y0 },\n { x: x0 + width, y: y0 + height },\n ]\n }),\n ]\n\n if (points.length === 0) {\n return { minX: -1, maxX: 1, minY: -1, maxY: 1 }\n }\n\n return points.reduce(\n (bounds, point) => ({\n minX: Math.min(bounds.minX, point.x),\n maxX: Math.max(bounds.maxX, point.x),\n minY: Math.min(bounds.minY, point.y),\n maxY: Math.max(bounds.maxY, point.y),\n }),\n { minX: Infinity, maxX: -Infinity, minY: Infinity, maxY: -Infinity },\n )\n}\n\n/**\n * Draws a graphics object onto a canvas or context\n * @param graphics - The graphics object to draw\n * @param target - The canvas element or 2D context to draw on\n * @param options - Options for controlling the transform and rendering\n */\nexport function drawGraphicsToCanvas(\n graphics: GraphicsObject,\n target: HTMLCanvasElement | CanvasRenderingContext2D,\n options: TransformOptions = {},\n): void {\n // Get the context\n const ctx =\n target instanceof HTMLCanvasElement ? target.getContext(\"2d\") : target\n\n if (!ctx) {\n throw new Error(\"Could not get 2D context from canvas\")\n }\n\n // Get canvas dimensions\n const canvasWidth =\n target instanceof HTMLCanvasElement ? target.width : target.canvas.width\n\n const canvasHeight =\n target instanceof HTMLCanvasElement ? target.height : target.canvas.height\n\n // Get or compute the transform matrix\n let matrix: Matrix\n\n if (options.transform) {\n matrix = options.transform\n } else if (options.viewbox) {\n matrix = computeTransformFromViewbox(\n options.viewbox,\n canvasWidth,\n canvasHeight,\n {\n padding: options.padding,\n yFlip: options.yFlip,\n },\n )\n } else {\n // Auto-compute bounds and transform if not provided\n const bounds = getBounds(graphics)\n const yFlip = graphics.coordinateSystem === \"cartesian\"\n matrix = computeTransformFromViewbox(bounds, canvasWidth, canvasHeight, {\n padding: options.padding ?? 40,\n yFlip,\n })\n }\n\n // Clear the canvas\n ctx.clearRect(0, 0, canvasWidth, canvasHeight)\n\n // Save the current transform state\n ctx.save()\n\n // Draw the graphics elements\n // Draw rectangles\n if (graphics.rects && graphics.rects.length > 0) {\n graphics.rects.forEach((rect) => {\n const halfWidth = rect.width / 2\n const halfHeight = rect.height / 2\n\n const topLeft = applyToPoint(matrix, {\n x: rect.center.x - halfWidth,\n y: rect.center.y - halfHeight,\n })\n\n const bottomRight = applyToPoint(matrix, {\n x: rect.center.x + halfWidth,\n y: rect.center.y + halfHeight,\n })\n\n const width = Math.abs(bottomRight.x - topLeft.x)\n const height = Math.abs(bottomRight.y - topLeft.y)\n\n ctx.beginPath()\n ctx.rect(\n Math.min(topLeft.x, bottomRight.x),\n Math.min(topLeft.y, bottomRight.y),\n width,\n height,\n )\n\n if (rect.fill) {\n ctx.fillStyle = rect.fill\n ctx.fill()\n }\n\n if (rect.stroke) {\n ctx.strokeStyle = rect.stroke\n ctx.stroke()\n }\n })\n }\n\n // Draw circles\n if (graphics.circles && graphics.circles.length > 0) {\n graphics.circles.forEach((circle) => {\n const projected = applyToPoint(matrix, circle.center)\n const scaledRadius = circle.radius * Math.abs(matrix.a) // Use matrix scale factor\n\n ctx.beginPath()\n ctx.arc(projected.x, projected.y, scaledRadius, 0, 2 * Math.PI)\n\n if (circle.fill) {\n ctx.fillStyle = circle.fill\n ctx.fill()\n }\n\n if (circle.stroke) {\n ctx.strokeStyle = circle.stroke ?? \"transparent\"\n ctx.stroke()\n }\n })\n }\n\n // Draw polygons\n if (graphics.polygons && graphics.polygons.length > 0) {\n graphics.polygons.forEach((polygon) => {\n if (polygon.points.length === 0) return\n\n const projectedPoints = polygon.points.map((point) =>\n applyToPoint(matrix, point),\n )\n\n ctx.beginPath()\n ctx.moveTo(projectedPoints[0].x, projectedPoints[0].y)\n for (let i = 1; i < projectedPoints.length; i++) {\n ctx.lineTo(projectedPoints[i].x, projectedPoints[i].y)\n }\n ctx.closePath()\n\n if (polygon.fill) {\n ctx.fillStyle = polygon.fill\n ctx.fill()\n }\n\n if (polygon.stroke) {\n ctx.strokeStyle = polygon.stroke\n if (polygon.strokeWidth !== undefined) {\n ctx.lineWidth = polygon.strokeWidth * Math.abs(matrix.a)\n }\n ctx.stroke()\n }\n })\n }\n\n if (graphics.arrows && graphics.arrows.length > 0) {\n graphics.arrows.forEach((arrow, arrowIndex) => {\n const geometry = getArrowGeometry(arrow)\n const shaftStart = applyToPoint(matrix, geometry.shaftStart)\n const shaftEnd = applyToPoint(matrix, geometry.shaftEnd)\n\n const color =\n arrow.color || defaultColors[arrowIndex % defaultColors.length]\n const scaleFactor = Math.hypot(matrix.a, matrix.b)\n\n ctx.strokeStyle = color\n ctx.fillStyle = color\n ctx.lineWidth = geometry.shaftWidth * (scaleFactor || 1)\n ctx.lineCap = \"round\"\n ctx.setLineDash([])\n\n ctx.beginPath()\n ctx.moveTo(shaftStart.x, shaftStart.y)\n ctx.lineTo(shaftEnd.x, shaftEnd.y)\n ctx.stroke()\n\n geometry.heads.forEach((head) => {\n const tip = applyToPoint(matrix, head.tip)\n const leftWing = applyToPoint(matrix, head.leftWing)\n const rightWing = applyToPoint(matrix, head.rightWing)\n\n ctx.beginPath()\n ctx.moveTo(tip.x, tip.y)\n ctx.lineTo(leftWing.x, leftWing.y)\n ctx.lineTo(rightWing.x, rightWing.y)\n ctx.closePath()\n ctx.fill()\n })\n })\n }\n\n // Draw lines\n if (graphics.lines && graphics.lines.length > 0) {\n graphics.lines.forEach((line, lineIndex) => {\n if (line.points.length === 0) return\n\n ctx.beginPath()\n\n const firstPoint = applyToPoint(matrix, line.points[0])\n ctx.moveTo(firstPoint.x, firstPoint.y)\n\n for (let i = 1; i < line.points.length; i++) {\n const projected = applyToPoint(matrix, line.points[i])\n ctx.lineTo(projected.x, projected.y)\n }\n\n ctx.strokeStyle =\n line.strokeColor || defaultColors[lineIndex % defaultColors.length]\n if (line.strokeWidth) {\n ctx.lineWidth = line.strokeWidth * matrix.a\n } else {\n ctx.lineWidth = 2\n }\n ctx.lineCap = \"round\"\n\n if (line.strokeDash) {\n if (typeof line.strokeDash === \"string\") {\n // Convert string to array of numbers, handling single values properly\n let dashArray: number[]\n\n // If the string contains commas, split and convert to numbers\n if (line.strokeDash.includes(\",\")) {\n dashArray = line.strokeDash\n .split(\",\")\n .map((s) => parseFloat(s.trim()))\n .filter((n) => !Number.isNaN(n))\n } else {\n // Handle single value case\n const value = parseFloat(line.strokeDash.trim())\n dashArray = !Number.isNaN(value) ? [value] : []\n }\n\n // Scale dash values based on transform matrix\n ctx.setLineDash(dashArray)\n } else {\n // Handle array format\n ctx.setLineDash(line.strokeDash.map((n) => n * Math.abs(matrix.a)))\n }\n } else {\n ctx.setLineDash([])\n }\n\n ctx.stroke()\n })\n }\n\n if (graphics.infiniteLines && graphics.infiniteLines.length > 0) {\n const viewportBounds = getViewportBoundsFromMatrix(\n matrix,\n canvasWidth,\n canvasHeight,\n )\n\n graphics.infiniteLines.forEach((line, lineIndex) => {\n const segment = clipInfiniteLineToBounds(line, viewportBounds)\n if (!segment) return\n\n const [start, end] = segment\n const projectedStart = applyToPoint(matrix, start)\n const projectedEnd = applyToPoint(matrix, end)\n\n ctx.beginPath()\n ctx.moveTo(projectedStart.x, projectedStart.y)\n ctx.lineTo(projectedEnd.x, projectedEnd.y)\n\n ctx.strokeStyle =\n line.strokeColor || defaultColors[lineIndex % defaultColors.length]\n ctx.lineWidth = line.strokeWidth\n ? line.strokeWidth * Math.abs(matrix.a)\n : 2\n ctx.lineCap = \"round\"\n\n if (line.strokeDash) {\n if (typeof line.strokeDash === \"string\") {\n let dashArray: number[]\n if (line.strokeDash.includes(\",\")) {\n dashArray = line.strokeDash\n .split(\",\")\n .map((s) => parseFloat(s.trim()))\n .filter((n) => !Number.isNaN(n))\n } else {\n const value = parseFloat(line.strokeDash.trim())\n dashArray = !Number.isNaN(value) ? [value] : []\n }\n ctx.setLineDash(dashArray)\n } else {\n ctx.setLineDash(line.strokeDash.map((n) => n * Math.abs(matrix.a)))\n }\n } else {\n ctx.setLineDash([])\n }\n\n ctx.stroke()\n })\n }\n\n // Draw points\n if (graphics.points && graphics.points.length > 0) {\n graphics.points.forEach((point, pointIndex) => {\n const projected = applyToPoint(matrix, point)\n\n // Draw point as a small circle\n ctx.beginPath()\n ctx.arc(projected.x, projected.y, 3, 0, 2 * Math.PI)\n ctx.fillStyle =\n point.color || defaultColors[pointIndex % defaultColors.length]\n ctx.fill()\n\n // Draw label if present and labels aren't disabled\n if (point.label && !options.disableLabels) {\n ctx.fillStyle = point.color || \"black\"\n ctx.font = \"12px sans-serif\"\n ctx.fillText(point.label, projected.x + 5, projected.y - 5)\n }\n })\n }\n\n // Draw texts\n if (graphics.texts && graphics.texts.length > 0) {\n graphics.texts.forEach((text) => {\n const projected = applyToPoint(matrix, { x: text.x, y: text.y })\n ctx.fillStyle = text.color || \"black\"\n ctx.font = `${(text.fontSize ?? 12) * Math.abs(matrix.a)}px sans-serif`\n\n const anchor = text.anchorSide ?? \"center\"\n const alignMap: Record<string, CanvasTextAlign> = {\n top_left: \"left\",\n center_left: \"left\",\n bottom_left: \"left\",\n top_center: \"center\",\n center: \"center\",\n bottom_center: \"center\",\n top_right: \"right\",\n center_right: \"right\",\n bottom_right: \"right\",\n }\n const baselineMap: Record<string, CanvasTextBaseline> = {\n top_left: \"top\",\n top_center: \"top\",\n top_right: \"top\",\n center_left: \"middle\",\n center: \"middle\",\n center_right: \"middle\",\n bottom_left: \"bottom\",\n bottom_center: \"bottom\",\n bottom_right: \"bottom\",\n }\n ctx.textAlign = alignMap[anchor]\n ctx.textBaseline = baselineMap[anchor]\n\n ctx.fillText(text.text, projected.x, projected.y)\n })\n }\n\n // Restore the original transform\n ctx.restore()\n}\n"],"mappings":";;;;;;;;;;;;;;AAGO,IAAM,gBAAgB;AAAA,EAC3B;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAA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YAAY;AAAA,QACZ,WAAW;AAAA,QACX,aAAa;AAAA,QACb,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,aAAa;AAAA,QACb,eAAe;AAAA,QACf,cAAc;AAAA,MAChB;AACA,UAAI,YAAY,SAAS,MAAM;AAC/B,UAAI,eAAe,YAAY,MAAM;AAErC,UAAI,SAAS,KAAK,MAAM,UAAU,GAAG,UAAU,CAAC;AAAA,IAClD,CAAC;AAAA,EACH;AAGA,MAAI,QAAQ;AACd;","names":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// lib/infiniteLineHelpers.ts
|
|
2
|
+
import { applyToPoint, inverse } from "transformation-matrix";
|
|
3
|
+
var EPSILON = 1e-9;
|
|
4
|
+
var isWithin = (value, min, max) => {
|
|
5
|
+
return value >= min - EPSILON && value <= max + EPSILON;
|
|
6
|
+
};
|
|
7
|
+
var dedupePoints = (points) => {
|
|
8
|
+
const unique = [];
|
|
9
|
+
for (const point of points) {
|
|
10
|
+
if (!unique.some(
|
|
11
|
+
(other) => Math.abs(other.x - point.x) < EPSILON && Math.abs(other.y - point.y) < EPSILON
|
|
12
|
+
)) {
|
|
13
|
+
unique.push(point);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return unique;
|
|
17
|
+
};
|
|
18
|
+
function clipInfiniteLineToBounds(infiniteLine, bounds) {
|
|
19
|
+
const { origin, directionVector } = infiniteLine;
|
|
20
|
+
if (Math.abs(directionVector.x) < EPSILON && Math.abs(directionVector.y) < EPSILON) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const intersections = [];
|
|
24
|
+
if (Math.abs(directionVector.x) >= EPSILON) {
|
|
25
|
+
const tAtMinX = (bounds.minX - origin.x) / directionVector.x;
|
|
26
|
+
const yAtMinX = origin.y + tAtMinX * directionVector.y;
|
|
27
|
+
if (isWithin(yAtMinX, bounds.minY, bounds.maxY)) {
|
|
28
|
+
intersections.push({ x: bounds.minX, y: yAtMinX });
|
|
29
|
+
}
|
|
30
|
+
const tAtMaxX = (bounds.maxX - origin.x) / directionVector.x;
|
|
31
|
+
const yAtMaxX = origin.y + tAtMaxX * directionVector.y;
|
|
32
|
+
if (isWithin(yAtMaxX, bounds.minY, bounds.maxY)) {
|
|
33
|
+
intersections.push({ x: bounds.maxX, y: yAtMaxX });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (Math.abs(directionVector.y) >= EPSILON) {
|
|
37
|
+
const tAtMinY = (bounds.minY - origin.y) / directionVector.y;
|
|
38
|
+
const xAtMinY = origin.x + tAtMinY * directionVector.x;
|
|
39
|
+
if (isWithin(xAtMinY, bounds.minX, bounds.maxX)) {
|
|
40
|
+
intersections.push({ x: xAtMinY, y: bounds.minY });
|
|
41
|
+
}
|
|
42
|
+
const tAtMaxY = (bounds.maxY - origin.y) / directionVector.y;
|
|
43
|
+
const xAtMaxY = origin.x + tAtMaxY * directionVector.x;
|
|
44
|
+
if (isWithin(xAtMaxY, bounds.minX, bounds.maxX)) {
|
|
45
|
+
intersections.push({ x: xAtMaxY, y: bounds.maxY });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const uniqueIntersections = dedupePoints(intersections);
|
|
49
|
+
if (uniqueIntersections.length < 2) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
let first = uniqueIntersections[0];
|
|
53
|
+
let second = uniqueIntersections[1];
|
|
54
|
+
let maxDistanceSquared = (first.x - second.x) ** 2 + (first.y - second.y) ** 2;
|
|
55
|
+
for (let i = 0; i < uniqueIntersections.length; i++) {
|
|
56
|
+
for (let j = i + 1; j < uniqueIntersections.length; j++) {
|
|
57
|
+
const a = uniqueIntersections[i];
|
|
58
|
+
const b = uniqueIntersections[j];
|
|
59
|
+
const distanceSquared = (a.x - b.x) ** 2 + (a.y - b.y) ** 2;
|
|
60
|
+
if (distanceSquared > maxDistanceSquared) {
|
|
61
|
+
first = a;
|
|
62
|
+
second = b;
|
|
63
|
+
maxDistanceSquared = distanceSquared;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return [first, second];
|
|
68
|
+
}
|
|
69
|
+
function getViewportBoundsFromMatrix(matrix, width, height) {
|
|
70
|
+
const screenToReal = inverse(matrix);
|
|
71
|
+
const corners = [
|
|
72
|
+
applyToPoint(screenToReal, { x: 0, y: 0 }),
|
|
73
|
+
applyToPoint(screenToReal, { x: width, y: 0 }),
|
|
74
|
+
applyToPoint(screenToReal, { x: 0, y: height }),
|
|
75
|
+
applyToPoint(screenToReal, { x: width, y: height })
|
|
76
|
+
];
|
|
77
|
+
return {
|
|
78
|
+
minX: Math.min(...corners.map((p) => p.x)),
|
|
79
|
+
maxX: Math.max(...corners.map((p) => p.x)),
|
|
80
|
+
minY: Math.min(...corners.map((p) => p.y)),
|
|
81
|
+
maxY: Math.max(...corners.map((p) => p.y))
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
clipInfiniteLineToBounds,
|
|
87
|
+
getViewportBoundsFromMatrix
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=chunk-FLFF6QXL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/infiniteLineHelpers.ts"],"sourcesContent":["import { type Matrix, applyToPoint, inverse } from \"transformation-matrix\"\nimport type { InfiniteLine, Point, Viewbox } from \"./types\"\n\nconst EPSILON = 1e-9\n\nconst isWithin = (value: number, min: number, max: number) => {\n return value >= min - EPSILON && value <= max + EPSILON\n}\n\nconst dedupePoints = (points: Point[]) => {\n const unique: Point[] = []\n for (const point of points) {\n if (\n !unique.some(\n (other) =>\n Math.abs(other.x - point.x) < EPSILON &&\n Math.abs(other.y - point.y) < EPSILON,\n )\n ) {\n unique.push(point)\n }\n }\n return unique\n}\n\nexport function clipInfiniteLineToBounds(\n infiniteLine: InfiniteLine,\n bounds: Viewbox,\n): [Point, Point] | null {\n const { origin, directionVector } = infiniteLine\n\n if (\n Math.abs(directionVector.x) < EPSILON &&\n Math.abs(directionVector.y) < EPSILON\n ) {\n return null\n }\n\n const intersections: Point[] = []\n\n if (Math.abs(directionVector.x) >= EPSILON) {\n const tAtMinX = (bounds.minX - origin.x) / directionVector.x\n const yAtMinX = origin.y + tAtMinX * directionVector.y\n if (isWithin(yAtMinX, bounds.minY, bounds.maxY)) {\n intersections.push({ x: bounds.minX, y: yAtMinX })\n }\n\n const tAtMaxX = (bounds.maxX - origin.x) / directionVector.x\n const yAtMaxX = origin.y + tAtMaxX * directionVector.y\n if (isWithin(yAtMaxX, bounds.minY, bounds.maxY)) {\n intersections.push({ x: bounds.maxX, y: yAtMaxX })\n }\n }\n\n if (Math.abs(directionVector.y) >= EPSILON) {\n const tAtMinY = (bounds.minY - origin.y) / directionVector.y\n const xAtMinY = origin.x + tAtMinY * directionVector.x\n if (isWithin(xAtMinY, bounds.minX, bounds.maxX)) {\n intersections.push({ x: xAtMinY, y: bounds.minY })\n }\n\n const tAtMaxY = (bounds.maxY - origin.y) / directionVector.y\n const xAtMaxY = origin.x + tAtMaxY * directionVector.x\n if (isWithin(xAtMaxY, bounds.minX, bounds.maxX)) {\n intersections.push({ x: xAtMaxY, y: bounds.maxY })\n }\n }\n\n const uniqueIntersections = dedupePoints(intersections)\n\n if (uniqueIntersections.length < 2) {\n return null\n }\n\n let first = uniqueIntersections[0]\n let second = uniqueIntersections[1]\n let maxDistanceSquared = (first.x - second.x) ** 2 + (first.y - second.y) ** 2\n\n for (let i = 0; i < uniqueIntersections.length; i++) {\n for (let j = i + 1; j < uniqueIntersections.length; j++) {\n const a = uniqueIntersections[i]\n const b = uniqueIntersections[j]\n const distanceSquared = (a.x - b.x) ** 2 + (a.y - b.y) ** 2\n if (distanceSquared > maxDistanceSquared) {\n first = a\n second = b\n maxDistanceSquared = distanceSquared\n }\n }\n }\n\n return [first, second]\n}\n\nexport function getViewportBoundsFromMatrix(\n matrix: Matrix,\n width: number,\n height: number,\n): Viewbox {\n const screenToReal = inverse(matrix)\n const corners = [\n applyToPoint(screenToReal, { x: 0, y: 0 }),\n applyToPoint(screenToReal, { x: width, y: 0 }),\n applyToPoint(screenToReal, { x: 0, y: height }),\n applyToPoint(screenToReal, { x: width, y: height }),\n ]\n\n return {\n minX: Math.min(...corners.map((p) => p.x)),\n maxX: Math.max(...corners.map((p) => p.x)),\n minY: Math.min(...corners.map((p) => p.y)),\n maxY: Math.max(...corners.map((p) => p.y)),\n }\n}\n"],"mappings":";AAAA,SAAsB,cAAc,eAAe;AAGnD,IAAM,UAAU;AAEhB,IAAM,WAAW,CAAC,OAAe,KAAa,QAAgB;AAC5D,SAAO,SAAS,MAAM,WAAW,SAAS,MAAM;AAClD;AAEA,IAAM,eAAe,CAAC,WAAoB;AACxC,QAAM,SAAkB,CAAC;AACzB,aAAW,SAAS,QAAQ;AAC1B,QACE,CAAC,OAAO;AAAA,MACN,CAAC,UACC,KAAK,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,WAC9B,KAAK,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI;AAAA,IAClC,GACA;AACA,aAAO,KAAK,KAAK;AAAA,IACnB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,yBACd,cACA,QACuB;AACvB,QAAM,EAAE,QAAQ,gBAAgB,IAAI;AAEpC,MACE,KAAK,IAAI,gBAAgB,CAAC,IAAI,WAC9B,KAAK,IAAI,gBAAgB,CAAC,IAAI,SAC9B;AACA,WAAO;AAAA,EACT;AAEA,QAAM,gBAAyB,CAAC;AAEhC,MAAI,KAAK,IAAI,gBAAgB,CAAC,KAAK,SAAS;AAC1C,UAAM,WAAW,OAAO,OAAO,OAAO,KAAK,gBAAgB;AAC3D,UAAM,UAAU,OAAO,IAAI,UAAU,gBAAgB;AACrD,QAAI,SAAS,SAAS,OAAO,MAAM,OAAO,IAAI,GAAG;AAC/C,oBAAc,KAAK,EAAE,GAAG,OAAO,MAAM,GAAG,QAAQ,CAAC;AAAA,IACnD;AAEA,UAAM,W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kBAAkB,oBAAoB;AACxC,gBAAQ;AACR,iBAAS;AACT,6BAAqB;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,CAAC,OAAO,MAAM;AACvB;AAEO,SAAS,4BACd,QACA,OACA,QACS;AACT,QAAM,eAAe,QAAQ,MAAM;AACnC,QAAM,UAAU;AAAA,IACd,aAAa,cAAc,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;AAAA,IACzC,aAAa,cAAc,EAAE,GAAG,OAAO,GAAG,EAAE,CAAC;AAAA,IAC7C,aAAa,cAAc,EAAE,GAAG,GAAG,GAAG,OAAO,CAAC;AAAA,IAC9C,aAAa,cAAc,EAAE,GAAG,OAAO,GAAG,OAAO,CAAC;AAAA,EACpD;AAEA,SAAO;AAAA,IACL,MAAM,KAAK,IAAI,GAAG,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAAA,IACzC,MAAM,KAAK,IAAI,GAAG,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAAA,IACzC,MAAM,KAAK,IAAI,GAAG,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAAA,IACzC,MAAM,KAAK,IAAI,GAAG,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAAA,EAC3C;AACF;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-NG6H63SM.js";
|
|
4
4
|
import {
|
|
5
5
|
getSvgFromGraphicsObject
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZWAXHWX2.js";
|
|
7
7
|
|
|
8
8
|
// lib/index.ts
|
|
9
9
|
function getSvgFromLogString(logString) {
|
|
@@ -53,4 +53,4 @@ export {
|
|
|
53
53
|
getHtmlFromLogString,
|
|
54
54
|
getSvgsFromLogString
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
56
|
+
//# sourceMappingURL=chunk-HPNVGPHJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/index.ts"],"sourcesContent":["import {\n computeTransformFromViewbox,\n drawGraphicsToCanvas,\n getBounds,\n} from \"./drawGraphicsToCanvas\"\nimport { getGraphicsObjectsFromLogString } from \"./getGraphicsObjectsFromLogString\"\nimport { getSvgFromGraphicsObject } from \"./getSvgFromGraphicsObject\"\nimport { mergeGraphics } from \"./mergeGraphics\"\nimport { setStepOfAllObjects } from \"./setStepOfAllObjects\"\nimport {\n createGraphicsGrid,\n stackGraphicsHorizontally,\n stackGraphicsVertically,\n} from \"./stackGraphics\"\n\nexport type {\n Point,\n Line,\n InfiniteLine,\n Rect,\n Circle,\n Polygon,\n Arrow,\n Text,\n NinePointAnchor,\n GraphicsObject,\n Viewbox,\n CenterViewbox,\n TransformOptions,\n} from \"./types\"\nexport { getGraphicsObjectsFromLogString } from \"./getGraphicsObjectsFromLogString\"\nexport { getSvgFromGraphicsObject } from \"./getSvgFromGraphicsObject\"\nexport {\n drawGraphicsToCanvas,\n computeTransformFromViewbox,\n getBounds,\n} from \"./drawGraphicsToCanvas\"\nexport { translateGraphics } from \"./translateGraphics\"\nexport { mergeGraphics } from \"./mergeGraphics\"\nexport { setStepOfAllObjects } from \"./setStepOfAllObjects\"\nexport {\n stackGraphicsHorizontally,\n stackGraphicsVertically,\n createGraphicsGrid,\n} from \"./stackGraphics\"\nexport { FONT_SIZE_WIDTH_RATIO, FONT_SIZE_HEIGHT_RATIO } from \"./constants\"\n\nexport function getSvgFromLogString(logString: string): string {\n const objects = getGraphicsObjectsFromLogString(logString)\n if (objects.length === 0) return \"\"\n return getSvgFromGraphicsObject(objects[0])\n}\n\nexport function getHtmlFromLogString(logString: string): string {\n const svgs = getSvgsFromLogString(logString)\n if (svgs.length === 0) return \"\"\n\n const sections = svgs\n .map(\n ({ title, svg }) => `\n <section>\n <h2>${title}</h2>\n ${svg}\n </section>\n `,\n )\n .join(\"\\n\")\n\n return `\n<!DOCTYPE html>\n<html>\n<head>\n <title>Graphics Debug Output</title>\n <style>\n body { font-family: system-ui; max-width: 1200px; margin: 0 auto; padding: 20px; }\n h1 { color: #333; }\n section { margin: 40px 0; }\n svg { max-width: 100%; height: auto; border: 1px solid #eee; }\n </style>\n</head>\n<body>\n <h1>Graphics Debug Output</h1>\n ${sections}\n</body>\n</html>`\n}\n\nexport function getSvgsFromLogString(\n logString: string,\n): Array<{ title: string; svg: string }> {\n const objects = getGraphicsObjectsFromLogString(logString)\n return objects.map((obj) => ({\n title: obj.title || \"Untitled Graphic\",\n svg: getSvgFromGraphicsObject(obj),\n }))\n}\n"],"mappings":";;;;;;;;AA+CO,SAAS,oBAAoB,WAA2B;AAC7D,QAAM,UAAU,gCAAgC,SAAS;AACzD,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,SAAO,yBAAyB,QAAQ,CAAC,CAAC;AAC5C;AAEO,SAAS,qBAAqB,WAA2B;AAC9D,QAAM,OAAO,qBAAqB,SAAS;AAC3C,MAAI,KAAK,WAAW,EAAG,QAAO;AAE9B,QAAM,WAAW,KACd;AAAA,IACC,CAAC,EAAE,OAAO,IAAI,MAAM;AAAA;AAAA,YAEd,KAAK;AAAA,QACT,GAAG;AAAA;AAAA;AAAA,EAGP,EACC,KAAK,IAAI;AAEZ,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcL,QAAQ;AAAA;AAAA;AAGZ;AAEO,SAAS,qBACd,WACuC;AACvC,QAAM,UAAU,gCAAgC,SAAS;AACzD,SAAO,QAAQ,IAAI,CAAC,SAAS;AAAA,IAC3B,OAAO,IAAI,SAAS;AAAA,IACpB,KAAK,yBAAyB,GAAG;AAAA,EACnC,EAAE;AACJ;","names":[]}
|
|
@@ -5,6 +5,10 @@ var mergeGraphics = (graphics1, graphics2) => {
|
|
|
5
5
|
rects: [...graphics1.rects ?? [], ...graphics2.rects ?? []],
|
|
6
6
|
points: [...graphics1.points ?? [], ...graphics2.points ?? []],
|
|
7
7
|
lines: [...graphics1.lines ?? [], ...graphics2.lines ?? []],
|
|
8
|
+
infiniteLines: [
|
|
9
|
+
...graphics1.infiniteLines ?? [],
|
|
10
|
+
...graphics2.infiniteLines ?? []
|
|
11
|
+
],
|
|
8
12
|
polygons: [...graphics1.polygons ?? [], ...graphics2.polygons ?? []],
|
|
9
13
|
circles: [...graphics1.circles ?? [], ...graphics2.circles ?? []],
|
|
10
14
|
arrows: [...graphics1.arrows ?? [], ...graphics2.arrows ?? []],
|
|
@@ -15,4 +19,4 @@ var mergeGraphics = (graphics1, graphics2) => {
|
|
|
15
19
|
export {
|
|
16
20
|
mergeGraphics
|
|
17
21
|
};
|
|
18
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-K37Y2KHE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/mergeGraphics.ts"],"sourcesContent":["import type { GraphicsObject } from \"./types\"\n\nexport const mergeGraphics = (\n graphics1: GraphicsObject,\n graphics2: GraphicsObject,\n): GraphicsObject => {\n return {\n ...graphics1,\n rects: [...(graphics1.rects ?? []), ...(graphics2.rects ?? [])],\n points: [...(graphics1.points ?? []), ...(graphics2.points ?? [])],\n lines: [...(graphics1.lines ?? []), ...(graphics2.lines ?? [])],\n infiniteLines: [\n ...(graphics1.infiniteLines ?? []),\n ...(graphics2.infiniteLines ?? []),\n ],\n polygons: [...(graphics1.polygons ?? []), ...(graphics2.polygons ?? [])],\n circles: [...(graphics1.circles ?? []), ...(graphics2.circles ?? [])],\n arrows: [...(graphics1.arrows ?? []), ...(graphics2.arrows ?? [])],\n texts: [...(graphics1.texts ?? []), ...(graphics2.texts ?? [])],\n }\n}\n"],"mappings":";AAEO,IAAM,gBAAgB,CAC3B,WACA,cACmB;AACnB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,CAAC,GAAI,UAAU,SAAS,CAAC,GAAI,GAAI,UAAU,SAAS,CAAC,CAAE;AAAA,IAC9D,QAAQ,CAAC,GAAI,UAAU,UAAU,CAAC,GAAI,GAAI,UAAU,UAAU,CAAC,CAAE;AAAA,IACjE,OAAO,CAAC,GAAI,UAAU,SAAS,CAAC,GAAI,GAAI,UAAU,SAAS,CAAC,CAAE;AAAA,IAC9D,eAAe;AAAA,MACb,GAAI,UAAU,iBAAiB,CAAC;AAAA,MAChC,GAAI,UAAU,iBAAiB,CAAC;AAAA,IAClC;AAAA,IACA,UAAU,CAAC,GAAI,UAAU,YAAY,CAAC,GAAI,GAAI,UAAU,YAAY,CAAC,CAAE;AAAA,IACvE,SAAS,CAAC,GAAI,UAAU,WAAW,CAAC,GAAI,GAAI,UAAU,WAAW,CAAC,CAAE;AAAA,IACpE,QAAQ,CAAC,GAAI,UAAU,UAAU,CAAC,GAAI,GAAI,UAAU,UAAU,CAAC,CAAE;AAAA,IACjE,OAAO,CAAC,GAAI,UAAU,SAAS,CAAC,GAAI,GAAI,UAAU,SAAS,CAAC,CAAE;AAAA,EAChE;AACF;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mergeGraphics
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-K37Y2KHE.js";
|
|
4
4
|
import {
|
|
5
5
|
translateGraphics
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7236NVI2.js";
|
|
7
7
|
import {
|
|
8
8
|
getBounds
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AKONCUCE.js";
|
|
10
10
|
|
|
11
11
|
// lib/stackGraphics.ts
|
|
12
12
|
function stackGraphicsHorizontally(graphicsList, opts = {}) {
|
|
@@ -118,4 +118,4 @@ export {
|
|
|
118
118
|
stackGraphicsVertically,
|
|
119
119
|
createGraphicsGrid
|
|
120
120
|
};
|
|
121
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-MYMDOAQN.js.map
|
|
@@ -10,6 +10,11 @@ function setStepOfAllObjects(graphics, step) {
|
|
|
10
10
|
line.step = step;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
if (graphics.infiniteLines) {
|
|
14
|
+
for (const infiniteLine of graphics.infiniteLines) {
|
|
15
|
+
infiniteLine.step = step;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
13
18
|
if (graphics.polygons) {
|
|
14
19
|
for (const polygon of graphics.polygons) {
|
|
15
20
|
polygon.step = step;
|
|
@@ -36,4 +41,4 @@ function setStepOfAllObjects(graphics, step) {
|
|
|
36
41
|
export {
|
|
37
42
|
setStepOfAllObjects
|
|
38
43
|
};
|
|
39
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-OB4CGOL3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/setStepOfAllObjects.ts"],"sourcesContent":["import type { GraphicsObject } from \"./types\"\n\nexport function setStepOfAllObjects(\n graphics: GraphicsObject,\n step: number,\n): GraphicsObject {\n if (graphics.points) {\n for (const p of graphics.points) {\n p.step = step\n }\n }\n if (graphics.lines) {\n for (const line of graphics.lines) {\n line.step = step\n }\n }\n if (graphics.infiniteLines) {\n for (const infiniteLine of graphics.infiniteLines) {\n infiniteLine.step = step\n }\n }\n if (graphics.polygons) {\n for (const polygon of graphics.polygons) {\n polygon.step = step\n }\n }\n if (graphics.rects) {\n for (const rect of graphics.rects) {\n rect.step = step\n }\n }\n if (graphics.circles) {\n for (const circle of graphics.circles) {\n circle.step = step\n }\n }\n if (graphics.texts) {\n for (const text of graphics.texts) {\n text.step = step\n }\n }\n return graphics\n}\n"],"mappings":";AAEO,SAAS,oBACd,UACA,MACgB;AAChB,MAAI,SAAS,QAAQ;AACnB,eAAW,KAAK,SAAS,QAAQ;AAC/B,QAAE,OAAO;AAAA,IACX;AAAA,EACF;AACA,MAAI,SAAS,OAAO;AAClB,eAAW,QAAQ,SAAS,OAAO;AACjC,WAAK,OAAO;AAAA,IACd;AAAA,EACF;AACA,MAAI,SAAS,eAAe;AAC1B,eAAW,gBAAgB,SAAS,eAAe;AACjD,mBAAa,OAAO;AAAA,IACtB;AAAA,EACF;AACA,MAAI,SAAS,UAAU;AACrB,eAAW,WAAW,SAAS,UAAU;AACvC,cAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AACA,MAAI,SAAS,OAAO;AAClB,eAAW,QAAQ,SAAS,OAAO;AACjC,WAAK,OAAO;AAAA,IACd;AAAA,EACF;AACA,MAAI,SAAS,SAAS;AACpB,eAAW,UAAU,SAAS,SAAS;AACrC,aAAO,OAAO;AAAA,IAChB;AAAA,EACF;AACA,MAAI,SAAS,OAAO;AAClB,eAAW,QAAQ,SAAS,OAAO;AACjC,WAAK,OAAO;AAAA,IACd;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -6,15 +6,18 @@ import {
|
|
|
6
6
|
FONT_SIZE_HEIGHT_RATIO,
|
|
7
7
|
FONT_SIZE_WIDTH_RATIO
|
|
8
8
|
} from "./chunk-ZGI74PYD.js";
|
|
9
|
+
import {
|
|
10
|
+
clipInfiniteLineToBounds
|
|
11
|
+
} from "./chunk-FLFF6QXL.js";
|
|
9
12
|
|
|
10
13
|
// lib/getSvgFromGraphicsObject.ts
|
|
14
|
+
import { stringify } from "svgson";
|
|
11
15
|
import {
|
|
16
|
+
applyToPoint,
|
|
12
17
|
compose,
|
|
13
|
-
translate,
|
|
14
18
|
scale,
|
|
15
|
-
|
|
19
|
+
translate
|
|
16
20
|
} from "transformation-matrix";
|
|
17
|
-
import { stringify } from "svgson";
|
|
18
21
|
var DEFAULT_SVG_SIZE = 640;
|
|
19
22
|
var PADDING = 40;
|
|
20
23
|
function getBounds(graphics) {
|
|
@@ -229,6 +232,55 @@ function getSvgFromGraphicsObject(graphics, {
|
|
|
229
232
|
]
|
|
230
233
|
};
|
|
231
234
|
}),
|
|
235
|
+
...(graphics.infiniteLines || []).flatMap((line) => {
|
|
236
|
+
const segment = clipInfiniteLineToBounds(line, bounds);
|
|
237
|
+
if (!segment) return [];
|
|
238
|
+
const [start, end] = segment;
|
|
239
|
+
const projectedStart = projectPoint(start, matrix);
|
|
240
|
+
const projectedEnd = projectPoint(end, matrix);
|
|
241
|
+
return [
|
|
242
|
+
{
|
|
243
|
+
name: "g",
|
|
244
|
+
type: "element",
|
|
245
|
+
attributes: {},
|
|
246
|
+
children: [
|
|
247
|
+
{
|
|
248
|
+
name: "line",
|
|
249
|
+
type: "element",
|
|
250
|
+
attributes: {
|
|
251
|
+
"data-type": "infinite-line",
|
|
252
|
+
"data-label": line.label || "",
|
|
253
|
+
"data-origin": `${line.origin.x},${line.origin.y}`,
|
|
254
|
+
"data-direction": `${line.directionVector.x},${line.directionVector.y}`,
|
|
255
|
+
x1: projectedStart.x.toString(),
|
|
256
|
+
y1: projectedStart.y.toString(),
|
|
257
|
+
x2: projectedEnd.x.toString(),
|
|
258
|
+
y2: projectedEnd.y.toString(),
|
|
259
|
+
stroke: line.strokeColor || "black",
|
|
260
|
+
"stroke-width": !line.strokeWidth ? "1px" : typeof line.strokeWidth === "string" ? line.strokeWidth : (strokeScale * line.strokeWidth).toString(),
|
|
261
|
+
...line.strokeDash && {
|
|
262
|
+
"stroke-dasharray": Array.isArray(line.strokeDash) ? line.strokeDash.join(" ") : line.strokeDash
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
...shouldRenderLabel("infiniteLines") && line.label ? [
|
|
267
|
+
{
|
|
268
|
+
name: "text",
|
|
269
|
+
type: "element",
|
|
270
|
+
attributes: {
|
|
271
|
+
x: ((projectedStart.x + projectedEnd.x) / 2 + 5).toString(),
|
|
272
|
+
y: ((projectedStart.y + projectedEnd.y) / 2 - 5).toString(),
|
|
273
|
+
"font-family": "sans-serif",
|
|
274
|
+
"font-size": "12",
|
|
275
|
+
fill: line.strokeColor || "black"
|
|
276
|
+
},
|
|
277
|
+
children: [{ type: "text", value: line.label }]
|
|
278
|
+
}
|
|
279
|
+
] : []
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
];
|
|
283
|
+
}),
|
|
232
284
|
// Rectangles
|
|
233
285
|
...(graphics.rects || []).map((rect) => {
|
|
234
286
|
const corner1 = {
|
|
@@ -557,4 +609,4 @@ function getSvgFromGraphicsObject(graphics, {
|
|
|
557
609
|
export {
|
|
558
610
|
getSvgFromGraphicsObject
|
|
559
611
|
};
|
|
560
|
-
//# sourceMappingURL=chunk-
|
|
612
|
+
//# sourceMappingURL=chunk-ZWAXHWX2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/getSvgFromGraphicsObject.ts"],"sourcesContent":["import { stringify } from \"svgson\"\nimport {\n type Matrix,\n applyToPoint,\n compose,\n identity,\n scale,\n transform,\n translate,\n} from \"transformation-matrix\"\nimport { getArrowBoundingBox, getArrowGeometry } from \"./arrowHelpers\"\nimport { FONT_SIZE_HEIGHT_RATIO, FONT_SIZE_WIDTH_RATIO } from \"./constants\"\nimport { clipInfiniteLineToBounds } from \"./infiniteLineHelpers\"\nimport type { GraphicsObject, Point } from \"./types\"\n\nconst DEFAULT_SVG_SIZE = 640\nconst PADDING = 40\n\ninterface Bounds {\n minX: number\n maxX: number\n minY: number\n maxY: number\n}\n\nfunction getBounds(graphics: GraphicsObject): Bounds {\n const points: Point[] = [\n ...(graphics.points || []),\n ...(graphics.lines || []).flatMap((line) => line.points),\n ...(graphics.polygons || []).flatMap((polygon) => polygon.points),\n ...(graphics.rects || []).flatMap((rect) => {\n const halfWidth = rect.width / 2\n const halfHeight = rect.height / 2\n return [\n { x: rect.center.x - halfWidth, y: rect.center.y - halfHeight },\n { x: rect.center.x + halfWidth, y: rect.center.y - halfHeight },\n { x: rect.center.x - halfWidth, y: rect.center.y + halfHeight },\n { x: rect.center.x + halfWidth, y: rect.center.y + halfHeight },\n ]\n }),\n ...(graphics.circles || []).flatMap((circle) => [\n { x: circle.center.x - circle.radius, y: circle.center.y }, // left\n { x: circle.center.x + circle.radius, y: circle.center.y }, // right\n { x: circle.center.x, y: circle.center.y - circle.radius }, // top\n { x: circle.center.x, y: circle.center.y + circle.radius }, // bottom\n ]),\n ...(graphics.arrows || []).flatMap((arrow) => {\n const bounds = getArrowBoundingBox(arrow)\n return [\n { x: bounds.minX, y: bounds.minY },\n { x: bounds.maxX, y: bounds.maxY },\n ]\n }),\n ...(graphics.texts || []).flatMap((t) => {\n const fontSize = t.fontSize ?? 12\n const width = t.text.length * fontSize * FONT_SIZE_WIDTH_RATIO\n const height = fontSize * FONT_SIZE_HEIGHT_RATIO\n const anchor = t.anchorSide ?? \"center\"\n const offsetMap: Record<string, { dx: number; dy: number }> = {\n top_left: { dx: 0, dy: 0 },\n top_center: { dx: -width / 2, dy: 0 },\n top_right: { dx: -width, dy: 0 },\n center_left: { dx: 0, dy: -height / 2 },\n center: { dx: -width / 2, dy: -height / 2 },\n center_right: { dx: -width, dy: -height / 2 },\n bottom_left: { dx: 0, dy: -height },\n bottom_center: { dx: -width / 2, dy: -height },\n bottom_right: { dx: -width, dy: -height },\n }\n const { dx, dy } = offsetMap[anchor]\n const x0 = t.x + dx\n const y0 = t.y + dy\n return [\n { x: x0, y: y0 },\n { x: x0 + width, y: y0 + height },\n ]\n }),\n ]\n\n if (points.length === 0) {\n return { minX: -1, maxX: 1, minY: -1, maxY: 1 }\n }\n\n return points.reduce(\n (bounds, point) => ({\n minX: Math.min(bounds.minX, point.x),\n maxX: Math.max(bounds.maxX, point.x),\n minY: Math.min(bounds.minY, point.y),\n maxY: Math.max(bounds.maxY, point.y),\n }),\n { minX: Infinity, maxX: -Infinity, minY: Infinity, maxY: -Infinity },\n )\n}\n\nfunction getProjectionMatrix(\n bounds: Bounds,\n coordinateSystem: GraphicsObject[\"coordinateSystem\"],\n svgWidth: number,\n svgHeight: number,\n) {\n const width = bounds.maxX - bounds.minX || 1\n const height = bounds.maxY - bounds.minY || 1\n\n const scale_factor = Math.min(\n (svgWidth - 2 * PADDING) / width,\n (svgHeight - 2 * PADDING) / height,\n )\n\n const yFlip = coordinateSystem === \"screen\" ? 1 : -1\n\n return compose(\n translate(svgWidth / 2, svgHeight / 2),\n scale(scale_factor, yFlip * scale_factor),\n translate(-(bounds.minX + width / 2), -(bounds.minY + height / 2)),\n )\n}\n\nfunction projectPoint(point: Point, matrix: Matrix) {\n const projected = applyToPoint(matrix, { x: point.x, y: point.y })\n return { ...point, ...projected }\n}\n\nexport function getSvgFromGraphicsObject(\n graphics: GraphicsObject,\n {\n includeTextLabels = false,\n backgroundColor = \"white\",\n svgWidth = DEFAULT_SVG_SIZE,\n svgHeight = DEFAULT_SVG_SIZE,\n }: {\n includeTextLabels?:\n | boolean\n | Array<\"points\" | \"lines\" | \"infiniteLines\" | \"rects\" | \"polygons\">\n backgroundColor?: string | null\n svgWidth?: number\n svgHeight?: number\n } = {},\n): string {\n const bounds = getBounds(graphics)\n const matrix = getProjectionMatrix(\n bounds,\n graphics.coordinateSystem,\n svgWidth,\n svgHeight,\n )\n const strokeScale = Math.abs(matrix.a)\n\n const shouldRenderLabel = (\n type: \"points\" | \"lines\" | \"infiniteLines\" | \"rects\" | \"polygons\",\n ): boolean => {\n if (typeof includeTextLabels === \"boolean\") {\n return includeTextLabels\n }\n if (Array.isArray(includeTextLabels)) {\n return includeTextLabels.includes(type)\n }\n return false\n }\n\n const svgObject = {\n name: \"svg\",\n type: \"element\",\n attributes: {\n width: svgWidth.toString(),\n height: svgHeight.toString(),\n viewBox: `0 0 ${svgWidth} ${svgHeight}`,\n xmlns: \"http://www.w3.org/2000/svg\",\n },\n children: [\n // Background rectangle (optional)\n ...(backgroundColor\n ? [\n {\n name: \"rect\",\n type: \"element\",\n attributes: {\n width: \"100%\",\n height: \"100%\",\n fill: backgroundColor,\n },\n },\n ]\n : []),\n // Points\n ...(graphics.points || []).map((point) => {\n const projected = projectPoint(point, matrix)\n return {\n name: \"g\",\n type: \"element\",\n attributes: {},\n children: [\n {\n name: \"circle\",\n type: \"element\",\n attributes: {\n \"data-type\": \"point\",\n \"data-label\": point.label || \"\",\n \"data-x\": point.x.toString(),\n \"data-y\": point.y.toString(),\n cx: projected.x.toString(),\n cy: projected.y.toString(),\n r: \"3\",\n fill: point.color || \"black\",\n },\n },\n ...(shouldRenderLabel(\"points\") && point.label\n ? [\n {\n name: \"text\",\n type: \"element\",\n attributes: {\n x: (projected.x + 5).toString(),\n y: (projected.y - 5).toString(),\n \"font-family\": \"sans-serif\",\n \"font-size\": \"12\",\n },\n children: [{ type: \"text\", value: point.label }],\n },\n ]\n : []),\n ],\n }\n }),\n // Lines\n ...(graphics.lines || []).map((line) => {\n const projectedPoints = line.points.map((p) => projectPoint(p, matrix))\n return {\n name: \"g\",\n type: \"element\",\n attributes: {},\n children: [\n {\n name: \"polyline\",\n type: \"element\",\n attributes: {\n \"data-points\": line.points\n .map((p) => `${p.x},${p.y}`)\n .join(\" \"),\n \"data-type\": \"line\",\n \"data-label\": line.label || \"\",\n points: projectedPoints.map((p) => `${p.x},${p.y}`).join(\" \"),\n fill: \"none\",\n stroke: line.strokeColor || \"black\",\n \"stroke-width\": !line.strokeWidth\n ? \"1px\"\n : typeof line.strokeWidth === \"string\"\n ? line.strokeWidth\n : (strokeScale * line.strokeWidth).toString(),\n ...(line.strokeDash && {\n \"stroke-dasharray\": Array.isArray(line.strokeDash)\n ? line.strokeDash.join(\" \")\n : line.strokeDash,\n }),\n },\n },\n ...(shouldRenderLabel(\"lines\") &&\n line.label &&\n projectedPoints.length > 0\n ? [\n {\n name: \"text\",\n type: \"element\",\n attributes: {\n x: (projectedPoints[0].x + 5).toString(),\n y: (projectedPoints[0].y - 5).toString(),\n \"font-family\": \"sans-serif\",\n \"font-size\": \"12\",\n fill: line.strokeColor || \"black\",\n },\n children: [{ type: \"text\", value: line.label }],\n },\n ]\n : []),\n ],\n }\n }),\n ...(graphics.infiniteLines || []).flatMap((line) => {\n const segment = clipInfiniteLineToBounds(line, bounds)\n if (!segment) return []\n\n const [start, end] = segment\n const projectedStart = projectPoint(start, matrix)\n const projectedEnd = projectPoint(end, matrix)\n\n return [\n {\n name: \"g\",\n type: \"element\",\n attributes: {},\n children: [\n {\n name: \"line\",\n type: \"element\",\n attributes: {\n \"data-type\": \"infinite-line\",\n \"data-label\": line.label || \"\",\n \"data-origin\": `${line.origin.x},${line.origin.y}`,\n \"data-direction\": `${line.directionVector.x},${line.directionVector.y}`,\n x1: projectedStart.x.toString(),\n y1: projectedStart.y.toString(),\n x2: projectedEnd.x.toString(),\n y2: projectedEnd.y.toString(),\n stroke: line.strokeColor || \"black\",\n \"stroke-width\": !line.strokeWidth\n ? \"1px\"\n : typeof line.strokeWidth === \"string\"\n ? line.strokeWidth\n : (strokeScale * line.strokeWidth).toString(),\n ...(line.strokeDash && {\n \"stroke-dasharray\": Array.isArray(line.strokeDash)\n ? line.strokeDash.join(\" \")\n : line.strokeDash,\n }),\n },\n },\n ...(shouldRenderLabel(\"infiniteLines\") && line.label\n ? [\n {\n name: \"text\",\n type: \"element\",\n attributes: {\n x: (\n (projectedStart.x + projectedEnd.x) / 2 +\n 5\n ).toString(),\n y: (\n (projectedStart.y + projectedEnd.y) / 2 -\n 5\n ).toString(),\n \"font-family\": \"sans-serif\",\n \"font-size\": \"12\",\n fill: line.strokeColor || \"black\",\n },\n children: [{ type: \"text\", value: line.label }],\n },\n ]\n : []),\n ],\n },\n ]\n }),\n // Rectangles\n ...(graphics.rects || []).map((rect) => {\n const corner1 = {\n x: rect.center.x - rect.width / 2,\n y: rect.center.y - rect.height / 2,\n }\n const projectedCorner1 = projectPoint(corner1, matrix)\n const corner2 = {\n x: rect.center.x + rect.width / 2,\n y: rect.center.y + rect.height / 2,\n }\n const projectedCorner2 = projectPoint(corner2, matrix)\n const scaledWidth = Math.abs(projectedCorner2.x - projectedCorner1.x)\n const scaledHeight = Math.abs(projectedCorner2.y - projectedCorner1.y)\n const rectX = Math.min(projectedCorner1.x, projectedCorner2.x)\n const rectY = Math.min(projectedCorner1.y, projectedCorner2.y)\n\n return {\n name: \"g\",\n type: \"element\",\n attributes: {},\n children: [\n {\n name: \"rect\",\n type: \"element\",\n attributes: {\n \"data-type\": \"rect\",\n \"data-label\": rect.label || \"\",\n \"data-x\": rect.center.x.toString(),\n \"data-y\": rect.center.y.toString(),\n x: rectX.toString(),\n y: rectY.toString(),\n width: scaledWidth.toString(),\n height: scaledHeight.toString(),\n fill: rect.fill || \"none\",\n stroke: rect.stroke || \"black\",\n \"stroke-width\": Math.abs(1 / matrix.a).toString(), // Consider scaling stroke width like lines if needed\n },\n },\n ...(shouldRenderLabel(\"rects\") && rect.label\n ? [\n {\n name: \"text\",\n type: \"element\",\n attributes: {\n x: (rectX + 5).toString(),\n y: rectY.toString(),\n \"font-family\": \"sans-serif\",\n \"dominant-baseline\": \"text-before-edge\",\n \"font-size\": (\n ((scaledWidth + scaledHeight) / 2) *\n 0.06\n ).toString(),\n fill: rect.stroke || \"black\", // Default to stroke color for label\n },\n children: [{ type: \"text\", value: rect.label }],\n },\n ]\n : []),\n ],\n }\n }),\n // Polygons\n ...(graphics.polygons || []).map((polygon) => {\n const projectedPoints = polygon.points.map((point) =>\n projectPoint(point, matrix),\n )\n const xs = projectedPoints.map((p) => p.x)\n const ys = projectedPoints.map((p) => p.y)\n const minX = xs.length > 0 ? Math.min(...xs) : 0\n const minY = ys.length > 0 ? Math.min(...ys) : 0\n const polygonStrokeWidth =\n polygon.strokeWidth === undefined\n ? Math.abs(1 / matrix.a)\n : strokeScale * polygon.strokeWidth\n\n return {\n name: \"g\",\n type: \"element\",\n attributes: {},\n children: [\n {\n name: \"polygon\",\n type: \"element\",\n attributes: {\n \"data-type\": \"polygon\",\n \"data-label\": polygon.label || \"\",\n \"data-points\": polygon.points\n .map((p) => `${p.x},${p.y}`)\n .join(\" \"),\n points: projectedPoints.map((p) => `${p.x},${p.y}`).join(\" \"),\n fill: polygon.fill || \"none\",\n stroke: polygon.stroke || \"black\",\n \"stroke-width\": polygonStrokeWidth.toString(),\n },\n },\n ...(shouldRenderLabel(\"polygons\") && polygon.label\n ? [\n {\n name: \"text\",\n type: \"element\",\n attributes: {\n x: (minX + 5).toString(),\n y: minY.toString(),\n \"font-family\": \"sans-serif\",\n \"dominant-baseline\": \"text-before-edge\",\n \"font-size\": \"12\",\n fill: polygon.stroke || \"black\",\n },\n children: [{ type: \"text\", value: polygon.label }],\n },\n ]\n : []),\n ],\n }\n }),\n // Circles\n ...(graphics.circles || []).map((circle) => {\n const projected = projectPoint(circle.center, matrix)\n const scaledRadius = circle.radius * Math.abs(matrix.a)\n return {\n name: \"circle\",\n type: \"element\",\n attributes: {\n \"data-type\": \"circle\",\n \"data-label\": \"\",\n \"data-x\": circle.center.x.toString(),\n \"data-y\": circle.center.y.toString(),\n cx: projected.x.toString(),\n cy: projected.y.toString(),\n r: scaledRadius.toString(),\n fill: circle.fill || \"none\",\n stroke: circle.stroke || \"black\",\n \"stroke-width\": Math.abs(1 / matrix.a).toString(),\n },\n }\n }),\n ...(graphics.arrows || []).map((arrow) => {\n const geometry = getArrowGeometry(arrow)\n const projectedShaftStart = projectPoint(geometry.shaftStart, matrix)\n const projectedShaftEnd = projectPoint(geometry.shaftEnd, matrix)\n\n const color = arrow.color || \"black\"\n\n const headChildren = geometry.heads.map((head) => {\n const projectedTip = projectPoint(head.tip, matrix)\n const projectedLeftWing = projectPoint(head.leftWing, matrix)\n const projectedRightWing = projectPoint(head.rightWing, matrix)\n\n return {\n name: \"polygon\",\n type: \"element\",\n attributes: {\n \"data-type\": \"arrow-head\",\n points: [\n `${projectedTip.x},${projectedTip.y}`,\n `${projectedLeftWing.x},${projectedLeftWing.y}`,\n `${projectedRightWing.x},${projectedRightWing.y}`,\n ].join(\" \"),\n fill: color,\n },\n }\n })\n\n const children = [\n {\n name: \"line\",\n type: \"element\",\n attributes: {\n \"data-type\": \"arrow-shaft\",\n x1: projectedShaftStart.x.toString(),\n y1: projectedShaftStart.y.toString(),\n x2: projectedShaftEnd.x.toString(),\n y2: projectedShaftEnd.y.toString(),\n stroke: color,\n \"stroke-width\": geometry.shaftWidth.toString(),\n \"stroke-linecap\": \"round\",\n },\n },\n ...headChildren,\n ]\n\n return {\n name: \"g\",\n type: \"element\",\n attributes: {\n \"data-type\": \"arrow\",\n \"data-start\": `${arrow.start.x},${arrow.start.y}`,\n \"data-end\": `${arrow.end.x},${arrow.end.y}`,\n \"data-double-sided\": arrow.doubleSided ? \"true\" : \"false\",\n },\n children,\n }\n }),\n // Texts\n ...(graphics.texts || []).map((txt) => {\n const projected = projectPoint({ x: txt.x, y: txt.y }, matrix)\n const anchor = txt.anchorSide ?? \"center\"\n const alignMap: Record<string, string> = {\n top_left: \"start\",\n center_left: \"start\",\n bottom_left: \"start\",\n top_center: \"middle\",\n center: \"middle\",\n bottom_center: \"middle\",\n top_right: \"end\",\n center_right: \"end\",\n bottom_right: \"end\",\n }\n const baselineMap: Record<string, string> = {\n top_left: \"text-before-edge\",\n top_center: \"text-before-edge\",\n top_right: \"text-before-edge\",\n center_left: \"central\",\n center: \"central\",\n center_right: \"central\",\n bottom_left: \"text-after-edge\",\n bottom_center: \"text-after-edge\",\n bottom_right: \"text-after-edge\",\n }\n return {\n name: \"text\",\n type: \"element\",\n attributes: {\n \"data-type\": \"text\",\n \"data-label\": txt.text,\n \"data-x\": txt.x.toString(),\n \"data-y\": txt.y.toString(),\n x: projected.x.toString(),\n y: projected.y.toString(),\n fill: txt.color || \"black\",\n \"font-size\": ((txt.fontSize ?? 12) * Math.abs(matrix.a)).toString(),\n \"font-family\": \"sans-serif\",\n \"text-anchor\": alignMap[anchor],\n \"dominant-baseline\": baselineMap[anchor],\n },\n children: [{ type: \"text\", value: txt.text }],\n }\n }),\n // Crosshair lines and coordinates (initially hidden)\n {\n name: \"g\",\n type: \"element\",\n attributes: {\n id: \"crosshair\",\n style: \"display: none\",\n },\n children: [\n {\n name: \"line\",\n type: \"element\",\n attributes: {\n id: \"crosshair-h\",\n y1: \"0\",\n y2: svgHeight.toString(),\n stroke: \"#666\",\n \"stroke-width\": \"0.5\",\n },\n },\n {\n name: \"line\",\n type: \"element\",\n attributes: {\n id: \"crosshair-v\",\n x1: \"0\",\n x2: svgWidth.toString(),\n stroke: \"#666\",\n \"stroke-width\": \"0.5\",\n },\n },\n {\n name: \"text\",\n type: \"element\",\n attributes: {\n id: \"coordinates\",\n \"font-family\": \"monospace\",\n \"font-size\": \"12\",\n fill: \"#666\",\n },\n children: [{ type: \"text\", value: \"\" }],\n },\n ],\n },\n // Mouse tracking script\n {\n name: \"script\",\n type: \"element\",\n children: [\n {\n type: \"text\",\n value: `\n document.currentScript.parentElement.addEventListener('mousemove', (e) => {\n const svg = e.currentTarget;\n const rect = svg.getBoundingClientRect();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n const crosshair = svg.getElementById('crosshair');\n const h = svg.getElementById('crosshair-h');\n const v = svg.getElementById('crosshair-v');\n const coords = svg.getElementById('coordinates');\n \n crosshair.style.display = 'block';\n h.setAttribute('x1', '0');\n h.setAttribute('x2', '${svgWidth}');\n h.setAttribute('y1', y);\n h.setAttribute('y2', y);\n v.setAttribute('x1', x);\n v.setAttribute('x2', x);\n v.setAttribute('y1', '0');\n v.setAttribute('y2', '${svgHeight}');\n\n // Calculate real coordinates using inverse transformation\n const matrix = ${JSON.stringify(matrix)};\n // Manually invert and apply the affine transform\n // Since we only use translate and scale, we can directly compute:\n // x' = (x - tx) / sx\n // y' = (y - ty) / sy\n const sx = matrix.a;\n const sy = matrix.d;\n const tx = matrix.e; \n const ty = matrix.f;\n const realPoint = {\n x: (x - tx) / sx,\n y: (y - ty) / sy // Flip y back since we used negative scale\n }\n \n coords.textContent = \\`(\\${realPoint.x.toFixed(2)}, \\${realPoint.y.toFixed(2)})\\`;\n coords.setAttribute('x', (x + 5).toString());\n coords.setAttribute('y', (y - 5).toString());\n });\n document.currentScript.parentElement.addEventListener('mouseleave', () => {\n document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';\n });\n `,\n },\n ],\n },\n ],\n }\n\n //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,IAAI;AAAA,cACJ,IAAI,UAAU,SAAS;AAAA,cACvB,QAAQ;AAAA,cACR,gBAAgB;AAAA,YAClB;AAAA,UACF;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,YAAY;AAAA,cACV,IAAI;AAAA,cACJ,IAAI;AAAA,cACJ,IAAI,SAAS,SAAS;AAAA,cACtB,QAAQ;AAAA,cACR,gBAAgB;AAAA,YAClB;AAAA,UACF;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,YAAY;AAAA,cACV,IAAI;AAAA,cACJ,eAAe;AAAA,cACf,aAAa;AAAA,cACb,MAAM;AAAA,YACR;AAAA,YACA,UAAU,CAAC,EAAE,MAAM,QAAQ,OAAO,GAAG,CAAC;AAAA,UACxC;AAAA,QACF;AAAA,MACF;AAAA;AAAA,MAEA;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,UAAU;AAAA,UACR;AAAA,YACE,MAAM;AAAA,YACN,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAaqB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAMR,SAAS;AAAA;AAAA;AAAA,iCAGhB,KAAK,UAAU,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAsB7C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,SAAO,UAAU,SAAgB;AACnC;","names":[]}
|
package/dist/cli/cli.js
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
import {
|
|
3
3
|
getHtmlFromLogString,
|
|
4
4
|
getSvgsFromLogString
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-HPNVGPHJ.js";
|
|
6
|
+
import "../chunk-OB4CGOL3.js";
|
|
7
|
+
import "../chunk-MYMDOAQN.js";
|
|
8
|
+
import "../chunk-K37Y2KHE.js";
|
|
9
|
+
import "../chunk-7236NVI2.js";
|
|
10
|
+
import "../chunk-AKONCUCE.js";
|
|
11
11
|
import {
|
|
12
12
|
getGraphicsObjectsFromLogString
|
|
13
13
|
} from "../chunk-NG6H63SM.js";
|
|
14
|
-
import "../chunk-
|
|
14
|
+
import "../chunk-ZWAXHWX2.js";
|
|
15
15
|
import "../chunk-IOVKI3ZO.js";
|
|
16
16
|
import "../chunk-ZGI74PYD.js";
|
|
17
|
+
import "../chunk-FLFF6QXL.js";
|
|
17
18
|
|
|
18
19
|
// cli/cli.ts
|
|
19
20
|
import { parseArgs } from "util";
|
package/dist/cli/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../cli/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\"\nimport { readFileSync } from \"node:fs\"\nimport { writeFileSync } from \"node:fs\"\nimport {\n getSvgsFromLogString,\n getHtmlFromLogString,\n getGraphicsObjectsFromLogString,\n} from \"../lib\"\n\nasync function getInput(): Promise<string> {\n // Check if there's data being piped in\n if (process.stdin.isTTY && process.stderr.isTTY) {\n console.error(\n \"Error: No input provided. Pipe in content with graphics objects.\",\n )\n process.exit(1)\n }\n\n const chunks = []\n\n // Read from stdin if available\n if (!process.stdin.isTTY) {\n for await (const chunk of process.stdin) {\n chunks.push(chunk)\n }\n }\n\n return chunks.join(\"\")\n}\n\nasync function main() {\n const { values } = parseArgs({\n options: {\n html: { type: \"boolean\" },\n url: { type: \"boolean\" },\n help: { type: \"boolean\" },\n },\n })\n\n if (values.help) {\n console.log(`\nUsage: graphics-debug [options]\n\nOptions:\n --html Output a single HTML file with all graphics\n --url Print a url to view the graphics in a browser\n --help Show this help message\n\nExamples:\n cat debug.log | graphics-debug\n echo '{ graphics: { points: [{x: 0, y: 0}] } }' | graphics-debug --html\n `)\n process.exit(0)\n }\n\n const input = await getInput()\n\n if (values.html) {\n const html = getHtmlFromLogString(input)\n writeFileSync(\"graphicsdebug.debug.html\", html)\n console.log('Wrote to \"graphicsdebug.debug.html\"')\n } else if (values.url) {\n const graphicsObjects = getGraphicsObjectsFromLogString(input)\n if (graphicsObjects.length === 0) {\n console.error(\"No graphics objects found in input\")\n process.exit(0)\n }\n\n const { url } = await fetch(\"https://gdstore.seve.workers.dev/store\", {\n method: \"POST\",\n body: JSON.stringify({\n graphicsObjects: getGraphicsObjectsFromLogString(input),\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n }).then((res) => res.json())\n\n const token = url.split(\"/get/\").pop()\n\n console.log(`https://graphicsdebug.com/t/${token}`)\n } else {\n const svgs = getSvgsFromLogString(input)\n svgs.forEach((svg, i) => {\n const filename = `${svg.title.toLowerCase().replace(/\\s+/g, \"-\")}-${i + 1}.debug.svg`\n writeFileSync(filename, svg.svg)\n console.log(`Wrote to \"${filename}\"`)\n })\n }\n}\n\nmain().catch((err) => {\n console.error(\"Error:\", err)\n process.exit(1)\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../cli/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\"\nimport { readFileSync } from \"node:fs\"\nimport { writeFileSync } from \"node:fs\"\nimport {\n getSvgsFromLogString,\n getHtmlFromLogString,\n getGraphicsObjectsFromLogString,\n} from \"../lib\"\n\nasync function getInput(): Promise<string> {\n // Check if there's data being piped in\n if (process.stdin.isTTY && process.stderr.isTTY) {\n console.error(\n \"Error: No input provided. Pipe in content with graphics objects.\",\n )\n process.exit(1)\n }\n\n const chunks = []\n\n // Read from stdin if available\n if (!process.stdin.isTTY) {\n for await (const chunk of process.stdin) {\n chunks.push(chunk)\n }\n }\n\n return chunks.join(\"\")\n}\n\nasync function main() {\n const { values } = parseArgs({\n options: {\n html: { type: \"boolean\" },\n url: { type: \"boolean\" },\n help: { type: \"boolean\" },\n },\n })\n\n if (values.help) {\n console.log(`\nUsage: graphics-debug [options]\n\nOptions:\n --html Output a single HTML file with all graphics\n --url Print a url to view the graphics in a browser\n --help Show this help message\n\nExamples:\n cat debug.log | graphics-debug\n echo '{ graphics: { points: [{x: 0, y: 0}] } }' | graphics-debug --html\n `)\n process.exit(0)\n }\n\n const input = await getInput()\n\n if (values.html) {\n const html = getHtmlFromLogString(input)\n writeFileSync(\"graphicsdebug.debug.html\", html)\n console.log('Wrote to \"graphicsdebug.debug.html\"')\n } else if (values.url) {\n const graphicsObjects = getGraphicsObjectsFromLogString(input)\n if (graphicsObjects.length === 0) {\n console.error(\"No graphics objects found in input\")\n process.exit(0)\n }\n\n const { url } = await fetch(\"https://gdstore.seve.workers.dev/store\", {\n method: \"POST\",\n body: JSON.stringify({\n graphicsObjects: getGraphicsObjectsFromLogString(input),\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n }).then((res) => res.json())\n\n const token = url.split(\"/get/\").pop()\n\n console.log(`https://graphicsdebug.com/t/${token}`)\n } else {\n const svgs = getSvgsFromLogString(input)\n svgs.forEach((svg, i) => {\n const filename = `${svg.title.toLowerCase().replace(/\\s+/g, \"-\")}-${i + 1}.debug.svg`\n writeFileSync(filename, svg.svg)\n console.log(`Wrote to \"${filename}\"`)\n })\n }\n}\n\nmain().catch((err) => {\n console.error(\"Error:\", err)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,SAAS,iBAAiB;AAE1B,SAAS,qBAAqB;AAO9B,eAAe,WAA4B;AAEzC,MAAI,QAAQ,MAAM,SAAS,QAAQ,OAAO,OAAO;AAC/C,YAAQ;AAAA,MACN;AAAA,IACF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,SAAS,CAAC;AAGhB,MAAI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AC,KAAK,MAAM;AACvB,YAAM,WAAW,GAAG,IAAI,MAAM,YAAY,EAAE,QAAQ,QAAQ,GAAG,CAAC,IAAI,IAAI,CAAC;AACzE,oBAAc,UAAU,IAAI,GAAG;AAC/B,cAAQ,IAAI,aAAa,QAAQ,GAAG;AAAA,IACtC,CAAC;AAAA,EACH;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,UAAU,GAAG;AAC3B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
@@ -2,9 +2,10 @@ import {
|
|
|
2
2
|
computeTransformFromViewbox,
|
|
3
3
|
drawGraphicsToCanvas,
|
|
4
4
|
getBounds
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-AKONCUCE.js";
|
|
6
6
|
import "../chunk-IOVKI3ZO.js";
|
|
7
7
|
import "../chunk-ZGI74PYD.js";
|
|
8
|
+
import "../chunk-FLFF6QXL.js";
|
|
8
9
|
export {
|
|
9
10
|
computeTransformFromViewbox,
|
|
10
11
|
drawGraphicsToCanvas,
|
|
@@ -2,7 +2,7 @@ import { GraphicsObject } from './types.js';
|
|
|
2
2
|
import 'transformation-matrix';
|
|
3
3
|
|
|
4
4
|
declare function getSvgFromGraphicsObject(graphics: GraphicsObject, { includeTextLabels, backgroundColor, svgWidth, svgHeight, }?: {
|
|
5
|
-
includeTextLabels?: boolean | Array<"points" | "lines" | "rects" | "polygons">;
|
|
5
|
+
includeTextLabels?: boolean | Array<"points" | "lines" | "infiniteLines" | "rects" | "polygons">;
|
|
6
6
|
backgroundColor?: string | null;
|
|
7
7
|
svgWidth?: number;
|
|
8
8
|
svgHeight?: number;
|