![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| >>> adjust(somePicture, .8) |
| >>> setRed(p, 300) >>> print getRed(p) |
| >>> print 5 / 2 |
| >>> print 5 / 2.0 |
| >>> getPixels(pic) |
| >>> 4 < 2 |
| >>> setColor(p, white) >>> setRed(p, 0) >>> setBlue(p, getRed(p)) |
def tomato(pictureA, pictureB):
for x in range(1, getWidth(pictureB) + 1):
for y in range(1, getHeight(pictureB) + 1):
targetPixel = getPixel(pictureA, x, y)
sourcePixel = getPixel(pictureB, x, y)
color = getColor(sourcePixel)
setColor(targetPixel, color)
|
def cucumber(picture):
for p in getPixels(picture):
color = getColor(p)
if distance(color, white) < distance(color, black):
setColor(p, white)
else:
setColor(p, black)
|
def hashbrowns(number):
foo = 0
for i in range(number + 1)
foo = foo + i
return foo
|
def nothingPolitical(picture):
for xoffset in range(1, getWidth(picture) / 2):
for y in range(1, getHeight(picture) + 1):
liberal = getPixel(picture, xoffset, y)
conservative = getPixel(picture, getWidth(picture) - xoffset, y)
colorA = getColor(liberal)
colorB = getColor(conservative)
setColor(liberal, colorB)
setColor(conservative, colorA)
|