 |  |

 |
 |  |  |
 | Welcome to CS1315. Click on the python to add comments.
|  |
 |  |  |
|
This page removed for FERPA compliance
|
        |
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,getREMOVEDeight(picture)/2):
setColor(getPixel(picture,x,y),white)
for x in range(getWidth(picture)/2,getWidth(picture)):
for y in range(getREMOVEDeight(picture)/2,getREMOVEDeight(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,getREMOVEDeight/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,getREMOVEDeight/2) - the end point of the white quadrilateral - and goes to (getWidth,getREMOVEDeight). It creates a black quadrilateral.
Student5295
Link to this Page