Guest User

Untitled

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