Giter Site home page Giter Site logo

Padding issues about qrious HOT 5 CLOSED

neocotic avatar neocotic commented on August 15, 2024
Padding issues

from qrious.

Comments (5)

pcooperuk avatar pcooperuk commented on August 15, 2024 10

Hi,
Even thought this issue is closed, it's still happens with the latest version and its not a nice UI experience.
As wanted to use the library, I have made a tweak to improve this just one line change if you want to include into the official version.

just replace line 404 in qrious.js

from:
var offset = this.getOffset(frame);

to:
var offset=parseInt((this.element.width-(frame.width*moduleSize))/2);

tested across a variety of sizes and content

from qrious.

F-Hauri avatar F-Hauri commented on August 15, 2024

I confirm: This work fine exept outer line!

There is a need to draw a white border, with same size than minimal block.

Workaround consist of having image or canvas in html element white padded (even using CSS).

Border effect is that resulting image have to be resized before printing or working on.

from qrious.

F-Hauri avatar F-Hauri commented on August 15, 2024

There is some correction I made, margin seem fine, pixel size too, but unfortunely I don't understand why I have to run two pass... There is a working try: http://fhauri.cartou.ch/qr

--- -   2014-01-31 13:02:44.796061685 +0100
+++ qr.js       2014-01-31 12:57:51.641130369 +0100
@@ -1019,12 +1019,19 @@
       // Module size of the generated QR code (i.e. 1-10).
       var size = data.size >= 1 && data.size <= 10 ? data.size : 4;
       // Actual size of the QR code symbol and is scaled to 25 pixels (e.g. 1 = 25px, 3 = 75px).
-      size *= 25;
+//      size *= 25;
+      size *= (2+width);

       // `<canvas>` element used to render the QR code.
       var cvs = data.canvas || createCanvas();
       // Retreive the 2D context of the canvas.
       var c2d = cvs.getContext('2d');
+
+      // Determine the *pixel* size.
+      var px = size;
+      px /= (2+width);
+      px  = Math.round(px - 0.5);
+
       // Ensure the canvas has the correct dimensions.
       c2d.canvas.width  = size;
       c2d.canvas.height = size;
@@ -1040,11 +1047,6 @@

       c2d.lineWidth = 1;

-      // Determine the *pixel* size.
-      var px = size;
-      px /= width;
-      px  = Math.round(px - 0.5);
-
       // Draw the QR code.
       c2d.clearRect(0, 0, size, size);
       c2d.fillStyle = data.background || '#fff';
@@ -1056,7 +1058,7 @@
       for (i = 0; i < width; i++) {
         for (j = 0; j < width; j++) {
           if (frame[j * width + i]) {
-            c2d.fillRect(px * i, px * j, px, px);
+            c2d.fillRect(px * (1+i), px * (1+j), px, px);
           }
         }
       }

from qrious.

andrewagain avatar andrewagain commented on August 15, 2024

Looks like this is still an issue in the latest version: 4.0.2

screen shot 2018-01-16 at 12 52 00 pm

screen shot 2018-01-16 at 12 51 54 pm

My options:

    var qr = new QRious({
      element: canvasElement,
      level: "L",
      padding: 0,
      size: 100,
      value: "meow"
    });

from qrious.

zcqno1 avatar zcqno1 commented on August 15, 2024

I guess it maybe because the QR code's minimal unit's size could not be bigger, otherwise, the total size would be larger than the expected size. Using the scale method may force the size to cover.
By the way, set a higher level would make it better, but also more complex.
Maybe the document should note the padding issue.

from qrious.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.