当前位置: 首页>>代码示例>>Python>>正文


Python Canvas.rows方法代码示例

本文整理汇总了Python中drawille.Canvas.rows方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.rows方法的具体用法?Python Canvas.rows怎么用?Python Canvas.rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在drawille.Canvas的用法示例。


在下文中一共展示了Canvas.rows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: render

# 需要导入模块: from drawille import Canvas [as 别名]
# 或者: from drawille.Canvas import rows [as 别名]
    def render(self, width, height, values):
        """
        :type width: int
        :type height: int
        :type values: list[int or float]
        :rtype: list[str or unicode]
        """
        from drawille import Canvas

        vertical_chart_resolution = height * self.char_resolution_vertical
        horizontal_chart_resolution = width * self.char_resolution_horizontal

        canvas = Canvas()
        x = 0
        for value in values:
            for y in range(1, int(round(value, 0)) + 1):
                canvas.set(x, vertical_chart_resolution - y)
            x += 1

        rows = canvas.rows(min_x=0, min_y=0, max_x=horizontal_chart_resolution, max_y=vertical_chart_resolution)

        if not rows:
            rows = [u'' for _ in range(height)]

        for i, row in enumerate(rows):
            rows[i] = u'{0}'.format(row.ljust(width))

        return rows
开发者ID:andras-tim,项目名称:tchart,代码行数:30,代码来源:renderers.py

示例2: main

# 需要导入模块: from drawille import Canvas [as 别名]
# 或者: from drawille.Canvas import rows [as 别名]
def main(args, opts):
    curses.use_default_colors()
    curses.curs_set(0)

    win = curses.initscr()

    source = Image.open(opts.filename)

    c = Canvas()

    try:
        while True:
            (wh, ww) = win.getmaxyx()

            try:
                source.seek(source.tell() + 1)
            except:
                if opts.onetime:
                    break
                source.seek(0)

            img = (source
                    .resize(((ww - 1) * 2, wh * 4))
                    .convert("1")
                    )
            w = img.width

            (x, y) = (0, 0)
            for v in img.getdata():

                if opts.reverse:
                    if not v:
                        c.set(x, y)

                else:
                    if v:
                        c.set(x, y)

                x += 1

                if w <= x:
                    x = 0
                    y += 1

            for r in range(wh):
                line = c.rows(min_y=(r*4), max_y=((r+1)*4))[0]
                win.addnstr(r, 0, pad(line, ww), ww)

            win.refresh()
            c.clear()
            time.sleep(opts.interval)

    except KeyboardInterrupt:
        pass
开发者ID:zaftzaft,项目名称:terminal-anime,代码行数:56,代码来源:main.py


注:本文中的drawille.Canvas.rows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。