Sunteți pe pagina 1din 3

Collage

# Vertical Mirror
def verticalMirror():
pic = makePicture(pickAFile())
width = getWidth(pic)
height = getHeight(pic)

for x in range(0, width / 2):


for y in range(0, height):
color = getColor(getPixel(pic, x, y))
setColor(getPixel(pic, width - x - 1, y), color)
return(pic)

# Make Negative
def makeNegative():
pic = makePicture(pickAFile())

pixels = getPixels(pic)
for p in pixels:
setRed(p, 255 - getRed(p))
setGreen(p, 255 - getGreen(p))
setBlue(p, 255 - getBlue(p))
return(pic)

# Rose colored Glasses


def roseColoredGlasses(tint, intensity):
pic = makePicture(pickAFile())

pixels = getPixels(pic)
for p in pixels:
r = getRed(p)
g = getGreen(p)
b = getBlue(p)

setRed(p, r + (tint[0] - r) * intensity)


setGreen(p, g + (tint[1] - g) * intensity)
setBlue(p, b + (tint[2] - b) * intensity)
return(pic)

# Quadruple Mirror
def quadMirror():
pic = makePicture(pickAFile())
width = getWidth(pic)
height = getHeight(pic)

for x in range(0, width / 2):


for y in range(0, height):
color = getColor(getPixel(pic, x, y))
setColor(getPixel(pic, width - x - 1, y), color)
for y in range(0, height / 2):
for x in range(0, width):
color = getColor(getPixel(pic, x, y))
setColor(getPixel(pic, x, height - y - 1), color)
return(pic)

# betterBnW
def betterBnW():
pic = makePicture(pickAFile())
pixels = getPixels(pic)

for pixel in pixels:


r = getRed(pixel)
g = getGreen(pixel)
b = getBlue(pixel)
better_gray = r*0.299 + g*0.587 + b*0.114
setColor(pixel, makeColor(better_gray))
return(pic)

# Rotate
def rotatePic():
pic = makePicture(pickAFile())
h = getHeight(pic)
w = getWidth(pic)
newpic = makeEmptyPicture(h, w)
for x in range (0, getHeight(newpic)):
for y in range (0, getWidth(newpic)):
setColor(getPixel(newpic, y, x), getColor(getPixel(pic, x, y)))
return(newpic)

# Make Collage
def makeCollage():
# Create empty collage file (sized 5x7)
collage = makeEmptyPicture(1500,2100)

# Select and Modify Pics


pic1 = verticalMirror()
pic2 = rotatePic()
pic3 = roseColoredGlasses([255,102,178], .5)
pic4 = makeNegative()
pic5 = betterBnW()
pic6 = makePicture(pickAFile())
pic7 = makePicture(pickAFile())
pic8 = quadMirror()

# Apply Pics to Collage


for x in range(0, getWidth(pic1)):
for y in range(0, getHeight(pic1)):
setColor(getPixel(collage, x + 200, y + 200), getColor(getPixel(pic1, x, y)))
for x in range(0, getWidth(pic2)):
for y in range(0, getHeight(pic2)):
setColor(getPixel(collage, x + 200, y + 600), getColor(getPixel(pic2, x, y)))
for x in range(0, getWidth(pic3)):
for y in range(0, getHeight(pic3)):
setColor(getPixel(collage, x + 200, y + 1000), getColor(getPixel(pic3, x, y)))
for x in range(0, getWidth(pic4)):
for y in range(0, getHeight(pic4)):
setColor(getPixel(collage, x + 200, y + 1400), getColor(getPixel(pic4, x, y)))
for x in range(0, getWidth(pic5)):
for y in range(0, getHeight(pic5)):
setColor(getPixel(collage, x + 900, y + 200), getColor(getPixel(pic5, x, y)))
for x in range(0, getWidth(pic6)):
for y in range(0, getHeight(pic6)):
setColor(getPixel(collage, x + 900, y + 600), getColor(getPixel(pic6, x, y)))
for x in range(0, getWidth(pic7)):
for y in range(0, getHeight(pic7)):
setColor(getPixel(collage, x + 900, y + 1000), getColor(getPixel(pic7, x, y)))
for x in range(0, getWidth(pic8)):
for y in range(0, getHeight(pic8)):
setColor(getPixel(collage, x + 900, y + 1400), getColor(getPixel(pic8, x, y)))

explore(collage)
return collage

S-ar putea să vă placă și