def __init__(self, name=helpers.random_seed(), seed=helpers.random_seed(), image_size=1000, sharp=100, land_color=colors.random_color(), ocean_color=colors.random_color(), water=50, blur=10, size=100, temp=0, planet_type="earthlike" ): self.blur = blur self.name = name self.seed = seed self.image_size = image_size self.size = size self.planet_type = planet_type self.temp = temp self.land_color = land_color self.ocean_color = ocean_color self.water = water self.sharp = float(sharp) self.sharp_img = Image.new('RGB', [self.image_size]*2).convert("RGBA") self.blur_filter = ImageFilter.GaussianBlur(radius=self.blur) """
def __init__(self, width=64): self.surface_thumb = Rect(0,0,width,width) self.rect_thumb = Rect(0,0,width,width) # ex [1] the standard pygame.Color("white") , same as Color("#ffffff") self.color_bg = Color("white") # ex [2] random color with a filter: self.color_bg = random_color('light') self.color_border = random_color('dark') # create empty surface; fill it self.surface_thumb = pygame.Surface([width, width]) self.surface_thumb.fill(self.color_bg)
def __init__(self, width=64): self.surface_thumb = Rect(0, 0, width, width) self.rect_thumb = Rect(0, 0, width, width) # ex [1] the standard pygame.Color("white") , same as Color("#ffffff") self.color_bg = Color("white") # ex [2] random color with a filter: self.color_bg = random_color('light') self.color_border = random_color('dark') # create empty surface; fill it self.surface_thumb = pygame.Surface([width, width]) self.surface_thumb.fill(self.color_bg)
def __init__(self): sqw = 32 sqh = 32 nobstacles = 5 ow = 25 oh = 25 self.MAZERECTS = [] self.START = Rect(0,0,sqw,sqh) #self.END = Rect(800-sqw*3,600-sqh*3,sqw*3,sqh*3) #self.OBSTACLES = self.generate_obstacles(nobstacles,ow,oh) maze = cMaze.cMaze(19,25) #self.MAZE = maze.maze maze.maze[0][0] = 0 self.MAZERECTS = self.maze_to_rects(maze.maze,1) self.VISITED = [] self.CHECKPOINTS = self.generate_checkpoints(maze.maze,6) #the last selected checkpoint is the exit self.END = self.CHECKPOINTS.pop() self.fgcolor = COLOR.white self.bgcolor = COLOR.random_color() self.right = True
def main(): print(c.clear) print(c.base03 + 'Base03' + c.reset, end=' ') print(c.base02 + 'Base02' + c.reset, end=' ') print(c.base01 + 'Base01' + c.reset, end=' ') print(c.base00 + 'Base00' + c.reset, end=' ') print(c.base0 + 'Base0' + c.reset, end=' ') print(c.base1 + 'Base1' + c.reset, end=' ') print(c.base2 + 'Base2' + c.reset, end=' ') print(c.base3 + 'Base3' + c.reset, end=' ') print() print(c.yellow + 'Yellow' + c.reset, end=' ') print(c.orange + 'Orange' + c.reset, end=' ') print(c.red + 'Red' + c.reset, end=' ') print(c.magenta + 'Magenta' + c.reset, end=' ') print(c.violet + 'Violet' + c.reset, end=' ') print(c.blue + 'Blue' + c.reset, end=' ') print(c.cyan + 'Cyan' + c.reset, end=' ') print(c.green + 'Green' + c.reset, end=' ') print() for count in range(7): print(c.random_color() + 'Random' + c.reset, end=' ') print() print() print(c.multi("Multicolored"))
def test_roll(sides): print(c.yellow + 'roll(1,{}):'.format(sides) + c.reset) for count in range(20): foo = roll(1,sides) print(c.random_color() + str(foo) + c.reset,end=' ') print() print()
def test_colorize_on_pygame(self): engine = PyGameEngine() stage = Stage(engine) stage.num_frames = 75 for row in range(50, 780, 100): for col in range(50, 1280, 100): name = 'bob{}x{}'.format(col, row) actor = Square( name, color=colors.random_color(), pos=(col, row), side=90, ) stage.add_actor(actor) stage.add_action( actions.Colorize(actor, 5, 70, colors.random_color())) for frame in range(stage.num_frames): stage.draw(frame)
def run(): print(c.clear) print(c.yellow+str("Hello! And welcome to....")) t.sleep(1) print(c.random_color()+logo) t.sleep(1) print() print() neworload()
def show_map(SURF, _map, side, slices=None): """\ Draw the map to surface SURF. If side is to small, pass in slices returned by generate_random_map. """ _map = _map[1:-1, 1:-1] if slices is not None: bit_map = np.zeros(SCREEN_SIZE, dtype=np.bool) for s in slices: bit_map[s] = _map bit_map = bit_map * SURF.map_rgb(colors.random_color()) surfarray.blit_array(SURF, bit_map) else: cell_surf = pygame.Surface((side,side)) for w in range(_map.shape[0]): for h in range(_map.shape[1]): if _map[w][h]: cell_surf.fill(colors.random_color()) SURF.blit(cell_surf, (w * side, h * side))
def start(self, search="light"): """creates initial grid, with default search. """ if VERBOSE: print "start( search={} )".format(search) self.thumbs = [] thumb_w, thumb_h = 64, 64 numx = self.width / thumb_w numy = self.height / thumb_h self.caption_prepend(search) self.thumbs = [] for y in range(numy): for x in range(numx): t = Thumbnail(width=self.thumb_w) if search: t.color_bg = random_color(search) # else: t.color_bg = Color('gray') t.fill() t.move(thumb_w * x, thumb_h * y) self.thumbs.append(t)
def close_page(self): if self.suffix is not None and len(self._current_page['fields']) > 0: self._current_page['fields'][-1]['value'] += '\n%s' % (self.suffix) if self.title is not None: self._current_page['title'] = self.title if len(self._pages) > 0: self._current_page['title'] += ' Cont. %d' % ( len(self._pages) + 1) if self.description is not None: self._current_page['description'] = self.description if self.footer is not None: self._current_page['footer'] = {'text': self.footer} if self.footer_icon_url is not None: self._current_page['footer']['icon_url'] = self.footer_icon_url if self.thumbnail_url is not None: self._current_page['thumbnail'] = {'url': self.thumbnail_url} self._current_page['color'] = random_color() self._current_page['type'] = 'rich' self._pages.append(self._current_page) self._current_page = {'fields': []} self._count = 0
def test_fade_in_in_pygame(self): sch = Scheduler() engine = PyGameEngine() studio = Stage(engine) for row in range(50, 780, 100): for col in range(50, 1280, 100): from_frame = random.randint(5, 30) size = random.randint(10, 70) to_frame = from_frame + size name = 'bob{}x{}'.format(col, row) actor = Square( name, color=colors.random_color(), pos=(col, row), side=90, alpha=0.1, ) sch.add_action(actions.FadeIn(actor, from_frame, to_frame)) studio.add_actor(actor) for frame in range(75): studio.draw(frame) sch.next()
import colors as c from math import * welcome = (c.random_color() + """ __________ | ________ | ||12345678|| |\"\"\"\"\"\"\"\"\"\"| |[M|#|C][-]| |[7|8|9][+]| |[4|5|6][x]| |[1|2|3][%]| |[.|O|:][=]| \"----------\" """) welcome2 = (c.random_color() + "Welcome to the Calculator!") print(welcome) print(welcome2) while True: op = input( c.random_color() + "To enter your operator, type the\nnumber that matches the order of\n(+,-,x,/,x^y,√). For an example:\nType a 1 for addition, type a 2\nfor subtraction, 6 to do square\nroot, etc. Type Here: > " ) num1 = float( input( c.random_color() + "Great Job! Now type in\nthe first number for your calculation > ") ) num2 = float( input( c.random_color() + "Now type the 2nd number\n(If you chose option 6 last time then type 0) > "
"""This is my EPIC tool box of STUFS. And don't you DARE judge me!""" import colors as c def ask(qustion): print(c.yellow + qustion + c.reset) anwser = input("> " + c.base3).lower().strip() print(c.reset) return anwser if __name__ == '__main__': print(c.clear) name = ask("What is your name?") color = ask("What is your name in color?", c.random_color())
def main(): """\ Press 'a' to decrease max possible fps. Press 'd' to increase max possible fps. Press 's' for no max fps limit. Press 'z' to decrease length of cell side. Press 'x' to increase length of cell side. Press 'p' to pause the game. """ side = 50 # length of cell side width = int(SCREEN_SIZE[0] / side) # number of cells per row height = int(SCREEN_SIZE[1] / side) # number of cellls per column pygame.init() pygame.mouse.set_visible(False) SURF = pygame.display.set_mode(SCREEN_SIZE,FULLSCREEN,32); fontObj = pygame.font.Font('freesansbold.ttf',32); FPSCLOCK = pygame.time.Clock() fps = 5 # max fps maps, slices = generate_random_map(width, height, side); pre_frame_time = time.time() # time of previous frame paused = False while True: for event in pygame.event.get(): if event.type == KEYDOWN: if event.key == K_q: pygame.quit() sys.exit() if event.key == K_a and fps > 1: fps -= 1 if event.key == K_d and fps < 60: fps += 1 if event.key == K_p: paused = not paused if event.key == K_f: maps[random.randint(1, width), random.randint(1, height)] = True if event.key == K_k: maps[random.randint(1, width), :] = True if event.key == K_l: maps[:, random.randint(1, height)] = True if event.key == K_m: maps[:, :] = False if event.key == K_z and side > 5: side -= 5 if side == 15: side = 10 width = int(SCREEN_SIZE[0] / side); height = int(SCREEN_SIZE[1] / side); maps, slices = generate_random_map(width, height, side) if event.key == K_x and side < 100: side += 5 if side == 15: side = 20 width = int(SCREEN_SIZE[0] / side); height = int(SCREEN_SIZE[1] / side); maps, slices = generate_random_map(width, height, side) if event.key == K_s: fps = 0 if event.key == K_r: maps, slices = generate_random_map(width, height, side) if event.type == QUIT: pygame.quit() sys.exit() SURF.fill(BG_COLOR) show_map(SURF, maps, side, slices) if not paused: maps = update(maps) current_frame_time = time.time() textSURF = fontObj.render('real fps: ' + str(1//(current_frame_time-pre_frame_time)), True, colors.random_color()); pre_frame_time = current_frame_time textRect = textSURF.get_rect(); textRect.topright = (SCREEN_SIZE[0],200); SURF.blit(textSURF,textRect); textSURF = fontObj.render('length of side: ' + str(side), True, colors.random_color()); textRect = textSURF.get_rect(); textRect.topright = (SCREEN_SIZE[0],100); SURF.blit(textSURF,textRect); pygame.display.update(); FPSCLOCK.tick(fps)
"""here is my cool utility kitchen""" import colors as c def ask(question, color=c.yellow): print(color + question + c.reset) answer = input('> ' + c.cyan).lower().strip() print(c.reset) return answer if __name__ == '__main__': print(c.clear) color = ask('what is your name in color', c.random_color()) name = ask('what is your name')
"""My awesome utility kitchen sink. Don't judge me.""" import colors as c def ask(question,color=c.yellow,lower=True,strip=True,end='\n> '): print(color + question + c.reset, end=end) answer = input(c.base3) if lower: answer = answer.lower() if strip: answer = answer.strip() print(c.reset, end="") return answer if __name__ == '__main__': print(c.clear) answer = ask("What is your name?") print(answer) answer = ask("What is your name in color?",c.random_color()) print(answer) answer = ask("What is your full name?",lower=False) print(answer) answer = ask("What is something with spaces around it:") print(answer) answer = ask("What is something with spaces around it again:",strip=False) print(answer)
from colors import random_color color = random_color() print(color.red)
"""This is my utilities file for cool functions.""" import colors as c def ask(question,color=c.yellow): print(color + question + c.reset) answer = input('> ' + c.base3).lower().strip() print(c.reset) return answer if __name__ == '__main__': print(c.clear) name = ask('What is your name?') color = ask ('What is your name in color?',c.random_color())
def ask(question,color=c.yellow): print(color + question + c.reset) answer = input(c.orange + '>' + c.random_color()).lower().strip() print(c.reset) return answer
from PIL import Image, ImageDraw from colors import colors, random_color import random img = Image.new('RGB', (512, 512), 'black') pixels = img.load() for i in range(img.size[0]): for j in range(img.size[1]): pixels[i, j] = (colors["periwinkle"][0] + (i - j) // 2, colors["periwinkle"][1] + (i - j) // 3, colors["periwinkle"][2] + (i - j) // 4) draw = ImageDraw.Draw(img) for i in range(0, img.size[0], 50): for j in range(0, img.size[1], 50): upper = random.random() * 50 - 20 lower = random.random() * 50 + 20 draw.ellipse((i + upper, j + upper, i + lower, j + lower), outline=random_color()) img.save("RING", "PNG")
if __name__ == '__main__': import colors as c def test_roll(sides): print(c.yellow + 'roll(1,{}):'.format(sides) + c.reset) for count in range(20): foo = roll(1,sides) print(c.random_color() + str(foo) + c.reset,end=' ') print() print() print(c.clear) test_roll(6) test_roll(20) test_roll(100) print(c.yellow + 'roll():' + c.reset) for count in range(20): foo = roll() print(c.random_color() + str(foo) + c.reset,end=' ') print() print() for text in ['2d6','4d6','1d20','2d100']: print("parse({})".format(text)) print(parse(text)) print("parse_roll({})".format(text)) print(parse_roll(text))
"""here is my cool utility kitchen""" import colors as c def ask(question,color=c.yellow): print(color + question + c.reset) answer = input('> ' + c.cyan).lower().strip() print(c.reset) return answer if __name__ == '__main__': print(c.clear) color = ask('what is your name in color' ,c.random_color()) name = ask('what is your name')
import turtle import random from colors import random_color timmy = turtle.Turtle() screen = turtle.Screen() screen.colormode(255) # Set width and speed timmy.width(18) timmy.speed(0) # Do random walk angles = [0, 90, 180, 270] for _ in range(200): timmy.color(random_color()) timmy.fd(50) timmy.lt(random.choice(angles)) screen.exitonclick()
"""This is RANDOM!!!!!""" import colors as c def ask(question,color=c.yellow): print(color + question + c.reset) answer = input('> ' + c.magenta).lower().strip() print(c.reset) return answer if __name__ == '__main__': print(c.clear) name = ask("what is your name?") color = ask("what is your name in color?",c.random_color())
"""This my awesome utility kitchen sink. Don't judge me.""" import colors as c def ask(question,color=c.red): print(color + question + c.reset) answer = input("> " + c.base3).lower().strip() print(c.reset) return answer if __name__ == '__main__': print(c.clear) name = ask("what is your name?") color = ask("What is your favorite color?",c.random_color())