Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Rakan Nassereddin, Quinn Chrzan, Ben Stewart
- #902593694, Insert ID's Here, " "
- #We worked on the homework assignment alone, using only this semester's course materials.
- from myro import *
- init()
- def record(time):
- pictures = []
- while timeRemaining(time):
- wait(.1)
- pictures.append(takePicture())
- pictures.append(takePicture())
- return pictures
- def fadetoBlack():
- pictures = record(15)
- index = 10
- for pic in pictures:
- pix = getPixels(pic)
- for x in pix:
- red = getRed(x)
- green = getGreen(x)
- blue = getBlue(x)
- if red <230:
- setRed(x, red + index)
- if blue < 230:
- setBlue(x, blue + index)
- if green <230:
- setGreen(x, green + index)
- index = index +10
- savePicture(pictures, 'Fade to black.gif')
- def tempoChange(time):
- pictures = []
- while timeRemaining(time):
- wait(.1)
- for x in range(5):
- pictures.append(takePicture())
- savePicture(pictures, 'tempo.gif')
- return pictures
- def seeingRed(time):
- pictures = record(time)
- for pic in pictures:
- pix = getPixels(pic)
- for x in pix:
- setRed(x, 255)
- return pictures
- def view360():
- pictures = []
- for seconds in timer(11):
- turnLeft(.2,.1)
- pictures.append(takePicture())
- savePicture(pictures, '360-View.gif')
- return pictures
- def robotZoom():
- pictures = []
- for seconds in timer(10):
- forward(.4,.1)
- wait(.1)
- stop()
- pictures.append(takePicture())
- savePicture(pictures, 'Robot-Zoom')
- return pictures
- def gifitize():
- pictures = seeingRed(10)
- pics2 = robotZoom
- pics3 = view360
- savePicture(pictures, 'seeingRed.gif')
- # EXAMPLE USAGE:
- # pics = recordGreenScreen(10,"/path/to/pic.jpg")
- # savePicture("/path/to/animated.gif")
- def recordGreenScreen(time,pic):
- pictures = []
- pic = makePicture(pic)
- while timeRemaining(time):
- wait(.5)
- pictures.append(takePicture())
- processed = [greenScreen(rec,pic,makeColor(66,255,255)) for rec in pictures]
- return processed
- # pic1, pic2 are picture resources, colorFilter is the specified color we are filtering for
- def greenScreen(pic1,pic2,colorFilter):
- r,g,b = getRGB(colorFilter)
- for i in range(getWidth(pic1)):
- for j in range(getHeight(pic1)):
- pixel1 = getPixel(pic1,i,j)
- pixel2 = getPixel(pic2,i,j)
- diff = math.sqrt((getRed(pixel1)-r)**2 + (getGreen(pixel1)-g)**2 + (getBlue(pixel1)-b)**2)
- #print diff
- if diff <= 200:
- setGreen(pixel1, getGreen(pixel2))
- setRed(pixel1, getRed(pixel2))
- setBlue(pixel1, getBlue(pixel2))
- return pic1
- #This is all part of one code: Split-Screen.
- def takePic():
- t1 = takePicture()
- turnRight(.5, .5)
- t2 = takePicture()
- def splitScreen(t1, t2):
- h = getHeight(t1)
- w = getWidth(t2)/2
- for i in range(w):
- for j in range(h):
- p = getPixel(t1,i,j)
- g = getGreen(p)
- r = getRed(p)
- b = getBlue(p)
- pixel2 = getPixel(t2,i,j)
- setGreen(pixel2,g)
- setRed(pixel2,r)
- setBlue(pixel2,b)
- return t2
- def pictures():
- index = 0
- l = []
- while index <= 9:
- t = takePicture()
- turnRight(.5,.5)
- l.append(t)
- index = index + 1
- l2 = []
- for i in range(0,5):
- pic1 = l[i]
- pic2 = l[i+5]
- newPic = splitScreen(pic1, pic2)
- l2.append(newPic)
- return l2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement