jes - Jython 2.5 isdigit

I am trying to add an isdigit() to the program so that I can verify what the user enters is valid. This is what I have so far. But when I run it an enter a character, say "f". It crashes and gives me the error which will be posted below the code. Any ideas?def mirrorHorizontal(source): userMirrorPoint = requestString("Enter a mirror point from 0 to halfway through the pitcure.") #asks user for an input while (int(userMirrorPoint) < 0 or int(userMirrorPoint) > (int(getHeight(source) - 1)//2)) or not(userMirrorPoint.isdigit()...Read more

jes - How to select bottom half of picture?

def changeRed(): setMediaPath("/Users/addison/Downloads/Cmpt101_Pics/Learjet31A.jpg") filename1 = "/Users/addison/Downloads/Cmpt101_Pics/Learjet31A.jpg" source = makePicture(filename1) halfHeight = getHeight(source)/2 for x in range(0,getWidth(source)): for y in range(0, halfHeight): pixel = getPixel(source, x, y) value = getRed(pixel) setRed(pixel, value-127.5) show(source)Sooo this is my code right now to select the top half of a picture and decresa the redness by 50%. My program also ...Read more

def negatives in JES

I am trying to show my picture as a negative, and I coded it, but it wont show the picture as a negative, did I do something wrong? def negative(picButterfly2): for px in getPixels(picButterfly1): red=getRed(px) green=getGreen(px) blue=getBlue(px) negColor=makeColor(255-red, 255-green, 255-blue) setColor(px,negColor)ALSO HOW DO I DRAW HORIZONTAL LINES? Thanks!...Read more

JES: Implementing modification code to a Loop

I am using JES and am wondering what built in function I should use to make this effect work.newG=(oldG+(abs(x*y*2.57901)%64))%256So far I have this codedef forLoop(): picture = makeEmptyPicture(300,200) show(picture) for p in getPixels(picture): setColor(p,black) repaint(picture) for p in getPixels(picture): oldG=(p) newG=(oldG+(abs(x*y*2.57901)%64))%256 repaint(picture)The error I get is The error was:x Name not found globally.A local or global name could not be found. You need to define the function or variable before you try to...Read more

jes - Use while loop to scan through pixels in a picture

I can't figure out how to use while loops to scan through all the pixels.I can do it with for loops, but how to do it with using only while loops??for x in range(0,width): for y in range(0,height): px = getPixels(pic,x,y)___________________________def question410(): pic = makePicture(getMediaPath("barbara.jpg")) width = getWidth(pic) height = getHeight(pic) canvas = makeEmptyPicture(width,height) explore(pic) scale = 2 x = 0 y = 0 while x < width: while y < height: px = getPixel(pic,x,y) colour = getColor(px) ...Read more