예제 #1
0
파일: __init__.py 프로젝트: 0shape/pyqrcode
    def terminal(self,
                 module_color='default',
                 background='reverse',
                 quiet_zone=4):
        """This method returns a string containing ASCII escape codes,
        such that if printed to a compatible terminal, it will display
        a vaild QR code. The code is printed using ASCII escape
        codes that alter the coloring of the background.

        The *module_color* parameter sets what color to
        use for the data modules (the black part on most QR codes).
        Likewise, the *background* parameter sets what color to use
        for the background (the white part on most QR codes).  

        There are two options for colors. The first, and most widely
        supported, is to use the 8 or 16 color scheme. This scheme uses
        eight to sixteen named colors. The following colors are
        supported the most widely supported: black, red, green,
        yellow, blue, magenta, and cyan. There are an some additional
        named colors that are supported by most terminals: light gray,
        dark gray, light red, light green, light blue, light yellow,
        light magenta, light cyan, and white. 

        There are two special named colors. The first is the
        "default" color. This color is the color the background of
        the terminal is set to. The next color is the "reverse"
        color. This is not really a color at all but a special
        property that will reverse the current color. These two colors
        are the default values for *module_color* and *background*
        respectively. These values should work on most terminals.

        Finally, there is one more way to specify the color. Some
        terminals support 256 colors. The actual colors displayed in the
        terminal is system dependent. This is the least transportable option.
        To use the 256 color scheme set *module_color* and/or
        *background* to a number between 0 and 256.

        The *quiet_zone* parameter sets how wide the quiet zone around the code
        should be. According to the standard this should be 4 modules. It is
        left settable because such a wide quiet zone is unnecessary in many
        applications.

        Example:
            >>> code = pyqrcode.create('Example')
            >>> text = code.terminal()
            >>> print(text)
        """
        return builder._terminal(self.code, module_color, background,
                                 quiet_zone)
예제 #2
0
    def terminal(self, module_color='default', background='reverse',
                 quiet_zone=4):
        """This method returns a string containing ASCII escape codes,
        such that if printed to a compatible terminal, it will display
        a vaild QR code. The code is printed using ASCII escape
        codes that alter the coloring of the background.

        The *module_color* parameter sets what color to
        use for the data modules (the black part on most QR codes).
        Likewise, the *background* parameter sets what color to use
        for the background (the white part on most QR codes).  

        There are two options for colors. The first, and most widely
        supported, is to use the 8 or 16 color scheme. This scheme uses
        eight to sixteen named colors. The following colors are
        supported the most widely supported: black, red, green,
        yellow, blue, magenta, and cyan. There are an some additional
        named colors that are supported by most terminals: light gray,
        dark gray, light red, light green, light blue, light yellow,
        light magenta, light cyan, and white. 

        There are two special named colors. The first is the
        "default" color. This color is the color the background of
        the terminal is set to. The next color is the "reverse"
        color. This is not really a color at all but a special
        property that will reverse the current color. These two colors
        are the default values for *module_color* and *background*
        respectively. These values should work on most terminals.

        Finally, there is one more way to specify the color. Some
        terminals support 256 colors. The actual colors displayed in the
        terminal is system dependent. This is the least transportable option.
        To use the 256 color scheme set *module_color* and/or
        *background* to a number between 0 and 256.

        The *quiet_zone* parameter sets how wide the quiet zone around the code
        should be. According to the standard this should be 4 modules. It is
        left settable because such a wide quiet zone is unnecessary in many
        applications.

        Example:
            >>> code = pyqrcode.create('Example')
            >>> text = code.terminal()
            >>> print(text)
        """
        return builder._terminal(self.code, module_color, background,
                                 quiet_zone)
예제 #3
0
    def terminal(self, module_color='default', background='reverse',
                 quiet_zone=4):
        """这个实例方法返回一种含有 ASCII 转义代码字符串形式。
        如果使用 `print()` 函数输出的话,会在终端里显示成二维码图像。
        使用 ASCII 转义代码输出的二维码在背景色上会有变化。

        其中 *module_color* 参数是设置数据块颜色用的(大部分二维码是黑色)。
        其中 *background* 参数是设置背景色用的(大部分是白色)。

        对于颜色来说,在终端里有两种选择。
        第一种,最广泛支持的就是实用 8 或 16 色彩机制。
        这种色彩机制实用了8到16个颜色名字,分别是:
        black, red, green, yellow, blue, magenta, 和 cyan。
        另外一些颜色名字是:
        light gray, dark gray, light red, light green, 
        light blue, light yellow, light magenta, light cyan, 和 white。 

        这里有两个特殊的颜色名字。
        *module_color* 参数值是 "default",这个颜色是采用
        终端的背景色。
        *background* 参数值是 "reverse",这个颜色实际上不是真正的颜色,
        而是一种特殊的财产值,这个财产值是当前颜色的反向色。
        这两个特殊的颜色名字分别是参数的默认值。
        以上颜色在绝大多数终端里都有效。

        最后,还有一项特殊的颜色。
        有的终端支持 256 色,而实际显示出来的颜色要依赖系统的终端。
        这是比较少用的一种选择。要使用 256 色机制,就是设置
        *module_color* 参数和/或 *background* 参数的值介于 0 到 256 之间。

        其中 *quiet_zone* 参数是设置无噪点区域多宽用的。
        根据二维码标准这个参数值应该是4个数据块。保留成可设置是因为
        在许多应用程序中不需要使用无噪点区域宽。

        Examples:
            >>> code = pyqrcode.create('Example')
            >>> text = code.terminal()
            >>> print(text)
        """
        return builder._terminal(self.code, module_color, background,
                                 quiet_zone)