Aligned code involving QrCode grid fields, in most languages.

pull/39/merge
Project Nayuki 6 years ago
parent fd64af3e50
commit 0a0ac19f9b

@ -119,7 +119,7 @@ QrCode::QrCode(int ver, Ecc ecl, const vector<uint8_t> &dataCodewords, int mask)
version(ver),
size(MIN_VERSION <= ver && ver <= MAX_VERSION ? ver * 4 + 17 : -1), // Avoid signed overflow undefined behavior
errorCorrectionLevel(ecl),
modules(size, vector<bool>(size)), // Entirely white grid
modules (size, vector<bool>(size)), // Entirely white grid
isFunction(size, vector<bool>(size)) {
// Check arguments

@ -222,7 +222,7 @@ public final class QrCode {
// Initialize fields
version = ver;
size = ver * 4 + 17;
modules = new boolean[size][size]; // Entirely white grid
modules = new boolean[size][size]; // Entirely white grid
isFunction = new boolean[size][size];
// Draw function patterns, draw all codewords, do masking

@ -83,10 +83,10 @@ var qrcodegen = new function() {
var row = [];
for (var i = 0; i < size; i++)
row.push(false);
var modules = [];
var modules = [];
var isFunction = [];
for (var i = 0; i < size; i++) {
modules.push(row.slice());
modules .push(row.slice());
isFunction.push(row.slice());
}

@ -186,7 +186,7 @@ impl QrCode {
size: size as i32,
mask: Mask::new(0), // Dummy value
errorcorrectionlevel: ecl,
modules: vec![false; size * size], // Entirely white grid
modules : vec![false; size * size], // Entirely white grid
isfunction: vec![false; size * size],
};

@ -138,7 +138,7 @@ namespace qrcodegen {
public readonly size: int;
// The modules of this QR Code symbol (false = white, true = black). Immutable after constructor finishes.
private readonly modules: Array<Array<boolean>> = [];
private readonly modules : Array<Array<boolean>> = [];
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
private readonly isFunction: Array<Array<boolean>> = [];
@ -172,7 +172,7 @@ namespace qrcodegen {
for (let i = 0; i < this.size; i++)
row.push(false);
for (let i = 0; i < this.size; i++) {
this.modules.push(row.slice());
this.modules .push(row.slice());
this.isFunction.push(row.slice());
}

Loading…
Cancel
Save