예제 #1
0
파일: __init__.py 프로젝트: ayosec/pyslide
def printcolornames(out = None):
    from pygame.colordict import THECOLORS as d
    keys = d.keys()
    keys.sort()
    width = max([len(x) for x in keys])

    for k in keys:
        print >> out, k.ljust(width), '%3d %3d %3d' % d[k][:3]
예제 #2
0
    by_hex = {}

    for name, color in THECOLORS.items():
        if name[-1].isdigit():
            continue
        html = html_color(color)
        by_hex.setdefault(html, []).append(name)

    return {
        ' / '.join(sorted(names)): THECOLORS[names[0]]
        for names in by_hex.values()
    }


SIMPLE_COLORS = simplified_color_table()
omitted_colors = sorted(THECOLORS.keys() - SIMPLE_COLORS.keys())
some_color = omitted_colors[0]


def gen_table(f):
    colors = list(SIMPLE_COLORS.items())
    colors.sort(key=color_key)

    last_hue = None

    for name, color in colors:
        html = html_color(color)

        arr = np.array(color) / 255
        rgb = arr[:3]
        a = arr[3]
예제 #3
0
파일: utils.py 프로젝트: ebarna2/pyntnclick
def lookup_debug_color(number):
    """Choose a unique colour for this number, to aid debugging"""
    return Color(list(THECOLORS.keys())[number])
예제 #4
0
파일: ch16-e1.py 프로젝트: muyicui/pylearn
import pygame,sys,random
from pygame.colordict import THECOLORS
pygame.init()
screen = pygame.display.set_mode([640,380])
screen.fill([255,255,255])
for i in range(100):
    width = random.randint(0,250)
    height= random.randint(0,100)
    top = random.randint(0,400)
    left = random.randint(0,500)
    color_name = random.choice(list(THECOLORS.keys()))
    color = THECOLORS[color_name]
    line_width = random.randint(0,3)
    pygame.draw.rect(screen,color,[left,top,width,height],line_width)
pygame.display.flip()
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
예제 #5
0
파일: ch16-e1.py 프로젝트: muyicui/pylearn
import pygame, sys, random
from pygame.colordict import THECOLORS
pygame.init()
screen = pygame.display.set_mode([640, 380])
screen.fill([255, 255, 255])
for i in range(100):
    width = random.randint(0, 250)
    height = random.randint(0, 100)
    top = random.randint(0, 400)
    left = random.randint(0, 500)
    color_name = random.choice(list(THECOLORS.keys()))
    color = THECOLORS[color_name]
    line_width = random.randint(0, 3)
    pygame.draw.rect(screen, color, [left, top, width, height], line_width)
pygame.display.flip()
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()