Added white background rectangle to SVG XML code output, in all language versions.

pull/4/head
Nayuki Minase 9 years ago
parent 1d27211497
commit fc705efac3

@ -171,6 +171,7 @@ std::string qrcodegen::QrCode::toSvgString(int border) const {
sb << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
sb << "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 ";
sb << (size + border * 2) << " " << (size + border * 2) << "\">\n";
sb << "\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\" stroke-width=\"0\"/>\n"
sb << "\t<path d=\"";
bool head = true;
for (int y = -border; y < size + border; y++) {

@ -310,6 +310,7 @@ public final class QrCode {
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
sb.append("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
sb.append(String.format("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 %1$d %1$d\">\n", size + border * 2));
sb.append("\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\" stroke-width=\"0\"/>\n");
sb.append("\t<path d=\"");
boolean head = true;
for (int y = -border; y < size + border; y++) {

@ -198,6 +198,7 @@ var qrcodegen = new function() {
var result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
result += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
result += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 " + (size + border * 2) + " " + (size + border * 2) + "\">\n";
result += "\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\" stroke-width=\"0\"/>\n";
result += "\t<path d=\"";
var head = true;
for (var y = -border; y < size + border; y++) {

@ -239,6 +239,7 @@ class QrCode(object):
return """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 {0} {0}">
<rect width="100%" height="100%" fill="#FFFFFF" stroke-width="0"/>
<path d="{1}" fill="#000000" stroke-width="0"/>
</svg>
""".format(self.size + border * 2, " ".join(parts))

Loading…
Cancel
Save