Simplified QrCode.toSvgString() in C++ and Rust, related to Java change in commit 9c670453a8.

pull/39/merge
Project Nayuki 6 years ago
parent 3ead3dbb84
commit b59c181162

@ -174,13 +174,10 @@ std::string QrCode::toSvgString(int border) const {
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 = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
if (getModule(x, y)) {
if (head)
head = false;
else
if (x != 0 || y != 0)
sb << " ";
sb << "M" << (x + border) << "," << (y + border) << "h1v1h-1z";
}

@ -252,13 +252,10 @@ impl QrCode {
"<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 {0} {0}\" stroke=\"none\">\n", dimension);
result += "\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n";
result += "\t<path d=\"";
let mut head = true;
for y in 0 .. self.size {
for x in 0 .. self.size {
if self.get_module(x, y) {
if head {
head = false;
} else {
if x != 0 || y != 0 {
result += " ";
}
result += &format!("M{},{}h1v1h-1z", x + border, y + border);

Loading…
Cancel
Save