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

padding not null toDataUrl Picture not centered #123

Open
milabi opened this issue Dec 7, 2020 · 3 comments
Open

padding not null toDataUrl Picture not centered #123

milabi opened this issue Dec 7, 2020 · 3 comments

Comments

@milabi
Copy link

milabi commented Dec 7, 2020

下载 (2)

qr.background = '#cfcfcf';
qr.backgroundAlpha = 1.0;
qr.foregroundAlpha = 1.0;
qr.foreground = '#000000';
qr.level = 'L';
qr.padding = 10;
qr.size = 220;
qr.value = '#123';

@cibersheep
Copy link

I had this on the old code.
Try removing Math.floor here: https://github.com/neocotic/qrious/blob/master/dist/qrious.js#L312

@roblewisink
Copy link

I realize this is an old thread, but wanted to add a note for anyone else who may be looking for a solution to the padding issue.

It appears to me that the getModuleSize function already accounts for the padding value. As such, there is no need to add a condition in the getOffset function to handle padding.

I made the following edit with positive results:

getOffset: function(frame) {
      var qrious = this.qrious;
      /* var padding = qrious.padding;
      *
      *  if (padding != null) {
      *   return padding;
      * }
      */
      var moduleSize = this.getModuleSize(frame);
      var offset = Math.floor((qrious.size - (moduleSize * frame.width)) / 2);
      return Math.max(0, offset);
    },

@ROBERT-MCDOWELL
Copy link

thanks! try to make a PR so maybe the author will merge it!

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

No branches or pull requests

4 participants