matrix.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:matrixgram 作者: samsiegart 项目源码 文件源码
def tick(self, scr, steps, padding_rows, padding_cols, output_rows, output_cols):
        height, width = scr.getmaxyx()
        in_picture_frame = self.y >= padding_rows and self.y <= padding_rows + output_rows and self.x >= padding_cols and self.x <= padding_cols + output_cols
        if self.advances(steps):
            # if window was resized and char is out of bounds, reset
            self.out_of_bounds_reset(width, height)
            # make previous char curses.A_NORMAL
            if not in_picture_frame:
                if USE_COLORS:
                    scr.addstr(self.y, self.x, self.char, curses.color_pair(COLOR_CHAR_NORMAL))
                else:
                    scr.addstr(self.y, self.x, self.char, curses.A_NORMAL)
            # choose new char and draw it A_REVERSE if not out of bounds
            self.char = random.choice(FallingChar.matrixchr).encode(encoding)
            self.y += 1
            in_picture_frame = self.y >= padding_rows and self.y <= padding_rows + output_rows and self.x >= padding_cols and self.x <= padding_cols + output_cols
            if not self.out_of_bounds_reset(width, height) and not in_picture_frame:
                if USE_COLORS:
                    scr.addstr(self.y, self.x, self.char, curses.color_pair(COLOR_CHAR_HIGHLIGHT))
                else:
                    scr.addstr(self.y, self.x, self.char, curses.A_REVERSE)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号