-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredeye.pybak
46 lines (30 loc) · 1.2 KB
/
redeye.pybak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def redEye():
picture = makePicture(getMediaPath('jenny-red.jpg'))
show(picture)
eyeWidth = range(109, 196)
eyeHeight =range(86, 105)
for x in eyeWidth:
for y in eyeHeight:
pixel = getPixel(picture, x, y)
pixelColor = getColor(pixel)
colorDistance = distance(pixelColor, red)
if colorDistance < 160:
setColor(pixel, black)
repaint(picture)
def blueScreen():
sourcePic = makePicture(getMediaPath('blue-mark.jpg'))
targetPic = makePicture(getMediaPath('moon-surface.jpg'))
show(sourcePic)
sourceWidth = getWidth(sourcePic)
widthRange =
sourceHeight = getHeight(sourcePic)
for x in sourceWidth:
for y in sourceHeight:
sourcePixel = getPixel(sourcePic, x, y)
targetPixel = getPixel(targetPic, x, y)
sourceColor = getColor(sourcePixel)
targetColor = getColor(targetPixel)
colorDistance = distance(pixelColor, blue)
if colorDistance < 160:
setColor(sourcePixel, targetColor)
repaint(picture)