Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/drawGraphicsToCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ export function drawGraphicsToCanvas(
ctx.lineWidth = 2
}
ctx.lineCap = "round"
ctx.lineJoin = "round"

if (line.strokeDash) {
if (typeof line.strokeDash === "string") {
Expand Down
1 change: 1 addition & 0 deletions lib/getPngBufferFromGraphicsObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions lib/getSvgFromGraphicsObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion tests/getSvgFromGraphicsObject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ describe("getSvgFromGraphicsObject", () => {
})
expect(svg).toBeString()
expect(svg).toContain("<polyline")
const polylines = svg.match(/<polyline[^>]*>/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
Expand All @@ -72,7 +79,7 @@ describe("getSvgFromGraphicsObject", () => {
expect(strokeWidths).toMatchInlineSnapshot(`
[
[
"<polyline data-points="0,0 10,10" data-type="line" data-label="" points="40,160 160,40" fill="none" stroke="blue" stroke-width="24"",
"<polyline data-points="0,0 10,10" data-type="line" data-label="" points="40,160 160,40" fill="none" stroke="blue" stroke-linejoin="round" stroke-width="24"",
"24",
],
]
Expand Down
Loading