Reduced the use of the word "symbol" when referring to QR Codes, in all languages.

pull/39/merge
Project Nayuki 6 years ago
parent 7d31874345
commit eebae19fb2

@ -504,7 +504,7 @@ static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[]) {
// The function modules must be marked and the codeword bits must be drawn // The function modules must be marked and the codeword bits must be drawn
// before masking. Due to the arithmetic of XOR, calling applyMask() with // before masking. Due to the arithmetic of XOR, calling applyMask() with
// the same mask value a second time will undo the mask. A final well-formed // the same mask value a second time will undo the mask. A final well-formed
// QR Code symbol needs exactly one (not zero, two, etc.) mask applied. // QR Code needs exactly one (not zero, two, etc.) mask applied.
static void applyMask(const uint8_t functionModules[], uint8_t qrcode[], enum qrcodegen_Mask mask) { static void applyMask(const uint8_t functionModules[], uint8_t qrcode[], enum qrcodegen_Mask mask) {
assert(0 <= (int)mask && (int)mask <= 7); // Disallows qrcodegen_Mask_AUTO assert(0 <= (int)mask && (int)mask <= 7); // Disallows qrcodegen_Mask_AUTO
int qrsize = qrcodegen_getSize(qrcode); int qrsize = qrcodegen_getSize(qrcode);

@ -133,7 +133,7 @@ struct qrcodegen_Segment {
/*---- Functions to generate QR Codes ----*/ /*---- Functions to generate QR Codes ----*/
/* /*
* Encodes the given text string to a QR Code symbol, returning true if encoding succeeded. * Encodes the given text string to a QR Code, returning true if encoding succeeded.
* If the data is too long to fit in any version in the given range * If the data is too long to fit in any version in the given range
* at the given ECC level, then false is returned. * at the given ECC level, then false is returned.
* - The input text must be encoded in UTF-8 and contain no NULs. * - The input text must be encoded in UTF-8 and contain no NULs.
@ -156,7 +156,7 @@ bool qrcodegen_encodeText(const char *text, uint8_t tempBuffer[], uint8_t qrcode
/* /*
* Encodes the given binary data to a QR Code symbol, returning true if encoding succeeded. * Encodes the given binary data to a QR Code, returning true if encoding succeeded.
* If the data is too long to fit in any version in the given range * If the data is too long to fit in any version in the given range
* at the given ECC level, then false is returned. * at the given ECC level, then false is returned.
* - The input array range dataAndTemp[0 : dataLen] should normally be * - The input array range dataAndTemp[0 : dataLen] should normally be
@ -236,7 +236,7 @@ struct qrcodegen_Segment qrcodegen_makeEci(long assignVal, uint8_t buf[]);
/* /*
* Renders a QR Code symbol representing the given segments at the given error correction level. * Renders a QR Code representing the given segments at the given error correction level.
* The smallest possible QR Code version is automatically chosen for the output. Returns true if * The smallest possible QR Code version is automatically chosen for the output. Returns true if
* QR Code creation succeeded, or false if the data is too long to fit in any version. The ECC level * QR Code creation succeeded, or false if the data is too long to fit in any version. The ECC level
* of the result may be higher than the ecl argument if it can be done without increasing the version. * of the result may be higher than the ecl argument if it can be done without increasing the version.
@ -252,7 +252,7 @@ bool qrcodegen_encodeSegments(const struct qrcodegen_Segment segs[], size_t len,
/* /*
* Renders a QR Code symbol representing the given segments with the given encoding parameters. * Renders a QR Code representing the given segments with the given encoding parameters.
* Returns true if QR Code creation succeeded, or false if the data is too long to fit in the range of versions. * Returns true if QR Code creation succeeded, or false if the data is too long to fit in the range of versions.
* The smallest possible QR Code version within the given range is automatically chosen for the output. * The smallest possible QR Code version within the given range is automatically chosen for the output.
* This function allows the user to create a custom sequence of segments that switches * This function allows the user to create a custom sequence of segments that switches

@ -109,7 +109,7 @@ QrCode QrCode::encodeSegments(const vector<QrSegment> &segs, Ecc ecl,
for (uint8_t padByte = 0xEC; bb.size() < dataCapacityBits; padByte ^= 0xEC ^ 0x11) for (uint8_t padByte = 0xEC; bb.size() < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
bb.appendBits(padByte, 8); bb.appendBits(padByte, 8);
// Create the QR Code symbol // Create the QR Code object
return QrCode(version, ecl, bb.getBytes(), mask); return QrCode(version, ecl, bb.getBytes(), mask);
} }

@ -60,7 +60,7 @@ class QrCode final {
/*---- Static factory functions (high level) ----*/ /*---- Static factory functions (high level) ----*/
/* /*
* Returns a QR Code symbol representing the given Unicode text string at the given error correction level. * Returns a QR Code representing the given Unicode text string at the given error correction level.
* As a conservative upper bound, this function is guaranteed to succeed for strings that have 2953 or fewer * As a conservative upper bound, this function is guaranteed to succeed for strings that have 2953 or fewer
* UTF-8 code units (not Unicode code points) if the low error correction level is used. The smallest possible * UTF-8 code units (not Unicode code points) if the low error correction level is used. The smallest possible
* QR Code version is automatically chosen for the output. The ECC level of the result may be higher than * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than
@ -70,7 +70,7 @@ class QrCode final {
/* /*
* Returns a QR Code symbol representing the given binary data string at the given error correction level. * Returns a QR Code representing the given binary data string at the given error correction level.
* This function always encodes using the binary segment mode, not any text mode. The maximum number of * This function always encodes using the binary segment mode, not any text mode. The maximum number of
* bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. * bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
* The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. * The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
@ -81,7 +81,7 @@ class QrCode final {
/*---- Static factory functions (mid level) ----*/ /*---- Static factory functions (mid level) ----*/
/* /*
* Returns a QR Code symbol representing the given segments with the given encoding parameters. * Returns a QR Code representing the given segments with the given encoding parameters.
* The smallest possible QR Code version within the given range is automatically chosen for the output. * The smallest possible QR Code version within the given range is automatically chosen for the output.
* This function allows the user to create a custom sequence of segments that switches * This function allows the user to create a custom sequence of segments that switches
* between modes (such as alphanumeric and binary) to encode text more efficiently. * between modes (such as alphanumeric and binary) to encode text more efficiently.
@ -96,24 +96,24 @@ class QrCode final {
// Immutable scalar parameters: // Immutable scalar parameters:
/* This QR Code symbol's version number, which is always between 1 and 40 (inclusive). */ /* This QR Code's version number, which is always between 1 and 40 (inclusive). */
private: int version; private: int version;
/* The width and height of this QR Code symbol, measured in modules. /* The width and height of this QR Code, measured in modules.
* Always equal to version * 4 + 17, in the range 21 to 177. */ * Always equal to version * 4 + 17, in the range 21 to 177. */
private: int size; private: int size;
/* The error correction level used in this QR Code symbol. */ /* The error correction level used in this QR Code. */
private: Ecc errorCorrectionLevel; private: Ecc errorCorrectionLevel;
/* The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). /* The mask pattern used in this QR Code, in the range 0 to 7 (i.e. unsigned 3-bit integer).
* Note that even if a constructor was called with automatic masking requested * Note that even if a constructor was called with automatic masking requested
* (mask = -1), the resulting object will still have a mask value between 0 and 7. */ * (mask = -1), the resulting object will still have a mask value between 0 and 7. */
private: int mask; private: int mask;
// Private grids of modules/pixels, with dimensions of size*size: // Private grids of modules/pixels, with dimensions of size*size:
// The modules of this QR Code symbol (false = white, true = black). Immutable after constructor finishes. // The modules of this QR Code (false = white, true = black). Immutable after constructor finishes.
private: std::vector<std::vector<bool> > modules; private: std::vector<std::vector<bool> > modules;
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes. // Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
@ -124,7 +124,7 @@ class QrCode final {
/*---- Constructor (low level) ----*/ /*---- Constructor (low level) ----*/
/* /*
* Creates a new QR Code symbol with the given version number, error correction level, binary data array, * Creates a new QR Code with the given version number, error correction level, binary data array,
* and mask number. This is a cumbersome low-level constructor that should not be invoked directly by the user. * and mask number. This is a cumbersome low-level constructor that should not be invoked directly by the user.
* To go one level up, see the encodeSegments() function. * To go one level up, see the encodeSegments() function.
*/ */
@ -155,7 +155,7 @@ class QrCode final {
/* /*
* Returns a string of SVG XML code representing an image of this QR Code symbol with the given * Returns a string of SVG XML code representing an image of this QR Code with the given
* number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform. * number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform.
*/ */
public: std::string toSvgString(int border) const; public: std::string toSvgString(int border) const;
@ -205,7 +205,7 @@ class QrCode final {
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
// data area of this QR Code symbol. Function modules need to be marked off before this is called. // data area of this QR Code. Function modules need to be marked off before this is called.
private: void drawCodewords(const std::vector<std::uint8_t> &data); private: void drawCodewords(const std::vector<std::uint8_t> &data);
@ -213,7 +213,7 @@ class QrCode final {
// The function modules must be marked and the codeword bits must be drawn // The function modules must be marked and the codeword bits must be drawn
// before masking. Due to the arithmetic of XOR, calling applyMask() with // before masking. Due to the arithmetic of XOR, calling applyMask() with
// the same mask value a second time will undo the mask. A final well-formed // the same mask value a second time will undo the mask. A final well-formed
// QR Code symbol needs exactly one (not zero, two, etc.) mask applied. // QR Code needs exactly one (not zero, two, etc.) mask applied.
private: void applyMask(int mask); private: void applyMask(int mask);

@ -40,7 +40,7 @@ public final class QrCode {
/*---- Static factory functions (high level) ----*/ /*---- Static factory functions (high level) ----*/
/** /**
* Returns a QR Code symbol representing the specified Unicode text string at the specified error correction level. * Returns a QR Code representing the specified Unicode text string at the specified error correction level.
* As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer * As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
* Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible * Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
* QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
@ -61,7 +61,7 @@ public final class QrCode {
/** /**
* Returns a QR Code symbol representing the specified binary data string at the specified error correction level. * Returns a QR Code representing the specified binary data string at the specified error correction level.
* This function always encodes using the binary segment mode, not any text mode. The maximum number of * This function always encodes using the binary segment mode, not any text mode. The maximum number of
* bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. * bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
* The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. * The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
@ -83,7 +83,7 @@ public final class QrCode {
/*---- Static factory functions (mid level) ----*/ /*---- Static factory functions (mid level) ----*/
/** /**
* Returns a QR Code symbol representing the specified segments at the specified error correction * Returns a QR Code representing the specified segments at the specified error correction
* level. The smallest possible QR Code version is automatically chosen for the output. The ECC level * level. The smallest possible QR Code version is automatically chosen for the output. The ECC level
* of the result may be higher than the ecl argument if it can be done without increasing the version. * of the result may be higher than the ecl argument if it can be done without increasing the version.
* <p>This function allows the user to create a custom sequence of segments that switches * <p>This function allows the user to create a custom sequence of segments that switches
@ -102,7 +102,7 @@ public final class QrCode {
/** /**
* Returns a QR Code symbol representing the specified segments with the specified encoding parameters. * Returns a QR Code representing the specified segments with the specified encoding parameters.
* The smallest possible QR Code version within the specified range is automatically chosen for the output. * The smallest possible QR Code version within the specified range is automatically chosen for the output.
* <p>This function allows the user to create a custom sequence of segments that switches * <p>This function allows the user to create a custom sequence of segments that switches
* between modes (such as alphanumeric and binary) to encode text more efficiently. * between modes (such as alphanumeric and binary) to encode text more efficiently.
@ -163,7 +163,7 @@ public final class QrCode {
for (int padByte = 0xEC; bb.bitLength() < dataCapacityBits; padByte ^= 0xEC ^ 0x11) for (int padByte = 0xEC; bb.bitLength() < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
bb.appendBits(padByte, 8); bb.appendBits(padByte, 8);
// Create the QR Code symbol // Create the QR Code object
return new QrCode(version, ecl, bb.getBytes(), mask); return new QrCode(version, ecl, bb.getBytes(), mask);
} }
@ -173,24 +173,24 @@ public final class QrCode {
// Public immutable scalar parameters: // Public immutable scalar parameters:
/** This QR Code symbol's version number, which is always between 1 and 40 (inclusive). */ /** This QR Code's version number, which is always between 1 and 40 (inclusive). */
public final int version; public final int version;
/** The width and height of this QR Code symbol, measured in modules. /** The width and height of this QR Code, measured in modules.
* Always equal to version &#xD7; 4 + 17, in the range 21 to 177 (inclusive). */ * Always equal to version &#xD7; 4 + 17, in the range 21 to 177 (inclusive). */
public final int size; public final int size;
/** The error correction level used in this QR Code symbol. Never {@code null}. */ /** The error correction level used in this QR Code. Never {@code null}. */
public final Ecc errorCorrectionLevel; public final Ecc errorCorrectionLevel;
/** The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). /** The mask pattern used in this QR Code, in the range 0 to 7 (i.e. unsigned 3-bit integer).
* Note that even if a constructor was called with automatic masking requested * Note that even if a constructor was called with automatic masking requested
* (mask = -1), the resulting object will still have a mask value between 0 and 7. */ * (mask = -1), the resulting object will still have a mask value between 0 and 7. */
public final int mask; public final int mask;
// Private grids of modules/pixels, with dimensions of size*size: // Private grids of modules/pixels, with dimensions of size*size:
// The modules of this QR Code symbol (false = white, true = black). Immutable after constructor finishes. // The modules of this QR Code (false = white, true = black). Immutable after constructor finishes.
private boolean[][] modules; private boolean[][] modules;
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes. // Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
@ -201,7 +201,7 @@ public final class QrCode {
/*---- Constructor (low level) ----*/ /*---- Constructor (low level) ----*/
/** /**
* Constructs a QR Code symbol with the specified version number, error correction level, binary data array, and mask number. * Constructs a QR Code with the specified version number, error correction level, binary data array, and mask number.
* <p>This is a cumbersome low-level constructor that should not be invoked directly by the user. * <p>This is a cumbersome low-level constructor that should not be invoked directly by the user.
* To go one level up, see the {@link #encodeSegments(List,Ecc,int,int,int,boolean)} function.</p> * To go one level up, see the {@link #encodeSegments(List,Ecc,int,int,int,boolean)} function.</p>
* @param ver the version number to use, which must be in the range 1 to 40 (inclusive) * @param ver the version number to use, which must be in the range 1 to 40 (inclusive)
@ -252,7 +252,7 @@ public final class QrCode {
/** /**
* Returns a new image object representing this QR Code, with the specified module scale and number * Returns a new image object representing this QR Code, with the specified module scale and number
* of border modules. For example, the arguments scale=10, border=4 means to pad the QR Code symbol * of border modules. For example, the arguments scale=10, border=4 means to pad the QR Code
* with 4 white border modules on all four edges, then use 10*10 pixels to represent each module. * with 4 white border modules on all four edges, then use 10*10 pixels to represent each module.
* The resulting image only contains the hex colors 000000 and FFFFFF. * The resulting image only contains the hex colors 000000 and FFFFFF.
* @param scale the module scale factor, which must be positive * @param scale the module scale factor, which must be positive
@ -279,7 +279,7 @@ public final class QrCode {
/** /**
* Returns a string of SVG XML code representing an image of this QR Code symbol with the specified * Returns a string of SVG XML code representing an image of this QR Code with the specified
* number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform. * number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform.
* @param border the number of border modules to add, which must be non-negative * @param border the number of border modules to add, which must be non-negative
* @return a string representing this QR Code as an SVG document * @return a string representing this QR Code as an SVG document
@ -474,7 +474,7 @@ public final class QrCode {
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
// data area of this QR Code symbol. Function modules need to be marked off before this is called. // data area of this QR Code. Function modules need to be marked off before this is called.
private void drawCodewords(byte[] data) { private void drawCodewords(byte[] data) {
Objects.requireNonNull(data); Objects.requireNonNull(data);
if (data.length != getNumRawDataModules(version) / 8) if (data.length != getNumRawDataModules(version) / 8)
@ -507,7 +507,7 @@ public final class QrCode {
// The function modules must be marked and the codeword bits must be drawn // The function modules must be marked and the codeword bits must be drawn
// before masking. Due to the arithmetic of XOR, calling applyMask() with // before masking. Due to the arithmetic of XOR, calling applyMask() with
// the same mask value a second time will undo the mask. A final well-formed // the same mask value a second time will undo the mask. A final well-formed
// QR Code symbol needs exactly one (not zero, two, etc.) mask applied. // QR Code needs exactly one (not zero, two, etc.) mask applied.
private void applyMask(int mask) { private void applyMask(int mask) {
if (mask < 0 || mask > 7) if (mask < 0 || mask > 7)
throw new IllegalArgumentException("Mask value out of range"); throw new IllegalArgumentException("Mask value out of range");
@ -670,7 +670,7 @@ public final class QrCode {
throw new IllegalArgumentException("Version number out of range"); throw new IllegalArgumentException("Version number out of range");
int size = ver * 4 + 17; int size = ver * 4 + 17;
int result = size * size; // Number of modules in the whole QR symbol square int result = size * size; // Number of modules in the whole QR Code square
result -= 8 * 8 * 3; // Subtract the three finders with separators result -= 8 * 8 * 3; // Subtract the three finders with separators
result -= 15 * 2 + 1; // Subtract the format information and black module result -= 15 * 2 + 1; // Subtract the format information and black module
result -= (size - 16) * 2; // Subtract the timing patterns (excluding finders) result -= (size - 16) * 2; // Subtract the timing patterns (excluding finders)

@ -64,7 +64,7 @@ var qrcodegen = new function() {
* and provides static functions to create a QR Code from user-supplied textual or binary data. * and provides static functions to create a QR Code from user-supplied textual or binary data.
* This class covers the QR Code Model 2 specification, supporting all versions (sizes) * This 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. * from 1 to 40, all 4 error correction levels, and 4 character encoding modes.
* This constructor creates a new QR Code symbol with the given version number, error correction level, binary data array, * This constructor creates a new QR Code with the given version number, error correction level, binary data array,
* and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor * and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor
* that should not be invoked directly by the user. To go one level up, see the QrCode.encodeSegments() function. * that should not be invoked directly by the user. To go one level up, see the QrCode.encodeSegments() function.
*/ */
@ -121,17 +121,17 @@ var qrcodegen = new function() {
/*---- Read-only instance properties ----*/ /*---- Read-only instance properties ----*/
// This QR Code symbol's version number, which is always between 1 and 40 (inclusive). // This QR Code's version number, which is always between 1 and 40 (inclusive).
Object.defineProperty(this, "version", {value:version}); Object.defineProperty(this, "version", {value:version});
// The width and height of this QR Code symbol, measured in modules. // The width and height of this QR Code, measured in modules.
// Always equal to version * 4 + 17, in the range 21 to 177. // Always equal to version * 4 + 17, in the range 21 to 177.
Object.defineProperty(this, "size", {value:size}); Object.defineProperty(this, "size", {value:size});
// The error correction level used in this QR Code symbol. // The error correction level used in this QR Code.
Object.defineProperty(this, "errorCorrectionLevel", {value:errCorLvl}); Object.defineProperty(this, "errorCorrectionLevel", {value:errCorLvl});
// The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). // The mask pattern used in this QR Code, in the range 0 to 7 (i.e. unsigned 3-bit integer).
// Note that even if the constructor was called with automatic masking requested // Note that even if the constructor was called with automatic masking requested
// (mask = -1), the resulting object will still have a mask value between 0 and 7. // (mask = -1), the resulting object will still have a mask value between 0 and 7.
Object.defineProperty(this, "mask", {value:mask}); Object.defineProperty(this, "mask", {value:mask});
@ -149,7 +149,7 @@ var qrcodegen = new function() {
/*---- Public instance methods ----*/ /*---- Public instance methods ----*/
// Draws this QR Code symbol with the given module scale and number of modules onto the given HTML canvas element. // Draws this QR Code with the given module scale and number of modules onto the given HTML canvas element.
// The canvas will be resized to a width and height of (this.size + border * 2) * scale. The painted image will be purely // The canvas will be resized to a width and height of (this.size + border * 2) * scale. The painted image will be purely
// black and white with no transparent regions. The scale must be a positive integer, and the border must be a non-negative integer. // black and white with no transparent regions. The scale must be a positive integer, and the border must be a non-negative integer.
this.drawCanvas = function(scale, border, canvas) { this.drawCanvas = function(scale, border, canvas) {
@ -167,7 +167,7 @@ var qrcodegen = new function() {
} }
}; };
// Returns a string of SVG XML code representing an image of this QR Code symbol with the given // Returns a string of SVG XML code representing an image of this QR Code with the given
// number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform. // number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform.
this.toSvgString = function(border) { this.toSvgString = function(border) {
if (border < 0) if (border < 0)
@ -351,7 +351,7 @@ var qrcodegen = new function() {
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
// data area of this QR Code symbol. Function modules need to be marked off before this is called. // data area of this QR Code. Function modules need to be marked off before this is called.
function drawCodewords(data) { function drawCodewords(data) {
if (data.length != Math.floor(QrCode.getNumRawDataModules(version) / 8)) if (data.length != Math.floor(QrCode.getNumRawDataModules(version) / 8))
throw "Invalid argument"; throw "Invalid argument";
@ -383,7 +383,7 @@ var qrcodegen = new function() {
// The function modules must be marked and the codeword bits must be drawn // The function modules must be marked and the codeword bits must be drawn
// before masking. Due to the arithmetic of XOR, calling applyMask() with // before masking. Due to the arithmetic of XOR, calling applyMask() with
// the same mask value a second time will undo the mask. A final well-formed // the same mask value a second time will undo the mask. A final well-formed
// QR Code symbol needs exactly one (not zero, two, etc.) mask applied. // QR Code needs exactly one (not zero, two, etc.) mask applied.
function applyMask(mask) { function applyMask(mask) {
if (mask < 0 || mask > 7) if (mask < 0 || mask > 7)
throw "Mask value out of range"; throw "Mask value out of range";
@ -516,7 +516,7 @@ var qrcodegen = new function() {
/*---- Static factory functions (high level) for QrCode ----*/ /*---- Static factory functions (high level) for QrCode ----*/
/* /*
* Returns a QR Code symbol representing the given Unicode text string at the given error correction level. * Returns a QR Code representing the given Unicode text string at the given error correction level.
* As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer * As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
* Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible * Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
* QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
@ -529,7 +529,7 @@ var qrcodegen = new function() {
/* /*
* Returns a QR Code symbol representing the given binary data string at the given error correction level. * Returns a QR Code representing the given binary data string at the given error correction level.
* This function always encodes using the binary segment mode, not any text mode. The maximum number of * This function always encodes using the binary segment mode, not any text mode. The maximum number of
* bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. * bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
* The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. * The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
@ -543,7 +543,7 @@ var qrcodegen = new function() {
/*---- Static factory functions (mid level) for QrCode ----*/ /*---- Static factory functions (mid level) for QrCode ----*/
/* /*
* Returns a QR Code symbol representing the given segments with the given encoding parameters. * Returns a QR Code representing the given segments with the given encoding parameters.
* The smallest possible QR Code version within the given range is automatically chosen for the output. * The smallest possible QR Code version within the given range is automatically chosen for the output.
* This function allows the user to create a custom sequence of segments that switches * This function allows the user to create a custom sequence of segments that switches
* between modes (such as alphanumeric and binary) to encode text more efficiently. * between modes (such as alphanumeric and binary) to encode text more efficiently.
@ -599,7 +599,7 @@ var qrcodegen = new function() {
for (var padByte = 0xEC; bb.length < dataCapacityBits; padByte ^= 0xEC ^ 0x11) for (var padByte = 0xEC; bb.length < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
bb.appendBits(padByte, 8); bb.appendBits(padByte, 8);
// Create the QR Code symbol // Create the QR Code object
return new this(version, ecl, bb.getBytes(), mask); return new this(version, ecl, bb.getBytes(), mask);
}; };

@ -70,7 +70,7 @@ class QrCode(object):
@staticmethod @staticmethod
def encode_text(text, ecl): def encode_text(text, ecl):
"""Returns a QR Code symbol representing the given Unicode text string at the given error correction level. """Returns a QR Code representing the given Unicode text string at the given error correction level.
As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
@ -81,7 +81,7 @@ class QrCode(object):
@staticmethod @staticmethod
def encode_binary(data, ecl): def encode_binary(data, ecl):
"""Returns a QR Code symbol representing the given binary data string at the given error correction level. """Returns a QR Code representing the given binary data string at the given error correction level.
This function always encodes using the binary segment mode, not any text mode. The maximum number of This function always encodes using the binary segment mode, not any text mode. The maximum number of
bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.""" The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version."""
@ -94,7 +94,7 @@ class QrCode(object):
@staticmethod @staticmethod
def encode_segments(segs, ecl, minversion=1, maxversion=40, mask=-1, boostecl=True): def encode_segments(segs, ecl, minversion=1, maxversion=40, mask=-1, boostecl=True):
"""Returns a QR Code symbol representing the given segments with the given encoding parameters. """Returns a QR Code representing the given segments with the given encoding parameters.
The smallest possible QR Code version within the given range is automatically chosen for the output. The smallest possible QR Code version within the given range is automatically chosen for the output.
This function allows the user to create a custom sequence of segments that switches This function allows the user to create a custom sequence of segments that switches
between modes (such as alphanumeric and binary) to encode text more efficiently. between modes (such as alphanumeric and binary) to encode text more efficiently.
@ -140,14 +140,14 @@ class QrCode(object):
break break
bb.append_bits(padbyte, 8) bb.append_bits(padbyte, 8)
# Create the QR Code symbol # Create the QR Code object
return QrCode(version, ecl, bb.get_bytes(), mask) return QrCode(version, ecl, bb.get_bytes(), mask)
# ---- Constructor (low level) ---- # ---- Constructor (low level) ----
def __init__(self, version, errcorlvl, datacodewords, mask): def __init__(self, version, errcorlvl, datacodewords, mask):
"""Creates a new QR Code symbol with the given version number, error correction level, binary data array, """Creates a new QR Code with the given version number, error correction level, binary data array,
and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor
that should not be invoked directly by the user. To go one level up, see the QrCode.encode_segments() function.""" that should not be invoked directly by the user. To go one level up, see the QrCode.encode_segments() function."""
@ -163,7 +163,7 @@ class QrCode(object):
self._errcorlvl = errcorlvl self._errcorlvl = errcorlvl
# Initialize both grids to be size*size arrays of Boolean false # Initialize both grids to be size*size arrays of Boolean false
# The modules of this QR Code symbol (False = white, True = black). Immutable after constructor finishes # The modules of this QR Code (False = white, True = black). Immutable after constructor finishes
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 white
# Indicates function modules that are not subjected to masking. Discarded when constructor finishes # Indicates function modules that are not subjected to masking. Discarded when constructor finishes
self._isfunction = [[False] * self._size for _ in range(self._size)] self._isfunction = [[False] * self._size for _ in range(self._size)]
@ -195,20 +195,20 @@ class QrCode(object):
# ---- Accessor methods ---- # ---- Accessor methods ----
def get_version(self): def get_version(self):
"""Returns this QR Code symbol's version number, which is always between 1 and 40 (inclusive).""" """Returns this QR Code's version number, which is always between 1 and 40 (inclusive)."""
return self._version return self._version
def get_size(self): def get_size(self):
"""Returns the width and height of this QR Code symbol, measured in modules. """Returns the width and height of this QR Code, measured in modules.
Always equal to version * 4 + 17, in the range 21 to 177.""" Always equal to version * 4 + 17, in the range 21 to 177."""
return self._size return self._size
def get_error_correction_level(self): def get_error_correction_level(self):
"""Returns the error correction level used in this QR Code symbol.""" """Returns the error correction level used in this QR Code."""
return self._errcorlvl return self._errcorlvl
def get_mask(self): def get_mask(self):
"""Returns the mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). """Returns the mask pattern used in this QR Code, in the range 0 to 7 (i.e. unsigned 3-bit integer).
Note that even if a constructor was called with automatic masking requested Note that even if a constructor was called with automatic masking requested
(mask = -1), the resulting object will still have a mask value between 0 and 7.""" (mask = -1), the resulting object will still have a mask value between 0 and 7."""
return self._mask return self._mask
@ -223,7 +223,7 @@ class QrCode(object):
# ---- Public instance methods ---- # ---- Public instance methods ----
def to_svg_str(self, border): def to_svg_str(self, border):
"""Returns a string of SVG XML code representing an image of this QR Code symbol with the given """Returns a string of SVG XML code representing an image of this QR Code with the given
number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform.""" number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform."""
if border < 0: if border < 0:
raise ValueError("Border must be non-negative") raise ValueError("Border must be non-negative")
@ -387,7 +387,7 @@ class QrCode(object):
def _draw_codewords(self, data): def _draw_codewords(self, data):
"""Draws the given sequence of 8-bit codewords (data and error correction) onto the entire """Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
data area of this QR Code symbol. Function modules need to be marked off before this is called.""" data area of this QR Code. Function modules need to be marked off before this is called."""
assert len(data) == QrCode._get_num_raw_data_modules(self._version) // 8 assert len(data) == QrCode._get_num_raw_data_modules(self._version) // 8
i = 0 # Bit index into the data i = 0 # Bit index into the data
@ -413,7 +413,7 @@ class QrCode(object):
The function modules must be marked and the codeword bits must be drawn The function modules must be marked and the codeword bits must be drawn
before masking. Due to the arithmetic of XOR, calling applyMask() with before masking. Due to the arithmetic of XOR, calling applyMask() with
the same mask value a second time will undo the mask. A final well-formed the same mask value a second time will undo the mask. A final well-formed
QR Code symbol needs exactly one (not zero, two, etc.) mask applied.""" QR Code needs exactly one (not zero, two, etc.) mask applied."""
if not (0 <= mask <= 7): if not (0 <= mask <= 7):
raise ValueError("Mask value out of range") raise ValueError("Mask value out of range")
masker = QrCode._MASK_PATTERNS[mask] masker = QrCode._MASK_PATTERNS[mask]

@ -33,24 +33,24 @@ pub struct QrCode {
// Scalar parameters: // Scalar parameters:
// This QR Code symbol's version number, which is always between 1 and 40 (inclusive). // This QR Code's version number, which is always between 1 and 40 (inclusive).
version: Version, version: Version,
// The width and height of this QR Code symbol, measured in modules. // The width and height of this QR Code, measured in modules.
// Always equal to version * 4 + 17, in the range 21 to 177. // Always equal to version * 4 + 17, in the range 21 to 177.
size: i32, size: i32,
// The error correction level used in this QR Code symbol. // The error correction level used in this QR Code.
errorcorrectionlevel: QrCodeEcc, errorcorrectionlevel: QrCodeEcc,
// The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). // The mask pattern used in this QR Code, in the range 0 to 7 (i.e. unsigned 3-bit integer).
// Note that even if a constructor was called with automatic masking requested // Note that even if a constructor was called with automatic masking requested
// (mask = -1), the resulting object will still have a mask value between 0 and 7. // (mask = -1), the resulting object will still have a mask value between 0 and 7.
mask: Mask, mask: Mask,
// Grids of modules/pixels, with dimensions of size*size: // Grids of modules/pixels, with dimensions of size*size:
// The modules of this QR Code symbol (false = white, true = black). Immutable after constructor finishes. // The modules of this QR Code (false = white, true = black). Immutable after constructor finishes.
modules: Vec<bool>, modules: Vec<bool>,
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes. // Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
@ -63,7 +63,7 @@ impl QrCode {
/*---- Static factory functions (high level) ----*/ /*---- Static factory functions (high level) ----*/
// Returns a QR Code symbol representing the given Unicode text string at the given error correction level. // Returns a QR Code representing the given Unicode text string at the given error correction level.
// As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer Unicode // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer Unicode
// code points (not UTF-8 code units) if the low error correction level is used. The smallest possible // code points (not UTF-8 code units) if the low error correction level is used. The smallest possible
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than
@ -76,7 +76,7 @@ impl QrCode {
} }
// Returns a QR Code symbol representing the given binary data string at the given error correction level. // Returns a QR Code representing the given binary data string at the given error correction level.
// This function always encodes using the binary segment mode, not any text mode. The maximum number of // This function always encodes using the binary segment mode, not any text mode. The maximum number of
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
@ -89,7 +89,7 @@ impl QrCode {
/*---- Static factory functions (mid level) ----*/ /*---- Static factory functions (mid level) ----*/
// Returns a QR Code symbol representing the given segments at the given error correction level. // Returns a QR Code representing the given segments at the given error correction level.
// The smallest possible QR Code version is automatically chosen for the output. The ECC level // The smallest possible QR Code version is automatically chosen for the output. The ECC level
// of the result may be higher than the ecl argument if it can be done without increasing the version. // of the result may be higher than the ecl argument if it can be done without increasing the version.
// This function allows the user to create a custom sequence of segments that switches // This function allows the user to create a custom sequence of segments that switches
@ -101,7 +101,7 @@ impl QrCode {
} }
// Returns a QR Code symbol representing the given segments with the given encoding parameters. // Returns a QR Code representing the given segments with the given encoding parameters.
// The smallest possible QR Code version within the given range is automatically chosen for the output. // The smallest possible QR Code version within the given range is automatically chosen for the output.
// This function allows the user to create a custom sequence of segments that switches // This function allows the user to create a custom sequence of segments that switches
// between modes (such as alphanumeric and binary) to encode text more efficiently. // between modes (such as alphanumeric and binary) to encode text more efficiently.
@ -168,14 +168,14 @@ impl QrCode {
bytes[i >> 3] |= (*bit as u8) << (7 - (i & 7)); bytes[i >> 3] |= (*bit as u8) << (7 - (i & 7));
} }
// Create the QR Code symbol // Create the QR Code object
Some(QrCode::encode_codewords(version, ecl, &bytes, mask)) Some(QrCode::encode_codewords(version, ecl, &bytes, mask))
} }
/*---- Constructor (low level) ----*/ /*---- Constructor (low level) ----*/
// Creates a new QR Code symbol with the given version number, error correction level, // Creates a new QR Code with the given version number, error correction level,
// binary data array, and mask number. This is a cumbersome low-level constructor that // binary data array, and mask number. This is a cumbersome low-level constructor that
// should not be invoked directly by the user. To go one level up, see the encode_segments() function. // should not be invoked directly by the user. To go one level up, see the encode_segments() function.
pub fn encode_codewords(ver: Version, ecl: QrCodeEcc, datacodewords: &[u8], mask: Option<Mask>) -> Self { pub fn encode_codewords(ver: Version, ecl: QrCodeEcc, datacodewords: &[u8], mask: Option<Mask>) -> Self {
@ -247,7 +247,7 @@ impl QrCode {
} }
// Returns a string of SVG XML code representing an image of this QR Code symbol with the given // Returns a string of SVG XML code representing an image of this QR Code with the given
// number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform. // number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform.
pub fn to_svg_string(&self, border: i32) -> String { pub fn to_svg_string(&self, border: i32) -> String {
assert!(border >= 0, "Border must be non-negative"); assert!(border >= 0, "Border must be non-negative");
@ -452,7 +452,7 @@ impl QrCode {
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
// data area of this QR Code symbol. Function modules need to be marked off before this is called. // data area of this QR Code. Function modules need to be marked off before this is called.
fn draw_codewords(&mut self, data: &[u8]) { fn draw_codewords(&mut self, data: &[u8]) {
assert_eq!(data.len(), QrCode::get_num_raw_data_modules(self.version) / 8, "Illegal argument"); assert_eq!(data.len(), QrCode::get_num_raw_data_modules(self.version) / 8, "Illegal argument");
@ -486,7 +486,7 @@ impl QrCode {
// The function modules must be marked and the codeword bits must be drawn // The function modules must be marked and the codeword bits must be drawn
// before masking. Due to the arithmetic of XOR, calling applyMask() with // before masking. Due to the arithmetic of XOR, calling applyMask() with
// the same mask value a second time will undo the mask. A final well-formed // the same mask value a second time will undo the mask. A final well-formed
// QR Code symbol needs exactly one (not zero, two, etc.) mask applied. // QR Code needs exactly one (not zero, two, etc.) mask applied.
fn apply_mask(&mut self, mask: Mask) { fn apply_mask(&mut self, mask: Mask) {
let mask: u8 = mask.value(); let mask: u8 = mask.value();
for y in 0 .. self.size { for y in 0 .. self.size {

@ -38,7 +38,7 @@ namespace qrcodegen {
* provides static functions to create a QR Code from user-supplied textual or binary data. * provides static functions to create a QR Code from user-supplied textual or binary data.
* This class covers the QR Code Model 2 specification, supporting all versions (sizes) * This 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. * from 1 to 40, all 4 error correction levels, and 4 character encoding modes.
* This constructor creates a new QR Code symbol with the given version number, error correction level, binary data array, * This constructor creates a new QR Code with the given version number, error correction level, binary data array,
* and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor * and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor
* that should not be invoked directly by the user. To go one level up, see the QrCode.encodeSegments() function. * that should not be invoked directly by the user. To go one level up, see the QrCode.encodeSegments() function.
*/ */
@ -46,7 +46,7 @@ namespace qrcodegen {
/*-- Static factory functions (high level) --*/ /*-- Static factory functions (high level) --*/
// Returns a QR Code symbol representing the given Unicode text string at the given error correction level. // Returns a QR Code representing the given Unicode text string at the given error correction level.
// As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
// Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
@ -57,7 +57,7 @@ namespace qrcodegen {
} }
// Returns a QR Code symbol representing the given binary data string at the given error correction level. // Returns a QR Code representing the given binary data string at the given error correction level.
// This function always encodes using the binary segment mode, not any text mode. The maximum number of // This function always encodes using the binary segment mode, not any text mode. The maximum number of
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
@ -69,7 +69,7 @@ namespace qrcodegen {
/*-- Static factory functions (mid level) --*/ /*-- Static factory functions (mid level) --*/
// Returns a QR Code symbol representing the given segments with the given encoding parameters. // Returns a QR Code representing the given segments with the given encoding parameters.
// The smallest possible QR Code version within the given range is automatically chosen for the output. // The smallest possible QR Code version within the given range is automatically chosen for the output.
// This function allows the user to create a custom sequence of segments that switches // This function allows the user to create a custom sequence of segments that switches
// between modes (such as alphanumeric and binary) to encode text more efficiently. // between modes (such as alphanumeric and binary) to encode text more efficiently.
@ -126,18 +126,18 @@ namespace qrcodegen {
for (let padByte = 0xEC; bb.length < dataCapacityBits; padByte ^= 0xEC ^ 0x11) for (let padByte = 0xEC; bb.length < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
bb.appendBits(padByte, 8); bb.appendBits(padByte, 8);
// Create the QR Code symbol // Create the QR Code object
return new QrCode(version, ecl, bb.getBytes(), mask); return new QrCode(version, ecl, bb.getBytes(), mask);
} }
/*-- Fields --*/ /*-- Fields --*/
// The width and height of this QR Code symbol, measured in modules. // The width and height of this QR Code, measured in modules.
// Always equal to version * 4 + 17, in the range 21 to 177. // Always equal to version * 4 + 17, in the range 21 to 177.
public readonly size: int; public readonly size: int;
// The modules of this QR Code symbol (false = white, true = black). Immutable after constructor finishes. // The modules of this QR Code (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. // Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
@ -147,15 +147,15 @@ namespace qrcodegen {
/*-- Constructor (low level) and fields --*/ /*-- Constructor (low level) and fields --*/
public constructor( public constructor(
// This QR Code symbol's version number, which is always between 1 and 40 (inclusive). // This QR Code's version number, which is always between 1 and 40 (inclusive).
public readonly version: int, public readonly version: int,
// The error correction level used in this QR Code symbol. // The error correction level used in this QR Code.
public readonly errorCorrectionLevel: QrCode.Ecc, public readonly errorCorrectionLevel: QrCode.Ecc,
dataCodewords: Array<byte>, dataCodewords: Array<byte>,
// The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). // The mask pattern used in this QR Code, in the range 0 to 7 (i.e. unsigned 3-bit integer).
// Note that even if the constructor was called with automatic masking requested // Note that even if the constructor was called with automatic masking requested
// (mask = -1), the resulting object will still have a mask value between 0 and 7. // (mask = -1), the resulting object will still have a mask value between 0 and 7.
public readonly mask: int) { public readonly mask: int) {
@ -217,7 +217,7 @@ namespace qrcodegen {
/*-- Public instance methods --*/ /*-- Public instance methods --*/
// Draws this QR Code symbol with the given module scale and number of modules onto the given HTML canvas element. // Draws this QR Code with the given module scale and number of modules onto the given HTML canvas element.
// The canvas will be resized to a width and height of (this.size + border * 2) * scale. The painted image will be purely // The canvas will be resized to a width and height of (this.size + border * 2) * scale. The painted image will be purely
// black and white with no transparent regions. The scale must be a positive integer, and the border must be a non-negative integer. // black and white with no transparent regions. 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 { public drawCanvas(scale: int, border: int, canvas: HTMLCanvasElement): void {
@ -236,7 +236,7 @@ namespace qrcodegen {
} }
// Returns a string of SVG XML code representing an image of this QR Code symbol with the given // Returns a string of SVG XML code representing an image of this QR Code with the given
// number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform. // number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform.
public toSvgString(border: int): string { public toSvgString(border: int): string {
if (border < 0) if (border < 0)
@ -423,7 +423,7 @@ namespace qrcodegen {
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
// data area of this QR Code symbol. Function modules need to be marked off before this is called. // data area of this QR Code. Function modules need to be marked off before this is called.
private drawCodewords(data: Array<byte>): void { private drawCodewords(data: Array<byte>): void {
if (data.length != Math.floor(QrCode.getNumRawDataModules(this.version) / 8)) if (data.length != Math.floor(QrCode.getNumRawDataModules(this.version) / 8))
throw "Invalid argument"; throw "Invalid argument";
@ -455,7 +455,7 @@ namespace qrcodegen {
// The function modules must be marked and the codeword bits must be drawn // The function modules must be marked and the codeword bits must be drawn
// before masking. Due to the arithmetic of XOR, calling applyMask() with // before masking. Due to the arithmetic of XOR, calling applyMask() with
// the same mask value a second time will undo the mask. A final well-formed // the same mask value a second time will undo the mask. A final well-formed
// QR Code symbol needs exactly one (not zero, two, etc.) mask applied. // QR Code needs exactly one (not zero, two, etc.) mask applied.
private applyMask(mask: int): void { private applyMask(mask: int): void {
if (mask < 0 || mask > 7) if (mask < 0 || mask > 7)
throw "Mask value out of range"; throw "Mask value out of range";

Loading…
Cancel
Save