Added/tweaked comments and blank lines in demo programs of all language versions except JavaScript.
This commit is contained in:
parent
8fe7878e1e
commit
6a71e09f72
|
@ -40,7 +40,6 @@ static void doMaskDemo(void);
|
||||||
static void printQr(const uint8_t qrcode[]);
|
static void printQr(const uint8_t qrcode[]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The main application program.
|
// The main application program.
|
||||||
int main(void) {
|
int main(void) {
|
||||||
doBasicDemo();
|
doBasicDemo();
|
||||||
|
@ -51,6 +50,9 @@ int main(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---- Demo suite ----*/
|
||||||
|
|
||||||
// Creates a single QR Code, then prints it to the console.
|
// Creates a single QR Code, then prints it to the console.
|
||||||
static void doBasicDemo(void) {
|
static void doBasicDemo(void) {
|
||||||
const char *text = "Hello, world!"; // User-supplied text
|
const char *text = "Hello, world!"; // User-supplied text
|
||||||
|
@ -115,6 +117,7 @@ static void doVarietyDemo(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Creates QR Codes with manually specified segments for better compactness.
|
||||||
static void doSegmentDemo(void) {
|
static void doSegmentDemo(void) {
|
||||||
{ // Illustration "silver"
|
{ // Illustration "silver"
|
||||||
const char *silver0 = "THE SQUARE ROOT OF 2 IS 1.";
|
const char *silver0 = "THE SQUARE ROOT OF 2 IS 1.";
|
||||||
|
@ -290,6 +293,9 @@ static void doMaskDemo(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---- Utilities ----*/
|
||||||
|
|
||||||
// Prints the given QR Code to the console.
|
// Prints the given QR Code to the console.
|
||||||
static void printQr(const uint8_t qrcode[]) {
|
static void printQr(const uint8_t qrcode[]) {
|
||||||
int size = qrcodegen_getSize(qrcode);
|
int size = qrcodegen_getSize(qrcode);
|
||||||
|
|
|
@ -46,7 +46,6 @@ static void doMaskDemo();
|
||||||
static void printQr(const QrCode &qr);
|
static void printQr(const QrCode &qr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The main application program.
|
// The main application program.
|
||||||
int main() {
|
int main() {
|
||||||
doBasicDemo();
|
doBasicDemo();
|
||||||
|
@ -57,6 +56,9 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---- Demo suite ----*/
|
||||||
|
|
||||||
// Creates a single QR Code, then prints it to the console.
|
// Creates a single QR Code, then prints it to the console.
|
||||||
static void doBasicDemo() {
|
static void doBasicDemo() {
|
||||||
const char *text = "Hello, world!"; // User-supplied text
|
const char *text = "Hello, world!"; // User-supplied text
|
||||||
|
@ -181,6 +183,9 @@ static void doMaskDemo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---- Utilities ----*/
|
||||||
|
|
||||||
// Prints the given QR Code to the console.
|
// Prints the given QR Code to the console.
|
||||||
static void printQr(const QrCode &qr) {
|
static void printQr(const QrCode &qr) {
|
||||||
int border = 4;
|
int border = 4;
|
||||||
|
|
|
@ -49,6 +49,9 @@ public final class QrCodeGeneratorDemo {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---- Demo suite ----*/
|
||||||
|
|
||||||
// Creates a single QR Code, then writes it to a PNG file and an SVG file.
|
// Creates a single QR Code, then writes it to a PNG file and an SVG file.
|
||||||
private static void doBasicDemo() throws IOException {
|
private static void doBasicDemo() throws IOException {
|
||||||
String text = "Hello, world!"; // User-supplied Unicode text
|
String text = "Hello, world!"; // User-supplied Unicode text
|
||||||
|
@ -176,6 +179,9 @@ public final class QrCodeGeneratorDemo {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---- Utilities ----*/
|
||||||
|
|
||||||
// Helper function to reduce code duplication.
|
// Helper function to reduce code duplication.
|
||||||
private static void writePng(BufferedImage img, String filepath) throws IOException {
|
private static void writePng(BufferedImage img, String filepath) throws IOException {
|
||||||
ImageIO.write(img, "png", new File(filepath));
|
ImageIO.write(img, "png", new File(filepath));
|
||||||
|
|
|
@ -28,8 +28,6 @@ from __future__ import print_function
|
||||||
import qrcodegen
|
import qrcodegen
|
||||||
|
|
||||||
|
|
||||||
# ---- Main program ----
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""The main application program."""
|
"""The main application program."""
|
||||||
do_basic_demo()
|
do_basic_demo()
|
||||||
|
@ -38,6 +36,9 @@ def main():
|
||||||
do_mask_demo()
|
do_mask_demo()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ---- Demo suite ----
|
||||||
|
|
||||||
def do_basic_demo():
|
def do_basic_demo():
|
||||||
"""Creates a single QR Code, then prints it to the console."""
|
"""Creates a single QR Code, then prints it to the console."""
|
||||||
text = u"Hello, world!" # User-supplied Unicode text
|
text = u"Hello, world!" # User-supplied Unicode text
|
||||||
|
|
|
@ -39,6 +39,9 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---- Demo suite ----*/
|
||||||
|
|
||||||
// Creates a single QR Code, then prints it to the console.
|
// Creates a single QR Code, then prints it to the console.
|
||||||
fn do_basic_demo() {
|
fn do_basic_demo() {
|
||||||
let text: &'static str = "Hello, world!"; // User-supplied Unicode text
|
let text: &'static str = "Hello, world!"; // User-supplied Unicode text
|
||||||
|
@ -155,6 +158,7 @@ fn do_mask_demo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---- Utilities ----*/
|
/*---- Utilities ----*/
|
||||||
|
|
||||||
// Prints the given QrCode object to the console.
|
// Prints the given QrCode object to the console.
|
||||||
|
|
Loading…
Reference in New Issue