Added spaces around multiplication operators in QrCode.getAlignmentPatternPositions() for all language versions, for consistency with other code.

pull/118/head
Project Nayuki 4 years ago
parent 42bc11c763
commit 764749bd8a

@ -552,7 +552,7 @@ testable int getAlignmentPatternPositions(int version, uint8_t result[7]) {
return 0;
int numAlign = version / 7 + 2;
int step = (version == 32) ? 26 :
(version*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2;
(version * 4 + numAlign * 2 + 1) / (numAlign * 2 - 2) * 2;
for (int i = numAlign - 1, pos = version * 4 + 10; i >= 1; i--, pos -= step)
result[i] = (uint8_t)pos;
result[0] = 6;

@ -670,7 +670,7 @@ vector<int> QrCode::getAlignmentPatternPositions() const {
else {
int numAlign = version / 7 + 2;
int step = (version == 32) ? 26 :
(version*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2;
(version * 4 + numAlign * 2 + 1) / (numAlign * 2 - 2) * 2;
vector<int> result;
for (int i = 0, pos = size - 7; i < numAlign - 1; i++, pos -= step)
result.insert(result.begin(), pos);

@ -618,8 +618,8 @@ public final class QrCode {
int step;
if (version == 32) // Special snowflake
step = 26;
else // step = ceil[(size - 13) / (numAlign*2 - 2)] * 2
step = (version*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2;
else // step = ceil[(size - 13) / (numAlign * 2 - 2)] * 2
step = (version * 4 + numAlign * 2 + 1) / (numAlign * 2 - 2) * 2;
int[] result = new int[numAlign];
result[0] = 6;
for (int i = result.length - 1, pos = size - 7; i >= 1; i--, pos -= step)

@ -486,7 +486,7 @@ class QrCode:
else:
numalign: int = ver // 7 + 2
step: int = 26 if (ver == 32) else \
(ver*4 + numalign*2 + 1) // (numalign*2 - 2) * 2
(ver * 4 + numalign * 2 + 1) // (numalign * 2 - 2) * 2
result: List[int] = [(self._size - 7 - i * step) for i in range(numalign - 1)] + [6]
return list(reversed(result))

@ -695,7 +695,7 @@ impl QrCode {
} else {
let numalign = i32::from(ver) / 7 + 2;
let step: i32 = if ver == 32 { 26 } else
{(i32::from(ver)*4 + numalign*2 + 1) / (numalign*2 - 2) * 2};
{(i32::from(ver) * 4 + numalign * 2 + 1) / (numalign * 2 - 2) * 2};
let mut result: Vec<i32> = (0 .. numalign - 1).map(
|i| self.size - 7 - i * step).collect();
result.push(6);

@ -545,7 +545,7 @@ namespace qrcodegen {
else {
const numAlign: int = Math.floor(this.version / 7) + 2;
const step: int = (this.version == 32) ? 26 :
Math.ceil((this.size - 13) / (numAlign*2 - 2)) * 2;
Math.ceil((this.size - 13) / (numAlign * 2 - 2)) * 2;
let result: Array<int> = [6];
for (let pos = this.size - 7; result.length < numAlign; pos -= step)
result.splice(1, 0, pos);

Loading…
Cancel
Save