Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added svg-round renderer #393

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added svg-round renderer #393

wants to merge 1 commit into from

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");

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.

1 participant