pure-svg-code
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -8,3 +8,5 @@ const fs = require('fs'); | ||
const svg = barcode('123', 'codabar'); | ||
assert.equal(svg, fs.readFileSync(path.resolve(__dirname, 'barcode.svg'))) | ||
assert.equal(svg, fs.readFileSync(path.resolve(__dirname, 'barcode.svg'), { | ||
encoding: 'utf8' | ||
})) | ||
}); |
@@ -28,2 +28,6 @@ /** | ||
color?: string; | ||
/** | ||
* should show text under bar | ||
*/ | ||
showHRI?: boolean; | ||
}): string; | ||
@@ -30,0 +34,0 @@ |
{ | ||
"name": "pure-svg-code", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "generate qrcode & barcode to svg in pure javascript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -775,11 +775,6 @@ function QR8bitByte(data) { | ||
/** Generates QR Code as SVG image */ | ||
QRCode.prototype.svg = function (opt) { | ||
if (typeof opt == "undefined") { | ||
opt = {container: "svg"}; | ||
} | ||
QRCode.prototype.svg = function () { | ||
var options = this.options; | ||
var modules = this.qrcode.modules; | ||
var EOL = '\r\n'; | ||
var width = options.width; | ||
@@ -791,3 +786,3 @@ var height = options.height; | ||
var rect = '<rect x="0" y="0" width="' + width + '" height="' + height + '" style="fill:' + options.background + ';shape-rendering:crispEdges;"/>' + EOL; | ||
var rect = '<rect x="0" y="0" width="' + width + '" height="' + height + '" style="fill:' + options.background + ';shape-rendering:crispEdges;"/>'; | ||
@@ -800,3 +795,3 @@ for (var y = 0; y < length; y++) { | ||
var py = (y * ysize + options.padding * ysize).toString(); | ||
rect += '<rect x="' + px + '" y="' + py + '" width="' + xsize + '" height="' + ysize + '" style="fill:' + options.color + ';shape-rendering:crispEdges;"/>' + EOL; | ||
rect += '<rect x="' + px + '" y="' + py + '" width="' + xsize + '" height="' + ysize + '" style="fill:' + options.color + ';shape-rendering:crispEdges;"/>'; | ||
} | ||
@@ -806,21 +801,6 @@ } | ||
var svg = ""; | ||
switch (opt.container) { | ||
case "svg": | ||
svg += '<?xml version="1.0" standalone="yes"?>' + EOL + '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="' + width + '" height="' + height + '">' + EOL; | ||
svg += rect; | ||
svg += '</svg>'; | ||
break; | ||
var svg = '<?xml version="1.0" standalone="yes"?>' + '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="' + width + '" height="' + height + '">'; | ||
svg += rect; | ||
svg += '</svg>'; | ||
case "g": | ||
svg += '<g width="' + width + '" height="' + height + '">' + EOL; | ||
svg += rect; | ||
svg += '</g>'; | ||
break; | ||
default: | ||
svg += rect; | ||
break; | ||
} | ||
return svg; | ||
@@ -827,0 +807,0 @@ }; |
@@ -8,3 +8,5 @@ const fs = require('fs'); | ||
const svg = qrcode('123'); | ||
assert.equal(svg, fs.readFileSync(path.resolve(__dirname, 'qrcode.svg'))) | ||
assert.equal(svg, fs.readFileSync(path.resolve(__dirname, 'qrcode.svg'), { | ||
encoding: 'utf8' | ||
})) | ||
}); |
@@ -95,8 +95,8 @@ [![Npm Package](https://img.shields.io/npm/v/pure-svg-code.svg?style=flat-square)](https://www.npmjs.com/package/pure-svg-code) | ||
#### Support options: | ||
- `barHeight` (number) -height of svg (default: 30); | ||
- `width` (number) -width of svg (default: 100); | ||
- `bgColor` (string) -background color css like (default: 'transparent'); | ||
- `color` (string) -barcode color (default: '#000000'); | ||
- `barHeight` height of svg (default: 30); | ||
- `width` width of svg (default: 100); | ||
- `bgColor` background color css like (default: 'transparent'); | ||
- `color` barcode color (default: '#000000'); | ||
- `showHRI`: should show text under bar; | ||
## Use it with `<img/>` tag | ||
@@ -103,0 +103,0 @@ ```js |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115484
1854