Skip to content

Commit

Permalink
Use only positive size for SVG. Defaults to no size.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyten committed Dec 29, 2014
1 parent 696c143 commit 7fd4adb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var svg_string = qr.imageSync('I love QR!', { type: 'svg' });
* `options` — image options object:
* `ec_level` — default `M`.
* `type` — image type. Possible values `png` (default), `svg`, `pdf` and `eps`.
* `size` (png and svg only) — size of one module in pixels. Default `5` for png and `1` for others.
* `size` (png and svg only) — size of one module in pixels. Default `5` for png and `undefined` for svg.
* `margin` — white space around QR image in modules. Default `4` for `png` and `1` for others.
* `customize` (only png) — function to customize qr bitmap before encoding to PNG.
* `parse_url` (experimental, default `false`) — try to optimize QR-code for URLs.
Expand Down
6 changes: 4 additions & 2 deletions lib/vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ function SVG_object(matrix, margin) {

function SVG(matrix, stream, margin, size) {
var X = matrix.length + 2 * margin;
var XY = X * size;
stream.push('<svg xmlns="http://www.w3.org/2000/svg" ');
if(size >= 0) stream.push('width="' + XY + '" height="' + XY + '" ');
if (size > 0) {
var XY = X * size;
stream.push('width="' + XY + '" height="' + XY + '" ');
}
stream.push('viewBox="0 0 ' + X + ' ' + X + '">');
stream.push('<path d="');
pushSVGPath(matrix, stream, margin);
Expand Down

0 comments on commit 7fd4adb

Please sign in to comment.