#Picture manipulation demos: # # Jay Summet - October 6th 2008 # Released to the public domain. # from myro import * def drawHLine(pic, yPos, r, g, b): pWidth = getWidth(pic) for x in range(pWidth): pix = getPixel(pic,x, yPos) setRed(pix,r) setGreen(pix,g) setBlue(pix,b) def drawRectangle(pic): for x in range(50,90): for y in range(100,150): print "x,y:", x,",",y #comment out for speed. pix = getPixel(pic,x,y) setRed(pix,255) setGreen(pix,255) setBlue(pix,0) show(pic) #comment out for speed. wait(0.1) #comment out for speed. def copyRectangle(pic,pic2): for x in range(50,90): for y in range(100,150): pix = getPixel(pic,x,y) pix2 = getPixel(pic2,x,y) setRed(pix2, getRed(pix) ) setGreen(pix2, getGreen(pix)) setBlue(pix2, getBlue(pix)) p = loadPicture("class.gif") p3 = loadPicture("p3.jpg") #drawRectangle(p) copyRectangle(p,p3) show(p3) ## ##p2 = copyPicture(p) ##y = 0 ##while( y < getHeight(p)): ## drawHLine(p2,y, 0,255,0) ## show(p2) ## wait(0.1) ## p2 = copyPicture(p) ## y = y + 5 ## ## ##show(p)