诅咒不能正确显示颜色对

问题描述

我试图了解诅咒是如何工作的,所以我编写了一小段代码来帮助我理解它。这有点乱,但它应该可以正常工作(理论上)。在第一个文件中,我手动定义了每个颜色对,然后我简单地在主文件中创建了一个实例。

ANSICOLORS.PY

import curses

LGREY_LGREY = None
WHITE_LGREY = None
LGREY_WHITE = None
WHITE_WHITE = None
LGREY_BLACK = None
WHITE_BLACK = None
LGREY_DGREY = None
WHITE_DGREY = None
BLACK_LGREY = None
DGREY_LGREY = None
BLACK_WHITE = None
DGREY_WHITE = None
BLACK_BLACK = None
DGREY_BLACK = None
BLACK_DGREY = None
DGREY_DGREY = None

def delayed_init():
    global LGREY_LGREY,WHITE_LGREY,LGREY_WHITE,WHITE_WHITE,LGREY_BLACK,WHITE_BLACK,LGREY_DGREY,WHITE_DGREY \,BLACK_LGREY,DGREY_LGREY,BLACK_WHITE,DGREY_WHITE,BLACK_BLACK,DGREY_BLACK,BLACK_DGREY,DGREY_DGREY

    curses.init_pair(1,curses.COLOR_WHITE,curses.COLOR_WHITE)
    curses.init_pair(2,curses.COLOR_WHITE)
    curses.init_pair(3,curses.COLOR_WHITE)
    curses.init_pair(4,curses.COLOR_WHITE)
    curses.init_pair(5,curses.COLOR_BLACK)
    curses.init_pair(6,curses.COLOR_BLACK)
    curses.init_pair(7,curses.COLOR_BLACK)
    curses.init_pair(8,curses.COLOR_BLACK)
    curses.init_pair(9,curses.COLOR_BLACK,curses.COLOR_WHITE)
    curses.init_pair(10,curses.COLOR_WHITE)
    curses.init_pair(11,curses.COLOR_WHITE)
    curses.init_pair(12,curses.COLOR_WHITE)
    curses.init_pair(13,curses.COLOR_BLACK)
    curses.init_pair(14,curses.COLOR_BLACK)
    curses.init_pair(15,curses.COLOR_BLACK)
    curses.init_pair(16,curses.COLOR_BLACK)


    LGREY_LGREY = curses.color_pair(1)
    WHITE_LGREY = curses.color_pair(2) | curses.A_BOLD
    LGREY_WHITE = curses.color_pair(3) | curses.A_REVERSE #CHECK
    WHITE_WHITE = curses.color_pair(4) | curses.A_BOLD | curses.A_REVERSE #CHECK

    LGREY_BLACK = curses.color_pair(5)
    WHITE_BLACK = curses.color_pair(6) | curses.A_BOLD
    LGREY_DGREY = curses.color_pair(7) | curses.A_REVERSE #CHECK
    WHITE_DGREY = curses.color_pair(8) | curses.A_BOLD | curses.A_REVERSE #CHECK

    BLACK_LGREY = curses.color_pair(9)
    DGREY_LGREY = curses.color_pair(10) | curses.A_BOLD
    BLACK_WHITE = curses.color_pair(11) | curses.A_REVERSE #CHECK
    DGREY_WHITE = curses.color_pair(12) | curses.A_BOLD | curses.A_REVERSE #CHECK

    BLACK_BLACK = curses.color_pair(13)
    DGREY_BLACK = curses.color_pair(14) | curses.A_BOLD
    BLACK_DGREY = curses.color_pair(15) | curses.A_REVERSE #CHECK
    DGREY_DGREY = curses.color_pair(16) | curses.A_BOLD | curses.A_REVERSE #CHECK

main.py

import curses
import time

import ANSICOLORS

stdscr = curses.initscr()
curses.start_color()
curses.use_default_colors()
ANSICOLORS.delayed_init()

colors = [  ANSICOLORS.LGREY_LGREY,ANSICOLORS.WHITE_LGREY,ANSICOLORS.LGREY_WHITE,ANSICOLORS.WHITE_WHITE,ANSICOLORS.LGREY_BLACK,ANSICOLORS.WHITE_BLACK,ANSICOLORS.LGREY_DGREY,ANSICOLORS.WHITE_DGREY,ANSICOLORS.BLACK_LGREY,ANSICOLORS.DGREY_LGREY,ANSICOLORS.BLACK_WHITE,ANSICOLORS.DGREY_WHITE,ANSICOLORS.BLACK_BLACK,ANSICOLORS.DGREY_BLACK,ANSICOLORS.BLACK_DGREY,ANSICOLORS.DGREY_DGREY]

win = curses.newwin(5,50,1,1)

for y in range(4):
    for x in range(4):
        print(y*4 + x)
        win.addstr(y,x*5,f"▀█{y}█▀",colors[y*4 + x])

while True:
    win.refresh()
    time.sleep(1)

然而,在实践中我并没有得到所有可能的组合。只有 WHITE_LGREY 产生颜色 WHITE。例如,WHITE_WHITE生成浅灰色图像。

结果如下:

screenshot

即使我对 BOLDREVERSE 如何工作的理解是错误的,我还是尝试了所有 16 种“ON/OFF”与黑白组合,所以理论上我应该得到一个案例所有实例。 关于问题可能是什么的任何想法?我是否遗漏了诅咒的某些组成部分?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)