From 99e7d59383a862f6f97cec9f8c906717b88db416 Mon Sep 17 00:00:00 2001 From: Project Nayuki <me@nayuki.io> Date: Tue, 27 Jul 2021 23:34:00 +0000 Subject: [PATCH] Changed the word "white" to "light" in {comments, local variables, a private C function} in order to match the vocabulary in the QR Code specification document. --- c/qrcodegen-test.c | 18 +++++++------- c/qrcodegen.c | 24 +++++++++---------- c/qrcodegen.h | 6 ++--- cpp/QrCode.cpp | 10 ++++---- cpp/QrCode.hpp | 10 ++++---- .../main/java/io/nayuki/qrcodegen/QrCode.java | 24 +++++++++---------- python/qrcodegen.py | 20 ++++++++-------- rust/src/lib.rs | 20 ++++++++-------- typescript-javascript/qrcodegen.ts | 22 ++++++++--------- 9 files changed, 77 insertions(+), 77 deletions(-) diff --git a/c/qrcodegen-test.c b/c/qrcodegen-test.c index 37612d7..76d1d0f 100644 --- a/c/qrcodegen-test.c +++ b/c/qrcodegen-test.c @@ -374,7 +374,7 @@ static void testInitializeFunctionModulesEtc(void) { else assert(size == ver * 4 + 17); - bool hasWhite = false; + bool hasLight = false; bool hasBlack = false; for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { @@ -382,10 +382,10 @@ static void testInitializeFunctionModulesEtc(void) { if (color) hasBlack = true; else - hasWhite = true; + hasLight = true; } } - assert(hasWhite && hasBlack); + assert(hasLight && hasBlack); free(qrcode); numTestCases++; } @@ -424,11 +424,11 @@ static void testGetSetModule(void) { initializeFunctionModules(23, qrcode); int size = qrcodegen_getSize(qrcode); - for (int y = 0; y < size; y++) { // Clear all to white + for (int y = 0; y < size; y++) { // Clear all to light for (int x = 0; x < size; x++) setModule(qrcode, x, y, false); } - for (int y = 0; y < size; y++) { // Check all white + for (int y = 0; y < size; y++) { // Check all light for (int x = 0; x < size; x++) assert(qrcodegen_getModule(qrcode, x, y) == false); } @@ -441,7 +441,7 @@ static void testGetSetModule(void) { assert(qrcodegen_getModule(qrcode, x, y) == true); } - // Set some out of bounds modules to white + // Set some out of bounds modules to light setModuleBounded(qrcode, -1, -1, false); setModuleBounded(qrcode, -1, 0, false); setModuleBounded(qrcode, 0, -1, false); @@ -453,13 +453,13 @@ static void testGetSetModule(void) { assert(qrcodegen_getModule(qrcode, x, y) == true); } - // Set some modules to white + // Set some modules to light setModule(qrcode, 3, 8, false); setModule(qrcode, 61, 49, false); for (int y = 0; y < size; y++) { // Check most black for (int x = 0; x < size; x++) { - bool white = (x == 3 && y == 8) || (x == 61 && y == 49); - assert(qrcodegen_getModule(qrcode, x, y) != white); + bool light = (x == 3 && y == 8) || (x == 61 && y == 49); + assert(qrcodegen_getModule(qrcode, x, y) != light); } } numTestCases++; diff --git a/c/qrcodegen.c b/c/qrcodegen.c index 31219a7..7166028 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -64,7 +64,7 @@ testable void reedSolomonComputeRemainder(const uint8_t data[], int dataLen, testable uint8_t reedSolomonMultiply(uint8_t x, uint8_t y); testable void initializeFunctionModules(int version, uint8_t qrcode[]); -static void drawWhiteFunctionModules(uint8_t qrcode[], int version); +static void drawLightFunctionModules(uint8_t qrcode[], int version); static void drawFormatBits(enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, uint8_t qrcode[]); testable int getAlignmentPatternPositions(int version, uint8_t result[7]); static void fillRectangle(int left, int top, int width, int height, uint8_t qrcode[]); @@ -259,7 +259,7 @@ bool qrcodegen_encodeSegmentsAdvanced(const struct qrcodegen_Segment segs[], siz addEccAndInterleave(qrcode, version, ecl, tempBuffer); initializeFunctionModules(version, qrcode); drawCodewords(tempBuffer, getNumRawDataModules(version) / 8, qrcode); - drawWhiteFunctionModules(qrcode, version); + drawLightFunctionModules(qrcode, version); initializeFunctionModules(version, tempBuffer); // Handle masking @@ -413,7 +413,7 @@ testable uint8_t reedSolomonMultiply(uint8_t x, uint8_t y) { /*---- Drawing function modules ----*/ -// Clears the given QR Code grid with white modules for the given +// Clears the given QR Code grid with light modules for the given // version's size, then marks every function module as black. testable void initializeFunctionModules(int version, uint8_t qrcode[]) { // Initialize QR Code @@ -449,10 +449,10 @@ testable void initializeFunctionModules(int version, uint8_t qrcode[]) { } -// Draws white function modules and possibly some black modules onto the given QR Code, without changing +// Draws light function modules and possibly some black modules onto the given QR Code, without changing // non-function modules. This does not draw the format bits. This requires all function modules to be previously // marked black (namely by initializeFunctionModules()), because this may skip redrawing black function modules. -static void drawWhiteFunctionModules(uint8_t qrcode[], int version) { +static void drawLightFunctionModules(uint8_t qrcode[], int version) { // Draw horizontal and vertical timing patterns int qrsize = qrcodegen_getSize(qrcode); for (int i = 7; i < qrsize - 7; i += 2) { @@ -512,7 +512,7 @@ static void drawWhiteFunctionModules(uint8_t qrcode[], int version) { // Draws two copies of the format bits (with its own error correction code) based // on the given mask and error correction level. This always draws all modules of -// the format bits, unlike drawWhiteFunctionModules() which might skip black modules. +// the format bits, unlike drawLightFunctionModules() which might skip black modules. static void drawFormatBits(enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, uint8_t qrcode[]) { // Calculate error correction code and pack bits assert(0 <= (int)mask && (int)mask <= 7); @@ -573,7 +573,7 @@ static void fillRectangle(int left, int top, int width, int height, uint8_t qrco /*---- Drawing data modules and masking ----*/ // Draws the raw codewords (including data and ECC) onto the given QR Code. This requires the initial state of -// the QR Code to be black at function modules and white at codeword modules (including unused remainder bits). +// the QR Code to be black at function modules and light at codeword modules (including unused remainder bits). static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[]) { int qrsize = qrcodegen_getSize(qrcode); int i = 0; // Bit index into the data @@ -592,7 +592,7 @@ static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[]) { i++; } // If this QR Code has any remainder bits (0 to 7), they were assigned as - // 0/false/white by the constructor and are left unchanged by this method + // 0/false/light by the constructor and are left unchanged by this method } } } @@ -693,7 +693,7 @@ static long getPenaltyScore(const uint8_t qrcode[]) { } } - // Balance of black and white modules + // Balance of black and light modules int black = 0; for (int y = 0; y < qrsize; y++) { for (int x = 0; x < qrsize; x++) { @@ -709,7 +709,7 @@ static long getPenaltyScore(const uint8_t qrcode[]) { } -// Can only be called immediately after a white run is added, and +// Can only be called immediately after a light run is added, and // returns either 0, 1, or 2. A helper function for getPenaltyScore(). static int finderPenaltyCountPatterns(const int runHistory[7], int qrsize) { int n = runHistory[1]; @@ -728,7 +728,7 @@ static int finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunLe finderPenaltyAddHistory(currentRunLength, runHistory, qrsize); currentRunLength = 0; } - currentRunLength += qrsize; // Add white border to final run + currentRunLength += qrsize; // Add light border to final run finderPenaltyAddHistory(currentRunLength, runHistory, qrsize); return finderPenaltyCountPatterns(runHistory, qrsize); } @@ -737,7 +737,7 @@ static int finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunLe // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore(). static void finderPenaltyAddHistory(int currentRunLength, int runHistory[7], int qrsize) { if (runHistory[0] == 0) - currentRunLength += qrsize; // Add white border to initial run + currentRunLength += qrsize; // Add light border to initial run memmove(&runHistory[1], &runHistory[0], 6 * sizeof(runHistory[0])); runHistory[0] = currentRunLength; } diff --git a/c/qrcodegen.h b/c/qrcodegen.h index a99b94d..fd0ae9c 100644 --- a/c/qrcodegen.h +++ b/c/qrcodegen.h @@ -36,7 +36,7 @@ extern "C" { /* * This library creates QR Code symbols, which is a type of two-dimension barcode. * Invented by Denso Wave and described in the ISO/IEC 18004 standard. - * A QR Code structure is an immutable square grid of black and white cells. + * A QR Code structure is an immutable square grid of black and light cells. * The library provides functions to create a QR Code from text or binary data. * The library covers the QR Code Model 2 specification, supporting all versions (sizes) * from 1 to 40, all 4 error correction levels, and 4 character encoding modes. @@ -300,8 +300,8 @@ int qrcodegen_getSize(const uint8_t qrcode[]); /* * Returns the color of the module (pixel) at the given coordinates, which is false - * for white or true for black. The top left corner has the coordinates (x=0, y=0). - * If the given coordinates are out of bounds, then false (white) is returned. + * for light or true for black. The top left corner has the coordinates (x=0, y=0). + * If the given coordinates are out of bounds, then false (light) is returned. */ bool qrcodegen_getModule(const uint8_t qrcode[], int x, int y); diff --git a/cpp/QrCode.cpp b/cpp/QrCode.cpp index b1673e2..88186e1 100644 --- a/cpp/QrCode.cpp +++ b/cpp/QrCode.cpp @@ -327,7 +327,7 @@ QrCode::QrCode(int ver, Ecc ecl, const vector<uint8_t> &dataCodewords, int msk) throw std::domain_error("Mask value out of range"); size = ver * 4 + 17; size_t sz = static_cast<size_t>(size); - modules = vector<vector<bool> >(sz, vector<bool>(sz)); // Initially all white + modules = vector<vector<bool> >(sz, vector<bool>(sz)); // Initially all light isFunction = vector<vector<bool> >(sz, vector<bool>(sz)); // Compute ECC, draw modules @@ -584,7 +584,7 @@ void QrCode::drawCodewords(const vector<uint8_t> &data) { i++; } // If this QR Code has any remainder bits (0 to 7), they were assigned as - // 0/false/white by the constructor and are left unchanged by this method + // 0/false/light by the constructor and are left unchanged by this method } } } @@ -676,7 +676,7 @@ long QrCode::getPenaltyScore() const { } } - // Balance of black and white modules + // Balance of black and light modules int black = 0; for (const vector<bool> &row : modules) { for (bool color : row) { @@ -797,7 +797,7 @@ int QrCode::finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunL finderPenaltyAddHistory(currentRunLength, runHistory); currentRunLength = 0; } - currentRunLength += size; // Add white border to final run + currentRunLength += size; // Add light border to final run finderPenaltyAddHistory(currentRunLength, runHistory); return finderPenaltyCountPatterns(runHistory); } @@ -805,7 +805,7 @@ int QrCode::finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunL void QrCode::finderPenaltyAddHistory(int currentRunLength, std::array<int,7> &runHistory) const { if (runHistory.at(0) == 0) - currentRunLength += size; // Add white border to initial run + currentRunLength += size; // Add light border to initial run std::copy_backward(runHistory.cbegin(), runHistory.cend() - 1, runHistory.end()); runHistory.at(0) = currentRunLength; } diff --git a/cpp/QrCode.hpp b/cpp/QrCode.hpp index 9e7f7fc..55a1ee8 100644 --- a/cpp/QrCode.hpp +++ b/cpp/QrCode.hpp @@ -220,7 +220,7 @@ class QrSegment final { /* * A QR Code symbol, which is a type of two-dimension barcode. * Invented by Denso Wave and described in the ISO/IEC 18004 standard. - * Instances of this class represent an immutable square grid of black and white cells. + * Instances of this class represent an immutable square grid of black and light cells. * The class provides static factory functions to create a QR Code from text or binary data. * The class covers the QR Code Model 2 specification, supporting all versions (sizes) * from 1 to 40, all 4 error correction levels, and 4 character encoding modes. @@ -314,7 +314,7 @@ class QrCode final { // Private grids of modules/pixels, with dimensions of size*size: - // The modules of this QR Code (false = white, true = black). + // The modules of this QR Code (false = light, true = black). // Immutable after constructor finishes. Accessed through getModule(). private: std::vector<std::vector<bool> > modules; @@ -363,8 +363,8 @@ class QrCode final { /* * Returns the color of the module (pixel) at the given coordinates, which is false - * for white or true for black. The top left corner has the coordinates (x=0, y=0). - * If the given coordinates are out of bounds, then false (white) is returned. + * for light or true for black. The top left corner has the coordinates (x=0, y=0). + * If the given coordinates are out of bounds, then false (light) is returned. */ public: bool getModule(int x, int y) const; @@ -472,7 +472,7 @@ class QrCode final { private: static std::uint8_t reedSolomonMultiply(std::uint8_t x, std::uint8_t y); - // Can only be called immediately after a white run is added, and + // Can only be called immediately after a light run is added, and // returns either 0, 1, or 2. A helper function for getPenaltyScore(). private: int finderPenaltyCountPatterns(const std::array<int,7> &runHistory) const; diff --git a/java/src/main/java/io/nayuki/qrcodegen/QrCode.java b/java/src/main/java/io/nayuki/qrcodegen/QrCode.java index 1b4c7d0..1a74fcb 100644 --- a/java/src/main/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/src/main/java/io/nayuki/qrcodegen/QrCode.java @@ -32,7 +32,7 @@ import java.util.Objects; /** * A QR Code symbol, which is a type of two-dimension barcode. * Invented by Denso Wave and described in the ISO/IEC 18004 standard. - * <p>Instances of this class represent an immutable square grid of black and white cells. + * <p>Instances of this class represent an immutable square grid of black and light cells. * The class provides static factory functions to create a QR Code from text or binary data. * The class covers the QR Code Model 2 specification, supporting all versions (sizes) * from 1 to 40, all 4 error correction levels, and 4 character encoding modes.</p> @@ -222,7 +222,7 @@ public final class QrCode { // Private grids of modules/pixels, with dimensions of size*size: - // The modules of this QR Code (false = white, true = black). + // The modules of this QR Code (false = light, true = black). // Immutable after constructor finishes. Accessed through getModule(). private boolean[][] modules; @@ -256,7 +256,7 @@ public final class QrCode { size = ver * 4 + 17; errorCorrectionLevel = Objects.requireNonNull(ecl); Objects.requireNonNull(dataCodewords); - modules = new boolean[size][size]; // Initially all white + modules = new boolean[size][size]; // Initially all light isFunction = new boolean[size][size]; // Compute ECC, draw modules, do masking @@ -273,12 +273,12 @@ public final class QrCode { /** * Returns the color of the module (pixel) at the specified coordinates, which is {@code false} - * for white or {@code true} for black. The top left corner has the coordinates (x=0, y=0). - * If the specified coordinates are out of bounds, then {@code false} (white) is returned. + * for light or {@code true} for black. The top left corner has the coordinates (x=0, y=0). + * If the specified coordinates are out of bounds, then {@code false} (light) is returned. * @param x the x coordinate, where 0 is the left edge and size−1 is the right edge * @param y the y coordinate, where 0 is the top edge and size−1 is the bottom edge * @return {@code true} if the coordinates are in bounds and the module - * at that location is black, or {@code false} (white) otherwise + * at that location is black, or {@code false} (light) otherwise */ public boolean getModule(int x, int y) { return 0 <= x && x < size && 0 <= y && y < size && modules[y][x]; @@ -287,7 +287,7 @@ public final class QrCode { /** * Returns a raster image depicting this QR Code, with the specified module scale and border modules. - * <p>For example, toImage(scale=10, border=4) means to pad the QR Code with 4 white + * <p>For example, toImage(scale=10, border=4) means to pad the QR Code with 4 light * border modules on all four sides, and use 10×10 pixels to represent each module. * The resulting image only contains the hex colors 000000 and FFFFFF. * @param scale the side length (measured in pixels, must be positive) of each module @@ -530,7 +530,7 @@ public final class QrCode { i++; } // If this QR Code has any remainder bits (0 to 7), they were assigned as - // 0/false/white by the constructor and are left unchanged by this method + // 0/false/light by the constructor and are left unchanged by this method } } } @@ -651,7 +651,7 @@ public final class QrCode { } } - // Balance of black and white modules + // Balance of black and light modules int black = 0; for (boolean[] row : modules) { for (boolean color : row) { @@ -786,7 +786,7 @@ public final class QrCode { } - // Can only be called immediately after a white run is added, and + // Can only be called immediately after a light run is added, and // returns either 0, 1, or 2. A helper function for getPenaltyScore(). private int finderPenaltyCountPatterns(int[] runHistory) { int n = runHistory[1]; @@ -803,7 +803,7 @@ public final class QrCode { finderPenaltyAddHistory(currentRunLength, runHistory); currentRunLength = 0; } - currentRunLength += size; // Add white border to final run + currentRunLength += size; // Add light border to final run finderPenaltyAddHistory(currentRunLength, runHistory); return finderPenaltyCountPatterns(runHistory); } @@ -812,7 +812,7 @@ public final class QrCode { // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore(). private void finderPenaltyAddHistory(int currentRunLength, int[] runHistory) { if (runHistory[0] == 0) - currentRunLength += size; // Add white border to initial run + currentRunLength += size; // Add light border to initial run System.arraycopy(runHistory, 0, runHistory, 1, runHistory.length - 1); runHistory[0] = currentRunLength; } diff --git a/python/qrcodegen.py b/python/qrcodegen.py index c0924c9..115d31d 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -32,7 +32,7 @@ from typing import Callable, Dict, List, Optional, Tuple, Union class QrCode: """A QR Code symbol, which is a type of two-dimension barcode. Invented by Denso Wave and described in the ISO/IEC 18004 standard. - Instances of this class represent an immutable square grid of black and white cells. + Instances of this class represent an immutable square grid of black and light cells. The class provides static factory functions to create a QR Code from text or binary data. The class covers the QR Code Model 2 specification, supporting all versions (sizes) from 1 to 40, all 4 error correction levels, and 4 character encoding modes. @@ -151,7 +151,7 @@ class QrCode: # the resulting object still has a mask value between 0 and 7. _mask: int - # The modules of this QR Code (False = white, True = black). + # The modules of this QR Code (False = light, True = black). # Immutable after constructor finishes. Accessed through get_module(). _modules: List[List[bool]] @@ -180,7 +180,7 @@ class QrCode: self._errcorlvl = errcorlvl # Initialize both grids to be size*size arrays of Boolean false - self._modules = [[False] * self._size for _ in range(self._size)] # Initially all white + self._modules = [[False] * self._size for _ in range(self._size)] # Initially all light self._isfunction = [[False] * self._size for _ in range(self._size)] # Compute ECC, draw modules @@ -227,8 +227,8 @@ class QrCode: def get_module(self, x: int, y: int) -> bool: """Returns the color of the module (pixel) at the given coordinates, which is False - for white or True for black. The top left corner has the coordinates (x=0, y=0). - If the given coordinates are out of bounds, then False (white) is returned.""" + for light or True for black. The top left corner has the coordinates (x=0, y=0). + If the given coordinates are out of bounds, then False (light) is returned.""" return (0 <= x < self._size) and (0 <= y < self._size) and self._modules[y][x] @@ -416,7 +416,7 @@ class QrCode: self._modules[y][x] = _get_bit(data[i >> 3], 7 - (i & 7)) i += 1 # If this QR Code has any remainder bits (0 to 7), they were assigned as - # 0/false/white by the constructor and are left unchanged by this method + # 0/false/light by the constructor and are left unchanged by this method assert i == len(data) * 8 @@ -486,7 +486,7 @@ class QrCode: if modules[y][x] == modules[y][x + 1] == modules[y + 1][x] == modules[y + 1][x + 1]: result += QrCode._PENALTY_N2 - # Balance of black and white modules + # Balance of black and light modules black: int = sum((1 if cell else 0) for row in modules for cell in row) total: int = size**2 # Note that size is odd, so black/total != 1/2 # Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)% @@ -591,7 +591,7 @@ class QrCode: def _finder_penalty_count_patterns(self, runhistory: collections.deque) -> int: - """Can only be called immediately after a white run is added, and + """Can only be called immediately after a light run is added, and returns either 0, 1, or 2. A helper function for _get_penalty_score().""" n: int = runhistory[1] assert n <= self._size * 3 @@ -605,14 +605,14 @@ class QrCode: if currentruncolor: # Terminate black run self._finder_penalty_add_history(currentrunlength, runhistory) currentrunlength = 0 - currentrunlength += self._size # Add white border to final run + currentrunlength += self._size # Add light border to final run self._finder_penalty_add_history(currentrunlength, runhistory) return self._finder_penalty_count_patterns(runhistory) def _finder_penalty_add_history(self, currentrunlength: int, runhistory: collections.deque) -> None: if runhistory[0] == 0: - currentrunlength += self._size # Add white border to initial run + currentrunlength += self._size # Add light border to initial run runhistory.appendleft(currentrunlength) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 64f563c..dbfb855 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -88,7 +88,7 @@ /// /// Invented by Denso Wave and described in the ISO/IEC 18004 standard. /// -/// Instances of this struct represent an immutable square grid of black and white cells. +/// Instances of this struct represent an immutable square grid of black and light cells. /// The impl provides static factory functions to create a QR Code from text or binary data. /// The struct and impl cover the QR Code Model 2 specification, supporting all versions /// (sizes) from 1 to 40, all 4 error correction levels, and 4 character encoding modes. @@ -126,7 +126,7 @@ pub struct QrCode { // Grids of modules/pixels, with dimensions of size*size: - // The modules of this QR Code (false = white, true = black). + // The modules of this QR Code (false = light, true = black). // Immutable after constructor finishes. Accessed through get_module(). modules: Vec<bool>, @@ -285,7 +285,7 @@ impl QrCode { size: size as i32, mask: Mask::new(0), // Dummy value errorcorrectionlevel: ecl, - modules : vec![false; size * size], // Initially all white + modules : vec![false; size * size], // Initially all light isfunction: vec![false; size * size], }; @@ -347,10 +347,10 @@ impl QrCode { /// Returns the color of the module (pixel) at the given coordinates, - /// which is `false` for white or `true` for black. + /// which is `false` for light or `true` for black. /// /// The top left corner has the coordinates (x=0, y=0). If the given - /// coordinates are out of bounds, then `false` (white) is returned. + /// coordinates are out of bounds, then `false` (light) is returned. pub fn get_module(&self, x: i32, y: i32) -> bool { 0 <= x && x < self.size && 0 <= y && y < self.size && self.module(x, y) } @@ -602,7 +602,7 @@ impl QrCode { i += 1; } // If this QR Code has any remainder bits (0 to 7), they were assigned as - // 0/false/white by the constructor and are left unchanged by this method + // 0/false/light by the constructor and are left unchanged by this method } } right -= 2; @@ -703,7 +703,7 @@ impl QrCode { } } - // Balance of black and white modules + // Balance of black and light modules let black: i32 = self.modules.iter().copied().map(i32::from).sum(); let total: i32 = size * size; // Note that size is odd, so black/total != 1/2 // Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)% @@ -846,7 +846,7 @@ impl FinderPenalty { // Pushes the given value to the front and drops the last value. pub fn add_history(&mut self, mut currentrunlength: i32) { if self.run_history[0] == 0 { - currentrunlength += self.qr_size; // Add white border to initial run + currentrunlength += self.qr_size; // Add light border to initial run } let rh = &mut self.run_history; for i in (0 .. rh.len()-1).rev() { @@ -856,7 +856,7 @@ impl FinderPenalty { } - // Can only be called immediately after a white run is added, and returns either 0, 1, or 2. + // Can only be called immediately after a light run is added, and returns either 0, 1, or 2. pub fn count_patterns(&self) -> i32 { let rh = &self.run_history; let n = rh[1]; @@ -873,7 +873,7 @@ impl FinderPenalty { self.add_history(currentrunlength); currentrunlength = 0; } - currentrunlength += self.qr_size; // Add white border to final run + currentrunlength += self.qr_size; // Add light border to final run self.add_history(currentrunlength); self.count_patterns() } diff --git a/typescript-javascript/qrcodegen.ts b/typescript-javascript/qrcodegen.ts index 88663ee..77f07bc 100644 --- a/typescript-javascript/qrcodegen.ts +++ b/typescript-javascript/qrcodegen.ts @@ -36,7 +36,7 @@ namespace qrcodegen { /* * A QR Code symbol, which is a type of two-dimension barcode. * Invented by Denso Wave and described in the ISO/IEC 18004 standard. - * Instances of this class represent an immutable square grid of black and white cells. + * Instances of this class represent an immutable square grid of black and light cells. * The class provides static factory functions to create a QR Code from text or binary data. * The class covers the QR Code Model 2 specification, supporting all versions (sizes) * from 1 to 40, all 4 error correction levels, and 4 character encoding modes. @@ -155,7 +155,7 @@ namespace qrcodegen { // 21 and 177 (inclusive). This is equal to version * 4 + 17. public readonly size: int; - // The modules of this QR Code (false = white, true = black). + // The modules of this QR Code (false = light, true = black). // Immutable after constructor finishes. Accessed through getModule(). private readonly modules : Array<Array<boolean>> = []; @@ -196,7 +196,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()); // Initially all white + this.modules .push(row.slice()); // Initially all light this.isFunction.push(row.slice()); } @@ -232,8 +232,8 @@ namespace qrcodegen { /*-- Accessor methods --*/ // Returns the color of the module (pixel) at the given coordinates, which is false - // for white or true for black. The top left corner has the coordinates (x=0, y=0). - // If the given coordinates are out of bounds, then false (white) is returned. + // for light or true for black. The top left corner has the coordinates (x=0, y=0). + // If the given coordinates are out of bounds, then false (light) is returned. public getModule(x: int, y: int): boolean { return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x]; } @@ -243,7 +243,7 @@ namespace qrcodegen { // Draws this QR Code, with the given module scale and border modules, onto the given HTML // canvas element. The canvas's width and height is resized to (this.size + border * 2) * scale. - // The drawn image is be purely black and white, and fully opaque. + // The drawn image is be purely black and light, and fully opaque. // The scale must be a positive integer and the border must be a non-negative integer. public drawCanvas(scale: int, border: int, canvas: HTMLCanvasElement): void { if (scale <= 0 || border < 0) @@ -467,7 +467,7 @@ namespace qrcodegen { i++; } // If this QR Code has any remainder bits (0 to 7), they were assigned as - // 0/false/white by the constructor and are left unchanged by this method + // 0/false/light by the constructor and are left unchanged by this method } } } @@ -566,7 +566,7 @@ namespace qrcodegen { } } - // Balance of black and white modules + // Balance of black and light modules let black: int = 0; for (const row of this.modules) black = row.reduce((sum, color) => sum + (color ? 1 : 0), black); @@ -686,7 +686,7 @@ namespace qrcodegen { } - // Can only be called immediately after a white run is added, and + // Can only be called immediately after a light run is added, and // returns either 0, 1, or 2. A helper function for getPenaltyScore(). private finderPenaltyCountPatterns(runHistory: Array<int>): int { const n: int = runHistory[1]; @@ -704,7 +704,7 @@ namespace qrcodegen { this.finderPenaltyAddHistory(currentRunLength, runHistory); currentRunLength = 0; } - currentRunLength += this.size; // Add white border to final run + currentRunLength += this.size; // Add light border to final run this.finderPenaltyAddHistory(currentRunLength, runHistory); return this.finderPenaltyCountPatterns(runHistory); } @@ -713,7 +713,7 @@ namespace qrcodegen { // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore(). private finderPenaltyAddHistory(currentRunLength: int, runHistory: Array<int>): void { if (runHistory[0] == 0) - currentRunLength += this.size; // Add white border to initial run + currentRunLength += this.size; // Add light border to initial run runHistory.pop(); runHistory.unshift(currentRunLength); }