Skip to content

Commit 7fd4adb

Browse files
committed
Use only positive size for SVG. Defaults to no size.
1 parent 696c143 commit 7fd4adb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var svg_string = qr.imageSync('I love QR!', { type: 'svg' });
4545
* `options` — image options object:
4646
* `ec_level` — default `M`.
4747
* `type` — image type. Possible values `png` (default), `svg`, `pdf` and `eps`.
48-
* `size` (png and svg only) — size of one module in pixels. Default `5` for png and `1` for others.
48+
* `size` (png and svg only) — size of one module in pixels. Default `5` for png and `undefined` for svg.
4949
* `margin` — white space around QR image in modules. Default `4` for `png` and `1` for others.
5050
* `customize` (only png) — function to customize qr bitmap before encoding to PNG.
5151
* `parse_url` (experimental, default `false`) — try to optimize QR-code for URLs.

lib/vector.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,11 @@ function SVG_object(matrix, margin) {
149149

150150
function SVG(matrix, stream, margin, size) {
151151
var X = matrix.length + 2 * margin;
152-
var XY = X * size;
153152
stream.push('<svg xmlns="http://www.w3.org/2000/svg" ');
154-
if(size >= 0) stream.push('width="' + XY + '" height="' + XY + '" ');
153+
if (size > 0) {
154+
var XY = X * size;
155+
stream.push('width="' + XY + '" height="' + XY + '" ');
156+
}
155157
stream.push('viewBox="0 0 ' + X + ' ' + X + '">');
156158
stream.push('<path d="');
157159
pushSVGPath(matrix, stream, margin);

0 commit comments

Comments
 (0)