Fall 2007 Test 1 Review - Mangle
Post questions here.
is it b?
I think it's C.
I also think it is C.
def mangle(picture):
for x in range(1,getWidth(picture)/2):
for y in range(1,getHeight(picture)/2):
setColor(getPixel(picture,x,y),white)
for x in range(getWidth(picture)/2,getWidth(picture)):
for y in range(getHeight(picture)/2,getHeight(picture)):
setColor(getPixel(picture,x,y),black)
The "mangled" picture has a white square in the top left area and a black square in the bottom right area.
The first nested "for" loop starts from (1,1) and goes to (getWidth/2,getHeight/2) and creates a white quadrilateral. It's starting from the top left corner and ends at the midpoint of the picture.
The second nested "for" loop starts from (getWidth/2,getHeight/2) - the end point of the white quadrilateral - and goes to (getWidth,getHeight). It creates a black quadrilateral.
Alex Young
Link to this Page