Changed QrCode.getModule() in {Java, JavaScript, Python, C++} language versions to return Boolean instead of 0/1 - to match {C, Rust} language versions - and updated comments and usages.

This commit is contained in:
Project Nayuki
2017-08-31 20:39:29 +00:00
parent 6f9116dfcb
commit 9c1a25aba4
11 changed files with 32 additions and 41 deletions
+3 -6
View File
@@ -159,11 +159,8 @@ int QrCode::getMask() const {
}
int QrCode::getModule(int x, int y) const {
if (0 <= x && x < size && 0 <= y && y < size)
return module(x, y) ? 1 : 0;
else
return 0; // Infinite white border
bool QrCode::getModule(int x, int y) const {
return 0 <= x && x < size && 0 <= y && y < size && module(x, y);
}
@@ -180,7 +177,7 @@ std::string QrCode::toSvgString(int border) const {
bool head = true;
for (int y = -border; y < size + border; y++) {
for (int x = -border; x < size + border; x++) {
if (getModule(x, y) == 1) {
if (getModule(x, y)) {
if (head)
head = false;
else