diff --git a/lib/drawGraphicsToCanvas.ts b/lib/drawGraphicsToCanvas.ts
index 8c2bd45..ba565cb 100644
--- a/lib/drawGraphicsToCanvas.ts
+++ b/lib/drawGraphicsToCanvas.ts
@@ -383,6 +383,7 @@ export function drawGraphicsToCanvas(
ctx.lineWidth = 2
}
ctx.lineCap = "round"
+ ctx.lineJoin = "round"
if (line.strokeDash) {
if (typeof line.strokeDash === "string") {
diff --git a/lib/getPngBufferFromGraphicsObject.ts b/lib/getPngBufferFromGraphicsObject.ts
index 724ba1a..5328be2 100644
--- a/lib/getPngBufferFromGraphicsObject.ts
+++ b/lib/getPngBufferFromGraphicsObject.ts
@@ -234,6 +234,7 @@ export async function getPngBufferFromGraphicsObject(
line.strokeWidth === undefined
? 1
: Math.max(line.strokeWidth * strokeScale, 1)
+ ctx.lineJoin = "round"
strokePolyline(ctx, projectedPoints, dashPattern)
if (
diff --git a/lib/getSvgFromGraphicsObject.ts b/lib/getSvgFromGraphicsObject.ts
index 20aed0f..331e38c 100644
--- a/lib/getSvgFromGraphicsObject.ts
+++ b/lib/getSvgFromGraphicsObject.ts
@@ -234,6 +234,7 @@ export function getSvgFromGraphicsObject(
points: projectedPoints.map((p) => `${p.x},${p.y}`).join(" "),
fill: "none",
stroke: line.strokeColor || "black",
+ "stroke-linejoin": "round",
"stroke-width": !line.strokeWidth
? "1px"
: typeof line.strokeWidth === "string"
diff --git a/tests/__snapshots__/line-joins.snapshot-acute-polyline.snap.svg b/tests/__snapshots__/line-joins.snapshot-acute-polyline.snap.svg
new file mode 100644
index 0000000..5b7b1bd
--- /dev/null
+++ b/tests/__snapshots__/line-joins.snapshot-acute-polyline.snap.svg
@@ -0,0 +1,44 @@
+
diff --git a/tests/getSvgFromGraphicsObject.test.ts b/tests/getSvgFromGraphicsObject.test.ts
index 4753f1d..3e1ef6d 100644
--- a/tests/getSvgFromGraphicsObject.test.ts
+++ b/tests/getSvgFromGraphicsObject.test.ts
@@ -63,6 +63,13 @@ describe("getSvgFromGraphicsObject", () => {
})
expect(svg).toBeString()
expect(svg).toContain("]*>/g) ?? []
+ expect(polylines).toHaveLength(2)
+ expect(
+ polylines.every((polyline) =>
+ polyline.includes('stroke-linejoin="round"'),
+ ),
+ ).toBe(true)
// Test custom stroke properties
expect(svg).toContain('stroke="blue"')
// Test stroke width scaling
@@ -72,7 +79,7 @@ describe("getSvgFromGraphicsObject", () => {
expect(strokeWidths).toMatchInlineSnapshot(`
[
[
- " {
+ const input: GraphicsObject = {
+ lines: [
+ {
+ points: [
+ { x: -1.5, y: 2 },
+ { x: 0, y: -2 },
+ { x: 1.5, y: 2 },
+ ],
+ strokeColor: "#2563eb",
+ strokeWidth: 0.8,
+ },
+ ],
+ }
+
+ const svg = getSvgFromGraphicsObject(input, {
+ svgWidth: 320,
+ svgHeight: 240,
+ })
+
+ expect(svg).toMatchSvgSnapshot(import.meta.path, "acute-polyline")
+})