Guest User

Untitled

a guest
Jul 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. # Assignment One Ellette Cruden 12077709
  2.  
  3. global picture
  4. global file
  5.  
  6. def open():
  7.  global picture
  8.  global file
  9.  file=pickAFile()                                                  #To pic your picture
  10.  picture = makePicture(file)
  11.  show(picture)
  12.  
  13. def render():
  14.  global picture
  15.  selection = requestString("*** Picture Modifications ***\n"                  #This is info box
  16.     "m - make monochrome (black-and-white image)\n"
  17.     "l - make the image Lighter\n"
  18.     "d - make the image Darker\n"
  19.     "u - undo\n"
  20.     "o - reset the picture to the Original\n"
  21.     "q - quit\n\n"
  22.     "Choice:\b")
  23.  if selection == "m":
  24.    monochrome(picture)
  25.  elif selection == "l":
  26.    lighten(picture)
  27.  elif selection == "u":
  28.    undo(picture)
  29.  elif selection == "o":
  30.    reset(picture)
  31.      
  32.  
  33.  
  34.  # request sting then have to come up with "if" statements
  35.  # eg. if request is m then run monochrome
  36.  
  37.  
  38. def lighten(picture):
  39.   for px in getPixels(picture):
  40.     color = getColor (px)
  41.     color = makeLighter (color)
  42.     setColor(px, color)
  43.   repaint(picture)
  44.    
  45. def darken(picture):
  46.   for px in getPixels(picture):
  47.     color = getColor (px)
  48.     color = makeDarker (color)
  49.     setColor(px,color)
  50.   repaint(picture)
  51.    
  52. def monochrome(picture):
  53.   for px in getPixels(picture):
  54.     value= (getRed(px) + getGreen(px) + getBlue(px))/3
  55.     setRed(px, value)
  56.     setGreen(px, value)
  57.     setBlue(px, value)
  58.   repaint(picture)
  59.    
  60. def undo(picture):
  61.   picture=backup
  62.   repaint(picture)
  63.    
  64. def reset(picture):
  65.   picture=makePicture(file)
  66.   repaint(picture)
Add Comment
Please, Sign In to add comment