From f011e527709ff2ce3d4e436f5b05a53cefa46de2 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sat, 6 Oct 2018 03:26:54 +0000 Subject: [PATCH] Updated and synchronized documentation comments for QrCode's instance methods, in all languages. --- c/qrcodegen.h | 4 ++-- cpp/QrCode.hpp | 8 ++++---- java/io/nayuki/qrcodegen/QrCode.java | 16 ++++++++-------- javascript/qrcodegen.js | 15 ++++++++------- python/qrcodegen.py | 8 ++++---- rust/src/lib.rs | 10 +++++----- typescript/qrcodegen.ts | 15 ++++++++------- 7 files changed, 39 insertions(+), 37 deletions(-) diff --git a/c/qrcodegen.h b/c/qrcodegen.h index 4757ed1..13e8eab 100644 --- a/c/qrcodegen.h +++ b/c/qrcodegen.h @@ -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); diff --git a/cpp/QrCode.hpp b/cpp/QrCode.hpp index f552b8f..4d33300 100644 --- a/cpp/QrCode.hpp +++ b/cpp/QrCode.hpp @@ -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; diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index b9bfbff..00364a7 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -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. + *

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×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 diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index c5c778f..2324d3b 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -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"; diff --git a/python/qrcodegen.py b/python/qrcodegen.py index a71a8ba..9c75982 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -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 = [] diff --git a/rust/src/lib.rs b/rust/src/lib.rs index f690350..f68d15b 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -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(); diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index a424b75..2aca061 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -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";