310 likes | 561 Views
Programing in JES ( Jython ). Kayla Dean & Patrick Baker. Original Picture. Sunset. def sunset(filename): filename = makePicture ( pickAFile ()) explore(filename) for p in getPixels (filename): value = getBlue (p) setBlue (p, value * 0.7) value = getGreen (p)
E N D
Programing in JES(Jython) Kayla Dean & Patrick Baker
Sunset def sunset(filename): filename = makePicture(pickAFile()) explore(filename) for p in getPixels(filename): value = getBlue(p) setBlue(p, value * 0.7) value = getGreen(p) setGreen(p, value * 0.7) explore(filename)
Grayscale def grayscale(filename): filename = makePicture(pickAFile()) explore(filename) for p in getPixels(filename): sum = getRed(p) + getGreen(p) + getBlue(p) intensity = sum / 3 setColor(p, makeColor(intensity, intensity, intensity)) explore(filename)
Mirror Vertical def mirrorVertical(filename): filename = makePicture(pickAFile()) explore(filename) mirrorPoint=getWidth(filename)/2 width=getWidth(filename) for y in range(0, getHeight(filename)): for x in range(0, mirrorPoint ): leftPixel=getPixel (filename, x, y) rightPixel=getPixel (filename, width-x-1,y) color=getColor(leftPixel) setColor(rightPixel ,color) explore(filename)
Mirror Horizontal def mirrorHorizontal(filename): filename = makePicture(pickAFile()) explore(filename) mirrorPoint=getHeight(filename)/2 height=getHeight(filename) for x in range(0, getWidth(filename)): for y in range(0, mirrorPoint ): topPixel=getPixel (filename, x, y) bottomPixel=getPixel(filename, x,height-y-1) color=getColor(topPixel) setColor(bottomPixel ,color) explore(filename)
Line Detect def lineDetect(filename): filename = makePicture(pickAFile()) for p in getPixels(filename): newRed = getRed(p)*0.229 newGreen = getGreen(p)*0.587 newBlue = getBlue(p)*0.114 luminance = newRed+newGreen+newBlue setColor(p,makeColor(luminance,luminance,luminance)) orig = (filename) makeBw = (filename) sketchLine = getWidth(orig)/2 for x in range(0,sketchLine): for y in range(0,getHeight(orig)-1): here=getPixel(makeBw,x,y) down=getPixel(orig,x,y+1) right=getPixel(orig,x+1,y) hereL=(getRed(here)+getGreen(here)+getBlue(here))/3 downL=(getRed(down)+getGreen(down)+getBlue(down))/3 rightL=(getRed(right)+getGreen(right)+getBlue(right))/3 if abs(hereL-downL)>=10 and abs(hereL-rightL)>=10: setColor(here,black) if abs(hereL-downL)<=10 and abs(hereL-rightL)<=10: setColor(here,white) show(makeBw) return makeBw
Negate Blue def negateblue(filename): filename = makePicture(pickAFile()) for p in getPixels(filename): setBlue(p,0) show(filename)
Negative def negative(filename): filename = makePicture(pickAFile()) for px in getPixels(filename): red = getRed(px) green = getGreen(px) blue = getBlue(px) negColor = makeColor( 255-red, 255-green, 255-blue) setColor(px, negColor) explore(filename)
Negate Green def negategreen(filename): filename = makePicture(pickAFile()) for p in getPixels(filename): setGreen(p,0) show(filename)
Negate Red def negatered(filename): filename = makePicture(pickAFile()) for p in getPixels(filename): setRed(p,0) show(filename)
Make Green def green(filename): filename = makePicture(pickAFile()) for p in getPixels(filename): setRed(p,0) setBlue(p,0) show(filename)
Make Red def red(filename): filename = makePicture(pickAFile()) for p in getPixels(filename): setGreen(p,0) setBlue(p,0) show(filename)
Make Blue def blue(filename): filename = makePicture(pickAFile()) for p in getPixels(filename): setRed(p,0) setGreen(p,0) show(filename)
Other Codes def filename(): filename=makePicture(pickAFile()) def sketchline(): sketchline = getWidth(filename)/2
Source • http://www.clarkvision.com/galleries/gallery.all/web/lion.cub.c02.11.2005.jz3f4256.b-600.html • Site for Original Picture.