zxpsuper / qrcode-with-logos

A plugin for generating QR codes with a logo and styling.
https://zxpsuper.github.io/qrcode-with-logos
MIT License
137 stars 41 forks source link

Option to change background color #42

Closed jayademola closed 1 month ago

jayademola commented 1 month ago

This issue proposes adding a setting to allow users to change the background color and/or image to their preference.

zxpsuper commented 1 month ago

This issue proposes adding a setting to allow users to change the background color and/or image to their preference.

It has been implemented! You can set nodeQrCodeOptions.color to change background and foreground colours. For example:

new QrCodeWithLogo({
  canvas: document.getElementById("canvas"),
  content: "https://github.com/zxpsuper",
  width: 380,
  logo: {
    src: "https://avatars1.githubusercontent.com/u/28730619?s=460&v=4"
  },
  nodeQrCodeOptions: {
    color: {
        light: "#eee",
        dark: "#f00"
      }
  },
  cornersOptions: {},
  dotsOptions: {}
})

The result is that: image

zxpsuper commented 1 month ago

Background image is not support now!