Swapped {dy,dx} variables in commutative operations for clarity, in all languages.
This commit is contained in:
parent
87868d7920
commit
6903d28c90
|
@ -361,9 +361,9 @@ static void drawWhiteFunctionModules(uint8_t qrcode[], int version) {
|
|||
// Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules)
|
||||
for (int dy = -4; dy <= 4; dy++) {
|
||||
for (int dx = -4; dx <= 4; dx++) {
|
||||
int dist = abs(dy);
|
||||
if (abs(dx) > dist)
|
||||
dist = abs(dx);
|
||||
int dist = abs(dx);
|
||||
if (abs(dy) > dist)
|
||||
dist = abs(dy);
|
||||
if (dist == 2 || dist == 4) {
|
||||
setModuleBounded(qrcode, 3 + dx, 3 + dy, false);
|
||||
setModuleBounded(qrcode, qrsize - 4 + dx, 3 + dy, false);
|
||||
|
@ -381,7 +381,7 @@ static void drawWhiteFunctionModules(uint8_t qrcode[], int version) {
|
|||
continue; // Don't draw on the three finder corners
|
||||
for (int dy = -1; dy <= 1; dy++) {
|
||||
for (int dx = -1; dx <= 1; dx++)
|
||||
setModule(qrcode, alignPatPos[i] + dx, alignPatPos[j] + dy, dy == 0 && dx == 0);
|
||||
setModule(qrcode, alignPatPos[i] + dx, alignPatPos[j] + dy, dx == 0 && dy == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ void QrCode::drawVersion() {
|
|||
void QrCode::drawFinderPattern(int x, int y) {
|
||||
for (int dy = -4; dy <= 4; dy++) {
|
||||
for (int dx = -4; dx <= 4; dx++) {
|
||||
int dist = std::max(std::abs(dy), std::abs(dx)); // Chebyshev/infinity norm
|
||||
int dist = std::max(std::abs(dx), std::abs(dy)); // Chebyshev/infinity norm
|
||||
int xx = x + dx, yy = y + dy;
|
||||
if (0 <= xx && xx < size && 0 <= yy && yy < size)
|
||||
setFunctionModule(xx, yy, dist != 2 && dist != 4);
|
||||
|
@ -284,7 +284,7 @@ void QrCode::drawFinderPattern(int x, int y) {
|
|||
void QrCode::drawAlignmentPattern(int x, int y) {
|
||||
for (int dy = -2; dy <= 2; dy++) {
|
||||
for (int dx = -2; dx <= 2; dx++)
|
||||
setFunctionModule(x + dx, y + dy, std::max(std::abs(dy), std::abs(dx)) != 1);
|
||||
setFunctionModule(x + dx, y + dy, std::max(std::abs(dx), std::abs(dy)) != 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ public final class QrCode {
|
|||
private void drawFinderPattern(int x, int y) {
|
||||
for (int dy = -4; dy <= 4; dy++) {
|
||||
for (int dx = -4; dx <= 4; dx++) {
|
||||
int dist = Math.max(Math.abs(dy), Math.abs(dx)); // Chebyshev/infinity norm
|
||||
int dist = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm
|
||||
int xx = x + dx, yy = y + dy;
|
||||
if (0 <= xx && xx < size && 0 <= yy && yy < size)
|
||||
setFunctionModule(xx, yy, dist != 2 && dist != 4);
|
||||
|
@ -418,7 +418,7 @@ public final class QrCode {
|
|||
private void drawAlignmentPattern(int x, int y) {
|
||||
for (int dy = -2; dy <= 2; dy++) {
|
||||
for (int dx = -2; dx <= 2; dx++)
|
||||
setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dy), Math.abs(dx)) != 1);
|
||||
setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ var qrcodegen = new function() {
|
|||
function drawFinderPattern(x, y) {
|
||||
for (var dy = -4; dy <= 4; dy++) {
|
||||
for (var dx = -4; dx <= 4; dx++) {
|
||||
var dist = Math.max(Math.abs(dy), Math.abs(dx)); // Chebyshev/infinity norm
|
||||
var dist = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm
|
||||
var xx = x + dx, yy = y + dy;
|
||||
if (0 <= xx && xx < size && 0 <= yy && yy < size)
|
||||
setFunctionModule(xx, yy, dist != 2 && dist != 4);
|
||||
|
@ -292,7 +292,7 @@ var qrcodegen = new function() {
|
|||
function drawAlignmentPattern(x, y) {
|
||||
for (var dy = -2; dy <= 2; dy++) {
|
||||
for (var dx = -2; dx <= 2; dx++)
|
||||
setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dy), Math.abs(dx)) != 1);
|
||||
setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -327,7 +327,7 @@ class QrCode(object):
|
|||
xx, yy = x + dx, y + dy
|
||||
if (0 <= xx < self._size) and (0 <= yy < self._size):
|
||||
# Chebyshev/infinity norm
|
||||
self._set_function_module(xx, yy, max(abs(dy), abs(dx)) not in (2, 4))
|
||||
self._set_function_module(xx, yy, max(abs(dx), abs(dy)) not in (2, 4))
|
||||
|
||||
|
||||
def _draw_alignment_pattern(self, x, y):
|
||||
|
@ -335,7 +335,7 @@ class QrCode(object):
|
|||
at (x, y). All modules must be in bounds."""
|
||||
for dy in range(-2, 3):
|
||||
for dx in range(-2, 3):
|
||||
self._set_function_module(x + dx, y + dy, max(abs(dy), abs(dx)) != 1)
|
||||
self._set_function_module(x + dx, y + dy, max(abs(dx), abs(dy)) != 1)
|
||||
|
||||
|
||||
def _set_function_module(self, x, y, isblack):
|
||||
|
|
|
@ -372,7 +372,7 @@ impl QrCode {
|
|||
let xx: i32 = x + dx;
|
||||
let yy: i32 = y + dy;
|
||||
if 0 <= xx && xx < self.size && 0 <= yy && yy < self.size {
|
||||
let dist: i32 = std::cmp::max(dy.abs(), dx.abs()); // Chebyshev/infinity norm
|
||||
let dist: i32 = std::cmp::max(dx.abs(), dy.abs()); // Chebyshev/infinity norm
|
||||
self.set_function_module(xx, yy, dist != 2 && dist != 4);
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ impl QrCode {
|
|||
fn draw_alignment_pattern(&mut self, x: i32, y: i32) {
|
||||
for dy in -2 .. 3 {
|
||||
for dx in -2 .. 3 {
|
||||
self.set_function_module(x + dx, y + dy, std::cmp::max(dy.abs(), dx.abs()) != 1);
|
||||
self.set_function_module(x + dx, y + dy, std::cmp::max(dx.abs(), dy.abs()) != 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ namespace qrcodegen {
|
|||
private drawFinderPattern(x: int, y: int): void {
|
||||
for (let dy = -4; dy <= 4; dy++) {
|
||||
for (let dx = -4; dx <= 4; dx++) {
|
||||
let dist: int = Math.max(Math.abs(dy), Math.abs(dx)); // Chebyshev/infinity norm
|
||||
let dist: int = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm
|
||||
let xx: int = x + dx;
|
||||
let yy: int = y + dy;
|
||||
if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size)
|
||||
|
@ -362,7 +362,7 @@ namespace qrcodegen {
|
|||
private drawAlignmentPattern(x: int, y: int): void {
|
||||
for (let dy = -2; dy <= 2; dy++) {
|
||||
for (let dx = -2; dx <= 2; dx++)
|
||||
this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dy), Math.abs(dx)) != 1);
|
||||
this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue