Write a function named makeCollage to create a collage of the same image at least four times fit onto the 7in.x95in.jpg blank JPEG. (You are welcome to add additional images.) One of those four copies can be the original picture. The other three should be modified forms. You can scale, crop, or rotate the image, create a negative of the image, shift or alter colors on the image, and make it darker or lighter. After composing your image, mirror it. You can do this vertically or horizon- tally (or otherwise), in any direction—just make sure that your four base images are still visible after mirroring. Your single function should make all of this happen—all of the effects and compositing must occur from the single function makeCollage. Of course, it is perfectly okay to use other functions,
This is an open-ended question. Speaking generally, the important parts of the question are to somehow make four or more different versions of an image, place them onto the specified image, and then mirror the image. A simple, but correct approach is below:
```
def makeCollage ():
canvas = makePicture("7in.x95in.jpg")
img = makePicture("InsertImageName.jpg")
#Get the four different images
grayscaleImg = makeGrayscale(img)
invertImg = invertImage(img)
darkenImg = darkenImage(img)
#Copy all four images to the base
for x in range(0,getWidth(img)):
for y in range(0, getHeight(img)):
p = getPixel(img, x, y)
pTarget = getPixel(canvas, x, y)
setColor(pTarget, getColor(p))
for x in range(0,getWidth(img)):
for y in range(0, getHeight(img)):
p = getPixel(grayscaleImg, x, y)
pTarget = getPixel(canvas, x+getWidth(grayscaleImg), y)
setColor(pTarget,getColor(p))
for x in range(0,getWidth(img)):
for y in range(0, getHeight(img)):
p = getPixel(invertImg, x, y)
pTarget = getPixel(canvas, x, y+getHeight(invertImg))
setColor(pTarget,getColor(p))
for x in range(0,getWidth(img)):
for y in range(0, getHeight(img)):
p = getPixel(darkenImg, x, y)
pTarget = getPixel(canvas, x+getWidth(img), y+getHeight(img))
setColor(pTarget, getColor(p))
#Mirror image and return
canvas = mirrorImg(canvas)
show(canvas)
return canvas
def mirrorImg(source):
canvas = makeEmptyPicture(getWidth(source), getHeight(source))
for y in range(0,getHeight(source)):
for x in range(0,getWidth(source)):
topPixel = getPixel(source ,x,y)
sourcePixel = getPixel(canvas,getWidth(source)-1-x,y)
color = getColor(topPixel)
setColor(sourcePixel ,color)
return canvas
def makeGrayscale(sourceImg):
width = getWidth(sourceImg)
height = getHeight(sourceImg)
canvas = makeEmptyPicture(width,height)
for x in range(0, width):
for y in range(0,height):
p = getPixel(sourceImg, x, y)
intensity = (getRed(p)+getGreen(p)+getBlue(p))/3
pTarget = getPixel(canvas, x, y)
setColor(pTarget, makeColor(intensity,intensity,intensity))
return canvas
def invertImage(sourceImg):
width = getWidth(sourceImg)
height = getHeight(sourceImg)
canvas = makeEmptyPicture(width,height)
for x in range(0, width):
for y in range(0,height):
p = getPixel(sourceImg, x, y)
pTarget = getPixel(canvas, x, y)
setColor(pTarget, makeColor(255-getRed(p),255-getGreen(p),255-getBlue(p))) return canvas
def darkenImage(sourceImg):
width = getWidth(sourceImg)
height = getHeight(sourceImg)
canvas = makeEmptyPicture(width,height)
for x in range(0, width):
for y in range(0,height):
p = getPixel(sourceImg, x, y)
pTarget = getPixel(canvas, x, y)
setColor(pTarget, makeColor(getRed(p)/2,getGreen(p)/2,getBlue(p)/2))
return canvas
```
You might also like to view...
In the New Hyperlink dialog box, the ____ section describes the physical characteristics that will be used for a hyperlink.
A. Appearance B. Display C. View D. Characteristics
Graphics can not be placed in the header of a document
Indicate whether the statement is true or false
The ________ command allows the user to find, and then substitute, word or phrases within the document
A) Scan B) Search C) Substitute D) Replace
By inserting a ________, individuals and companies can distribute and collect signatures, and then process forms or documents electronically without having to print and fax or mail
A) proxy signature B) digital signature C) signature line D) binary signature