Reduced the use of the word "symbol" when referring to QR Codes, in all languages.
This commit is contained in:
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
|
||||
// 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
|
||||
// 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) {
|
||||
assert(0 <= (int)mask && (int)mask <= 7); // Disallows qrcodegen_Mask_AUTO
|
||||
int qrsize = qrcodegen_getSize(qrcode);
|
||||
|
|
|
@ -133,7 +133,7 @@ struct qrcodegen_Segment {
|
|||
/*---- 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
|
||||
* at the given ECC level, then false is returned.
|
||||
* - 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
|
||||
* at the given ECC level, then false is returned.
|
||||
* - 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
|
||||
* 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.
|
||||
|
@ -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.
|
||||
* 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
|
||||
|
|
|
@ -109,7 +109,7 @@ QrCode QrCode::encodeSegments(const vector<QrSegment> &segs, Ecc ecl,
|
|||
for (uint8_t padByte = 0xEC; bb.size() < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
|
||||
bb.appendBits(padByte, 8);
|
||||
|
||||
// Create the QR Code symbol
|
||||
// Create the QR Code object
|
||||
return QrCode(version, ecl, bb.getBytes(), mask);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class QrCode final {
|
|||
/*---- 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
|
||||
* 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
|
||||
|
@ -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
|
||||
* 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.
|
||||
|
@ -81,7 +81,7 @@ class QrCode final {
|
|||
/*---- 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.
|
||||
* 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.
|
||||
|
@ -96,24 +96,24 @@ class QrCode final {
|
|||
|
||||
// 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;
|
||||
|
||||
/* 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. */
|
||||
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;
|
||||
|
||||
/* 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
|
||||
* (mask = -1), the resulting object will still have a mask value between 0 and 7. */
|
||||
private: int mask;
|
||||
|
||||
// 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;
|
||||
|
||||
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
|
||||
|
@ -124,7 +124,7 @@ class QrCode final {
|
|||
/*---- 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.
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
// 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);
|
||||
|
||||
|
||||
|
@ -213,7 +213,7 @@ class QrCode final {
|
|||
// The function modules must be marked and the codeword bits must be drawn
|
||||
// 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
|
||||
// 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);
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public final class QrCode {
|
|||
/*---- 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
|
||||
* 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
|
||||
|
@ -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
|
||||
* 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.
|
||||
|
@ -83,7 +83,7 @@ public final class QrCode {
|
|||
/*---- 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
|
||||
* 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
|
||||
|
@ -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.
|
||||
* <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.
|
||||
|
@ -163,7 +163,7 @@ public final class QrCode {
|
|||
for (int padByte = 0xEC; bb.bitLength() < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
|
||||
bb.appendBits(padByte, 8);
|
||||
|
||||
// Create the QR Code symbol
|
||||
// Create the QR Code object
|
||||
return new QrCode(version, ecl, bb.getBytes(), mask);
|
||||
}
|
||||
|
||||
|
@ -173,24 +173,24 @@ public final class QrCode {
|
|||
|
||||
// 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;
|
||||
|
||||
/** 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 (inclusive). */
|
||||
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;
|
||||
|
||||
/** 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
|
||||
* (mask = -1), the resulting object will still have a mask value between 0 and 7. */
|
||||
public final int mask;
|
||||
|
||||
// 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;
|
||||
|
||||
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
|
||||
|
@ -201,7 +201,7 @@ public final class QrCode {
|
|||
/*---- 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.
|
||||
* 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)
|
||||
|
@ -252,7 +252,7 @@ public final class QrCode {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* The resulting image only contains the hex colors 000000 and FFFFFF.
|
||||
* @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.
|
||||
* @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
|
||||
|
@ -474,7 +474,7 @@ public final class QrCode {
|
|||
|
||||
|
||||
// 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) {
|
||||
Objects.requireNonNull(data);
|
||||
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
|
||||
// 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
|
||||
// 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) {
|
||||
if (mask < 0 || mask > 7)
|
||||
throw new IllegalArgumentException("Mask value out of range");
|
||||
|
@ -670,7 +670,7 @@ public final class QrCode {
|
|||
throw new IllegalArgumentException("Version number out of range");
|
||||
|
||||
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 -= 15 * 2 + 1; // Subtract the format information and black module
|
||||
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.
|
||||
* 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.
|
||||
* 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
|
||||
* 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 ----*/
|
||||
|
||||
// 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});
|
||||
|
||||
// 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.
|
||||
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});
|
||||
|
||||
// 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
|
||||
// (mask = -1), the resulting object will still have a mask value between 0 and 7.
|
||||
Object.defineProperty(this, "mask", {value:mask});
|
||||
|
@ -149,7 +149,7 @@ var qrcodegen = new function() {
|
|||
|
||||
/*---- 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
|
||||
// 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) {
|
||||
|
@ -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.
|
||||
this.toSvgString = function(border) {
|
||||
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
|
||||
// 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) {
|
||||
if (data.length != Math.floor(QrCode.getNumRawDataModules(version) / 8))
|
||||
throw "Invalid argument";
|
||||
|
@ -383,7 +383,7 @@ var qrcodegen = new function() {
|
|||
// The function modules must be marked and the codeword bits must be drawn
|
||||
// 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
|
||||
// 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) {
|
||||
if (mask < 0 || mask > 7)
|
||||
throw "Mask value out of range";
|
||||
|
@ -516,7 +516,7 @@ var qrcodegen = new function() {
|
|||
/*---- 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
|
||||
* 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
|
||||
|
@ -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
|
||||
* 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.
|
||||
|
@ -543,7 +543,7 @@ var qrcodegen = new function() {
|
|||
/*---- 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.
|
||||
* 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.
|
||||
|
@ -599,7 +599,7 @@ var qrcodegen = new function() {
|
|||
for (var padByte = 0xEC; bb.length < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
|
||||
bb.appendBits(padByte, 8);
|
||||
|
||||
// Create the QR Code symbol
|
||||
// Create the QR Code object
|
||||
return new this(version, ecl, bb.getBytes(), mask);
|
||||
};
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ class QrCode(object):
|
|||
|
||||
@staticmethod
|
||||
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
|
||||
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
|
||||
|
@ -81,7 +81,7 @@ class QrCode(object):
|
|||
|
||||
@staticmethod
|
||||
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
|
||||
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."""
|
||||
|
@ -94,7 +94,7 @@ class QrCode(object):
|
|||
|
||||
@staticmethod
|
||||
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.
|
||||
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.
|
||||
|
@ -140,14 +140,14 @@ class QrCode(object):
|
|||
break
|
||||
bb.append_bits(padbyte, 8)
|
||||
|
||||
# Create the QR Code symbol
|
||||
# Create the QR Code object
|
||||
return QrCode(version, ecl, bb.get_bytes(), mask)
|
||||
|
||||
|
||||
# ---- Constructor (low level) ----
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
# 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
|
||||
# Indicates function modules that are not subjected to masking. Discarded when constructor finishes
|
||||
self._isfunction = [[False] * self._size for _ in range(self._size)]
|
||||
|
@ -195,20 +195,20 @@ class QrCode(object):
|
|||
# ---- Accessor methods ----
|
||||
|
||||
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
|
||||
|
||||
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."""
|
||||
return self._size
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
(mask = -1), the resulting object will still have a mask value between 0 and 7."""
|
||||
return self._mask
|
||||
|
@ -223,7 +223,7 @@ class QrCode(object):
|
|||
# ---- Public instance methods ----
|
||||
|
||||
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."""
|
||||
if border < 0:
|
||||
raise ValueError("Border must be non-negative")
|
||||
|
@ -387,7 +387,7 @@ class QrCode(object):
|
|||
|
||||
def _draw_codewords(self, data):
|
||||
"""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
|
||||
|
||||
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
|
||||
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
|
||||
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):
|
||||
raise ValueError("Mask value out of range")
|
||||
masker = QrCode._MASK_PATTERNS[mask]
|
||||
|
|
|
@ -33,24 +33,24 @@ pub struct QrCode {
|
|||
|
||||
// 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,
|
||||
|
||||
// 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.
|
||||
size: i32,
|
||||
|
||||
// The error correction level used in this QR Code symbol.
|
||||
// The error correction level used in this QR Code.
|
||||
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
|
||||
// (mask = -1), the resulting object will still have a mask value between 0 and 7.
|
||||
mask: Mask,
|
||||
|
||||
// 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>,
|
||||
|
||||
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
|
||||
|
@ -63,7 +63,7 @@ impl QrCode {
|
|||
|
||||
/*---- 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
|
||||
// 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
|
||||
|
@ -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
|
||||
// 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.
|
||||
|
@ -89,7 +89,7 @@ impl QrCode {
|
|||
|
||||
/*---- 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
|
||||
// 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
|
||||
|
@ -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.
|
||||
// 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.
|
||||
|
@ -168,14 +168,14 @@ impl QrCode {
|
|||
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))
|
||||
}
|
||||
|
||||
|
||||
/*---- 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
|
||||
// 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 {
|
||||
|
@ -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.
|
||||
pub fn to_svg_string(&self, border: i32) -> String {
|
||||
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
|
||||
// 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]) {
|
||||
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
|
||||
// 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
|
||||
// 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) {
|
||||
let mask: u8 = mask.value();
|
||||
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.
|
||||
* 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.
|
||||
* 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
|
||||
* 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) --*/
|
||||
|
||||
// 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 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
|
||||
|
@ -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
|
||||
// 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.
|
||||
|
@ -69,7 +69,7 @@ namespace qrcodegen {
|
|||
|
||||
/*-- 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.
|
||||
// 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.
|
||||
|
@ -126,18 +126,18 @@ namespace qrcodegen {
|
|||
for (let padByte = 0xEC; bb.length < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
|
||||
bb.appendBits(padByte, 8);
|
||||
|
||||
// Create the QR Code symbol
|
||||
// Create the QR Code object
|
||||
return new QrCode(version, ecl, bb.getBytes(), mask);
|
||||
}
|
||||
|
||||
|
||||
/*-- 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.
|
||||
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>> = [];
|
||||
|
||||
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
|
||||
|
@ -147,15 +147,15 @@ namespace qrcodegen {
|
|||
/*-- Constructor (low level) and fields --*/
|
||||
|
||||
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,
|
||||
|
||||
// The error correction level used in this QR Code symbol.
|
||||
// The error correction level used in this QR Code.
|
||||
public readonly errorCorrectionLevel: QrCode.Ecc,
|
||||
|
||||
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
|
||||
// (mask = -1), the resulting object will still have a mask value between 0 and 7.
|
||||
public readonly mask: int) {
|
||||
|
@ -217,7 +217,7 @@ namespace qrcodegen {
|
|||
|
||||
/*-- 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
|
||||
// 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 {
|
||||
|
@ -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.
|
||||
public toSvgString(border: int): string {
|
||||
if (border < 0)
|
||||
|
@ -423,7 +423,7 @@ namespace qrcodegen {
|
|||
|
||||
|
||||
// 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 {
|
||||
if (data.length != Math.floor(QrCode.getNumRawDataModules(this.version) / 8))
|
||||
throw "Invalid argument";
|
||||
|
@ -455,7 +455,7 @@ namespace qrcodegen {
|
|||
// The function modules must be marked and the codeword bits must be drawn
|
||||
// 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
|
||||
// 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 {
|
||||
if (mask < 0 || mask > 7)
|
||||
throw "Mask value out of range";
|
||||
|
|
Loading…
Reference in New Issue