I have been attempting a mirroring assignment using Jython Environment for students.
I am seeking to request an arbitrary line from the user which I will use to mirror the image, this line has to be from an image edge to an edge and be a diagonal.
def userCoordinates():
pic = makePicture(pickAFile())
height = getHeight(pic)
width = getWidth(pic)
newPic = makeEmptyPicture, (width, height)
startX = requestInteger("Please enter your startX Coordinate")
while startX > width:
startX = requestInteger("Error, this coordinate is outside the image, please enter your startX Coordinate")
else:
print "Your startX coordinate is", startX
startY = requestInteger("Please enter your startY Coordinate")
while startY > height:
startY = requestInteger("Error, this coordinate is outside the image, please enter your startY Coordinate")
else:
print "Your startY coordinate is", startY
endX = requestInteger("Please enter your endX Coordinate")
while endX > width:
endX = requestInteger("Error, this coordinate is outside the image, please enter your endX Coordinate")
else:
print "Your endX coordinate is", endX
endY = requestInteger("Please enter your endY Coordinate")
while endY > height:
endY = requestInteger("Error, this coordinate is outside the image, please enter your endY Coordinate")
else:
print "Your endY coordinate is", endY
Is there any way to validate that the point selected is on the edges of the image? Or a better(cleaner way) to do above. Im a beginner in all ways.
I tried using while startX != 0 or startX != width
but then this will not work as the X really could be anything
Any help would be greatly appreciated!