Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Assignment One Ellette Cruden 12077709
- file=pickAFile()
- picture = makePicture(file)
- original = duplicatePicture(picture)
- undoPic = picture
- # request sting then have to come up with "if" statements
- # eg. if request is m then run monochrome
- def lighten(picture):
- for px in getPixels(picture):
- color = getColor (px)
- color = makeLighter (color)
- setColor(px, color)
- repaint(picture)
- def darken(picture):
- for px in getPixels(picture):
- color = getColor (px)
- color = makeDarker (color)
- setColor(px,color)
- repaint(picture)
- def monochrome(picture):
- for px in getPixels(picture):
- value= (getRed(px) + getGreen(px) + getBlue(px))/3
- setRed(px, value)
- setGreen(px, value)
- setBlue(px, value)
- repaint(picture)
- def undo(picture):
- #duplicatePicture(picture)
- global undoPic
- picture = undoPic
- repaint(picture)
- def reset(picture):
- picture = original
- repaint(picture)
- def quit():
- quit
- #The following is the picture modifications happening;
- def render():
- while true:
- global picture
- global undoPic
- selection = requestString("*** Picture Modifications ***\n" #This is info box
- "m - make monochrome (black-and-white image)\n"
- "l - make the image Lighter\n"
- "d - make the image Darker\n"
- "u - undo\n"
- "o - reset the picture to the Original\n"
- "q - quit\n\n"
- "Choice:\b")
- if selection == "m":
- undoPic = picture
- monochrome(picture)
- elif selection == "d":
- undoPic = picture
- darken(picture)
- elif selection == "l":
- undoPic = picture
- lighten(picture)
- elif selection == "u":
- picture = undoPic
- repaint(picture)
- elif selection == "o":
- reset(picture)
- elif selection == "q":
- printNow("Program Quit")
- break
- def open():
- global picture
- show(picture)
- render()
- open()
Add Comment
Please, Sign In to add comment