Aurara

HW help

May 2nd, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. from graphics import *
  2. import sys
  3.  
  4. def inverted_color(picture):
  5.     Width = picture.getWidth()
  6.     Height = picture.getHeight()
  7.     for x in range(Width):
  8.         colours = x.getPixel()
  9.         colourstring = color_rgb(225 - colours[RED], 225 - colours[GREEN], 225 - colours[BLUE])
  10.         picture.setPixel(colourstring, colourstring, colourstring)
  11.         #for y in range(Height):
  12.            
  13.            
  14. def Sepia():
  15.     pass
  16.    
  17. def Shuffle():
  18.     pass
  19.        
  20.        
  21. def main():
  22.     image = input('Please enter a filename ')
  23.     try:
  24.         img = Image(Point(0,0), image)
  25.     except tk.TclError:
  26.         print('Not a valid file type!')
  27.         sys.exit()
  28.     area = img.getWidth() * img.getHeight()
  29.     if area == 0:
  30.         print('Not a valid image!!')
  31.         sys.exit()
  32.     cloned_img = img.clone()
  33.     loop = 0
  34.     while loop == 0:
  35.         print('a. Invert image colors')
  36.         print('b. Convert image to sepia.')
  37.         print('c. Shuffle the image.')
  38.         choice = input('What would you like to do? ')
  39.         choice = choice.lower()
  40.         if choice == 'a':
  41.             inverted_color(cloned_img)
  42.             loop = loop + 1
  43.         if choice == 'b':
  44.             colors = img.getPixel(0,0)
  45.             loop = loop + 1
  46.         if choice == 'c':
  47.             colors = img.getPixel(0,0)
  48.             loop = loop + 1
  49.    
  50.     newfilename = input('What do you want to call the file? ')
  51.     try:
  52.         img.save(newfilename)
  53.        
  54.     except tk.TclError:
  55.         print('That is not a valid file!')
  56.    
  57. main()
Advertisement
Add Comment
Please, Sign In to add comment