Simplified the no-stroke declaration in SVG output code - in Java, C++, JavaScript, Python language versions.

pull/16/head
Project Nayuki 8 years ago
parent 7075db21d1
commit d785ecb598

@ -176,8 +176,8 @@ std::string QrCode::toSvgString(int border) const {
sb << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
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 << (size + border * 2) << " " << (size + border * 2) << "\" stroke=\"none\">\n";
sb << "\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n";
sb << "\t<path d=\"";
bool head = true;
for (int y = -border; y < size + border; y++) {
@ -191,7 +191,7 @@ std::string QrCode::toSvgString(int border) const {
}
}
}
sb << "\" fill=\"#000000\" stroke-width=\"0\"/>\n";
sb << "\" fill=\"#000000\"/>\n";
sb << "</svg>\n";
return sb.str();
}

@ -308,8 +308,8 @@ public final class QrCode {
StringBuilder sb = new StringBuilder();
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(String.format("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 %1$d %1$d\" stroke=\"none\">\n", size + border * 2));
sb.append("\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n");
sb.append("\t<path d=\"");
boolean head = true;
for (int y = -border; y < size + border; y++) {
@ -323,7 +323,7 @@ public final class QrCode {
}
}
}
sb.append("\" fill=\"#000000\" stroke-width=\"0\"/>\n");
sb.append("\" fill=\"#000000\"/>\n");
sb.append("</svg>\n");
return sb.toString();
}

@ -210,8 +210,8 @@ var qrcodegen = new function() {
throw "Border must be non-negative";
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 += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 " + (size + border * 2) + " " + (size + border * 2) + "\" stroke=\"none\">\n";
result += "\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n";
result += "\t<path d=\"";
var head = true;
for (var y = -border; y < size + border; y++) {
@ -225,7 +225,7 @@ var qrcodegen = new function() {
}
}
}
result += "\" fill=\"#000000\" stroke-width=\"0\"/>\n";
result += "\" fill=\"#000000\"/>\n";
result += "</svg>\n";
return result;
};

@ -243,9 +243,9 @@ class QrCode(object):
parts.append("M{},{}h1v1h-1z".format(x + border, y + border))
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 xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 {0} {0}" stroke="none">
<rect width="100%" height="100%" fill="#FFFFFF"/>
<path d="{1}" fill="#000000"/>
</svg>
""".format(self._size + border * 2, " ".join(parts))

Loading…
Cancel
Save