Code

add 4-unit margin and white background
authord <d@d-desktop>
Tue, 9 Nov 2010 05:10:07 +0000 (01:10 -0400)
committerd <d@d-desktop>
Tue, 9 Nov 2010 05:10:07 +0000 (01:10 -0400)
share/extensions/render_barcode_qrcode.py

index 7b6759c0f5c8ba3410c75c0a87b37e62925efb22..6a34f9671e65c5ce4ec98c921b8e1dd181513e59 100644 (file)
@@ -119,13 +119,22 @@ class QRCode:
         return pattern\r
 \r
     def makeSVG(self, grp, boxsize):\r
-        pixelsize = self.getModuleCount() * boxsize\r
-\r
+        margin = 4\r
+        pixelsize = (self.getModuleCount() + 2*margin) * boxsize #self.getModuleCount() * boxsize\r
+\r
+        # white background providing margin:\r
+        rect = inkex.etree.SubElement(grp, inkex.addNS('rect', 'svg'))\r
+        rect.set('x', '0')\r
+        rect.set('y', '0')\r
+        rect.set('width', str(pixelsize))\r
+        rect.set('height', str(pixelsize))\r
+        rect.set('style', 'fill:white;stroke:none')\r
+        \r
         for r in range(self.getModuleCount()):\r
             for c in range(self.getModuleCount()):\r
                 if (self.isDark(r, c) ):\r
-                    x = c * boxsize\r
-                    y = r * boxsize\r
+                    x = (c + margin) * boxsize\r
+                    y = (r + margin) * boxsize\r
                     rect = inkex.etree.SubElement(grp, inkex.addNS('rect', 'svg'))\r
                     rect.set('x', str(x))\r
                     rect.set('y', str(y))\r