############################################### # File: Xiang/pixel2.py # Random colored pixels # mycolor = color_rgb(r,g,b) # mix your own color r=0-255 from graphics import * import random winxMAX=300 winyMAX=300 def randcolor(): r=random.randint(0, 255) # RED Integer from 0 to 255 g=random.randint(0, 255) # GREEN Integer from 0 to 255 b=random.randint(0, 255) # BLUE Integer from 0 to 255 return color_rgb(r,g,b) # mix your own color def main(): win = GraphWin( "Random colored pixels", winxMAX, winyMAX ) for x in range(10000): x=random.randint(7,winxMAX) # choose random positions y=random.randint(7,winyMAX) win.plot(x,y,randcolor()) message = Text( Point(100,20), "Click anywhere to stop!" ) message.draw( win ) win.getMouse() win.close() main()