Updated and synchronized documentation comments for QrCode's instance methods, in all languages.

pull/39/merge
Project Nayuki 7 years ago
parent 76f97dd0b8
commit f011e52770

@ -297,8 +297,8 @@ int qrcodegen_getSize(const uint8_t qrcode[]);
/*
* Returns the color of the module (pixel) at the given coordinates, which is either
* false for white or true for black. The top left corner has the coordinates (x=0, y=0).
* Returns the color of the module (pixel) at the given coordinates, which is false
* for white or true for black. The top left corner has the coordinates (x=0, y=0).
* If the given coordinates are out of bounds, then false (white) is returned.
*/
bool qrcodegen_getModule(const uint8_t qrcode[], int x, int y);

@ -163,16 +163,16 @@ class QrCode final {
/*
* Returns the color of the module (pixel) at the given coordinates, which is either
* false for white or true for black. The top left corner has the coordinates (x=0, y=0).
* Returns the color of the module (pixel) at the given coordinates, which is false
* for white or true for black. The top left corner has the coordinates (x=0, y=0).
* If the given coordinates are out of bounds, then false (white) is returned.
*/
public: bool getModule(int x, int y) const;
/*
* 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.
* Returns a string of SVG code for an image depicting this QR Code, with the given number
* of border modules. The string always uses Unix newlines (\n), regardless of the platform.
*/
public: std::string toSvgString(int border) const;

@ -260,9 +260,9 @@ public final class QrCode {
/*---- Public instance methods ----*/
/**
* Returns the color of the module (pixel) at the specified coordinates, which is either
* false for white or true for black. The top left corner has the coordinates (x=0, y=0).
* If the specified coordinates are out of bounds, then false (white) is returned.
* Returns the color of the module (pixel) at the specified coordinates, which is {@code false}
* for white or {@code true} for black. The top left corner has the coordinates (x=0, y=0).
* If the specified coordinates are out of bounds, then {@code false} (white) is returned.
* @param x the x coordinate, where 0 is the left edge and size−1 is the right edge
* @param y the y coordinate, where 0 is the top edge and size−1 is the bottom edge
* @return the module's color, which is either false (white) or true (black)
@ -273,9 +273,9 @@ 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
* with 4 white border modules on all four edges, then use 10*10 pixels to represent each module.
* Returns a raster image depicting this QR Code, with the specified module scale and border modules.
* <p>For example, toImage(scale=10, border=4) means to pad the QR Code with 4 white
* border modules on all four sides, and use 10&#xD7;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
* @param border the number of border modules to add, which must be non-negative
@ -301,8 +301,8 @@ public final class QrCode {
/**
* 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.
* Returns a string of SVG code for an image depicting this QR Code, with the specified number
* of border modules. The string always uses Unix newlines (\n), 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
* @throws IllegalArgumentException if the border is negative

@ -152,8 +152,8 @@ var qrcodegen = new function() {
/*---- Accessor methods ----*/
// (Public) Returns the color of the module (pixel) at the given coordinates, which is either
// false for white or true for black. The top left corner has the coordinates (x=0, y=0).
// Returns the color of the module (pixel) at the given coordinates, which is false
// for white or true for black. The top left corner has the coordinates (x=0, y=0).
// If the given coordinates are out of bounds, then false (white) is returned.
this.getModule = function(x, y) {
return 0 <= x && x < size && 0 <= y && y < size && modules[y][x];
@ -162,9 +162,10 @@ var qrcodegen = new function() {
/*---- Public instance methods ----*/
// 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.
// Draws this QR Code, with the given module scale and border modules, onto the given HTML
// canvas element. The canvas's width and height is resized to (this.size + border * 2) * scale.
// The drawn image is be purely black and white, and fully opaque.
// The scale must be a positive integer and the border must be a non-negative integer.
this.drawCanvas = function(scale, border, canvas) {
if (scale <= 0 || border < 0)
throw "Value out of range";
@ -180,8 +181,8 @@ var qrcodegen = new function() {
}
};
// 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.
// Returns a string of SVG code for an image depicting this QR Code, with the given number
// of border modules. The string always uses Unix newlines (\n), regardless of the platform.
this.toSvgString = function(border) {
if (border < 0)
throw "Border must be non-negative";

@ -241,8 +241,8 @@ class QrCode(object):
return self._mask
def get_module(self, x, y):
"""Returns the color of the module (pixel) at the given coordinates, which is either
False for white or True for black. The top left corner has the coordinates (x=0, y=0).
"""Returns the color of the module (pixel) at the given coordinates, which is False
for white or True for black. The top left corner has the coordinates (x=0, y=0).
If the given coordinates are out of bounds, then False (white) is returned."""
return (0 <= x < self._size) and (0 <= y < self._size) and self._modules[y][x]
@ -250,8 +250,8 @@ 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 with the given
number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform."""
"""Returns a string of SVG code for an image depicting this QR Code, with the given number
of border modules. The string always uses Unix newlines (\n), regardless of the platform."""
if border < 0:
raise ValueError("Border must be non-negative")
parts = []

@ -246,9 +246,9 @@ impl QrCode {
}
// Returns the color of the module (pixel) at the given coordinates, which is either
// false for white or true for black. The top left corner has the coordinates (x=0, y=0).
// If the given coordinates are out of bounds, then 0 (white) is returned.
// Returns the color of the module (pixel) at the given coordinates, which is false
// for white or true for black. The top left corner has the coordinates (x=0, y=0).
// If the given coordinates are out of bounds, then false (white) is returned.
pub fn get_module(&self, x: i32, y: i32) -> bool {
0 <= x && x < self.size && 0 <= y && y < self.size && self.module(x, y)
}
@ -266,8 +266,8 @@ impl QrCode {
}
// 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.
// Returns a string of SVG code for an image depicting this QR Code, with the given number
// of border modules. The string always uses Unix newlines (\n), regardless of the platform.
pub fn to_svg_string(&self, border: i32) -> String {
assert!(border >= 0, "Border must be non-negative");
let mut result = String::new();

@ -223,8 +223,8 @@ namespace qrcodegen {
/*-- Accessor methods --*/
// Returns the color of the module (pixel) at the given coordinates, which is either
// false for white or true for black. The top left corner has the coordinates (x=0, y=0).
// Returns the color of the module (pixel) at the given coordinates, which is false
// for white or true for black. The top left corner has the coordinates (x=0, y=0).
// If the given coordinates are out of bounds, then false (white) is returned.
public getModule(x: int, y: int): boolean {
return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];
@ -233,9 +233,10 @@ namespace qrcodegen {
/*-- Public instance methods --*/
// 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.
// Draws this QR Code, with the given module scale and border modules, onto the given HTML
// canvas element. The canvas's width and height is resized to (this.size + border * 2) * scale.
// The drawn image is be purely black and white, and fully opaque.
// The scale must be a positive integer and the border must be a non-negative integer.
public drawCanvas(scale: int, border: int, canvas: HTMLCanvasElement): void {
if (scale <= 0 || border < 0)
throw "Value out of range";
@ -252,8 +253,8 @@ namespace qrcodegen {
}
// 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.
// Returns a string of SVG code for an image depicting this QR Code, with the given number
// of border modules. The string always uses Unix newlines (\n), regardless of the platform.
public toSvgString(border: int): string {
if (border < 0)
throw "Border must be non-negative";

Loading…
Cancel
Save