def main(): from color_list import read_colors colors, rgbs = read_colors() scene.range = (256, 256, 256) scene.center = (128, 128, 128) draw_spheres(rgbs, 10)
def create_color_cube(): visual.scene.range = (256, 256, 256) visual.scene.center = (128, 128, 128) color_dict, rgbs = color_list.read_colors() for rgb in color_dict.values(): r = int(rgb[1:3], 16) g = int(rgb[3:5], 16) b = int(rgb[5:7], 16) pos = (r, g, b) color = (r / 255.0, g / 255.0, b / 255.0) visual.sphere(pos=pos, radius=10, color=color)
def create_color_cube(): visual.scene.range=(256,256,256) visual.scene.center=(128,128,128) color_dict,rgbs=color_list.read_colors() for rgb in color_dict.values(): r=int(rgb[1:3],16) g=int(rgb[3:5],16) b=int(rgb[5:7],16) pos=(r,g,b) color=(r/255.0,g/255.0,b/255.0) visual.sphere(pos=pos,radius=10,color=color)
def main(script, *args): """create the display and wait for user events """ # set up the scene scene.title = "X11 color space" scene.height = 500 scene.width = 500 scene.range = (256, 256, 256) scene.center = (128, 128, 128) # read the colors from color_list import read_colors colors, rgbs = read_colors() # add an entry for the biggest unnamed color in X11 space name = "allen blue" rgbs.append(((51, 51, 255), [name])) # draw the spheres spheres = draw_spheres(rgbs) if "resize" in args: set_size(spheres) # find_biggest_hole(spheres) print """ Left-click on a sphere to see the color name(s). Drag the middle mouse up/down to zoom in/out. Drag the right mouse to rotate. """ # wait for mouse clicks while 1: if scene.mouse.clicked: m = scene.mouse.getclick() obj = find_closest_sphere(m, spheres) if obj: print ", ".join(obj.names) toggle_label(obj)
def main(script, *args): """create the display and wait for user events """ # set up the scene scene.title = "X11 color space" scene.height = 500 scene.width = 500 scene.range = (256, 256, 256) scene.center = (128, 128, 128) # read the colors from color_list import read_colors colors, rgbs = read_colors() # add an entry for the biggest unnamed color in X11 space name = 'allen blue' rgbs.append(((51, 51, 255), [name])) # draw the spheres spheres = draw_spheres(rgbs) if 'resize' in args: set_size(spheres) #find_biggest_hole(spheres) print """ Left-click on a sphere to see the color name(s). Drag the middle mouse up/down to zoom in/out. Drag the right mouse to rotate. """ # wait for mouse clicks while 1: if scene.mouse.clicked: m = scene.mouse.getclick() obj = find_closest_sphere(m, spheres) if obj: print ', '.join(obj.names) toggle_label(obj)
def main(script, *args): """create the display and wait for user events """ # set up the scene scene.title = "X11 color space" scene.height = 500 scene.width = 500 scene.range = (256, 256, 256) scene.center = (128, 128, 128) # read the colors from color_list import read_colors colors, rgbs = read_colors() # add an entry for the biggest unnamed color in X11 space #name = 'allen blue' #rgbs.append(((51,51,255), [name])) # draw the spheres spheres = draw_spheres(rgbs) if 'resize' in args: set_size(spheres)
from visual import * scene.range = (256, 256, 256) scene.center = (128, 128, 128) #color = (0.1, 0.1, 0.9) #sphere(pos=scene.center, radius=128, color=color) #t = range(0, 256, 51) #for x in t: #for y in t: #for z in t: #pos = x, y, z #each_color = (x/255, y/255, z/255) #sphere(pos=pos, radius=10, color=each_color) import color_list for k, color in color_list.read_colors()[0].items(): if k.strip() != '': x = int(color[1:1+2], 16) y = int(color[1+2:1+2+2], 16) z = int(color[1+2+2:1+2+2+2], 16) pos = (x, y, z) each_color = (x/255, y/255, z/255) sphere(pos=pos, radius=10, color=each_color)
#thinkpython 17.8, 3d graph. from visual import * from color_list import read_colors scene.range = (256,256,256) scene.center = (128,128,128) #t = range(0,256,51) #for x in t: # for y in t: # for z in t: # pos = (x,y,z) # color = (1*float(x)/256, 1*float(y)/256, 1*float(z)/256) # sphere(pos=pos, radius=10, color=color) # print color colors = read_colors()[0] print colors for key, value in colors.items(): x = int(value[1:3], 16) y = int(value[3:5], 16) z = int(value[5:], 16) pos = (x,y,z) color = (1*float(x)/256, 1*float(y)/256, 1*float(z)/256) sphere(pos=pos, radius=10, color=color) print color
return rgb def draw_sphere(liste): '''This function takes a list of tuples and draws spheres with positions and colors corresponding to the rgb value of the tuple. liste = list of tuples sphere = sphere of position and color rgb''' for rgb in liste: (x,y,z) = rgb pos = x, y, z color = (x/255.0, y/255.0, z/255.0) sphere(pos=pos, radius=10, color=color) ##test case colors, rgbs = read_colors() list_rgb = [] #creates a list of tuples of all the colors in rgbs #prints the names and corresponding RGB values of the colors in rgbs for rgb, names in rgbs: list_rgb.append(hex_to_rgb(rgb)) print rgb,names print draw_sphere(list_rgb)