Skip to content

Conversation

@EDais
Copy link

@EDais EDais commented Feb 12, 2025

Added a new renderer to export SVG format QR codes rendered with rounded corners.

This has been split into new renderer since the generated code is significantly larger than the standard SVG renderer. To support the rounded corners, the runs must be generated as filled polygons made up of arcs and lines rather than simple strokes.

Top-left, top-right, bottom-left and bottom-right corner sizes can be configured independently, and if the combined size of opposite corners is greater than 1, they will be reduced proportionally like the border-radius CSS property.

Example usage:

const res = await QRCode.toString("test", {
    type: "svg-round",
    errorCorrectionLevel: "M",
    margin: 1,
    color: {
        dark: "#000000ff",
        light: "#ffffffff",
    },
    rendererOpts: {
        corners: {
            topLeft: 0.5,
            topRight: 0.1,
            bottomLeft: 0.1,
            bottomRight: 0.5,
        }
    }
});

fs.writeFileSync("test.svg", res, "utf8");

@YoshiYo
Copy link

YoshiYo commented Jun 11, 2025

LGTM. The branch works well. Thanks, @EDais!

@soldair, I think this is good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants