Exemple #1
0
def random_color(search=None):
    """get a single random Color(), with Optional search filter.
        search='green' will return 'seagreen', 'bluegreen', etc...
        
    default to choice() of full list"""    
    if search: c = choice(search_color(search))
    else: c = choice(THECOLORS.values())
    
    #debug: print type(c), c # returns Color()
    return c 
Exemple #2
0
def random_color(search=None):
    """get a single random Color(), with Optional search filter.
        search='green' will return 'seagreen', 'bluegreen', etc...
        
    default to choice() of full list"""
    if search: c = choice(search_color(search))
    else: c = choice(THECOLORS.values())

    #debug: print type(c), c # returns Color()
    return c
Exemple #3
0
import pygame, sys, random
from pygame.color import THECOLORS
pygame.init()
screen = pygame.display.set_mode([640, 480])
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 = random.choice(list(THECOLORS.values()))
    pygame.draw.rect(screen, color, [left, top, width, height], 1)
pygame.display.flip()
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
pygame.quit()