Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Assignment One Ellette Cruden 12077709
- global picture
- global file
- def open():
- global picture
- global file
- file=pickAFile() #To pic your picture
- picture = makePicture(file)
- show(picture)
- def render():
- global picture
- 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":
- monochrome(picture)
- elif selection == "l":
- lighten(picture)
- elif selection == "u":
- undo(picture)
- elif selection == "o":
- reset(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):
- picture=backup
- repaint(picture)
- def reset(picture):
- picture=makePicture(file)
- repaint(picture)
Add Comment
Please, Sign In to add comment