Comp 150-001, MWF 12:35, Crown 105

Week 9




Homework 7: Illusions

Implement an optical illusion. One of the following is recommended:

These and other illusions can be found at michaelbach.de/ot.

After you make your illusion, experiment with it. Does the stripe width matter for Stepping Feet and Pigeon Neck? If you see the circles in SAM flipping vertically, do they stay that way as you move the aspect ratio towards 1.0? Can you think of other experiments?



illusion1.py

drawing the pigeon.
    Let coordlist be the list of the above coordinates, as tuples in Python. (You can just paste it in to Idle.)

pointlist = []
for (x,y) in coordlist:
    pointlist.append(Point(x,y))
pigeon = Polygon(pointlist)
pigeon.move(200, 100)
pigeon.draw(win)

The forehead of the pigeon has x=30. The front of the body of the pigeon has x=24. You can play with these (probably by slightly reducing the latter) to make the pigeon fit with your vertical stripes.

Orbit: Here is the main method from orbit.py:

def main(advance, delay):
    global WIN
    center = Point(WINX/2,WINY/2)
    sun = makeDisk(center, 15, WIN, "yellow")
    t = 1
    #advance = 0.02
    #delay = 0.01
    oldx = R*math.sin(t)
    oldy = R*math.cos(t)
    planet=makeDisk(Point(WINX/2+oldx, WINY/2+oldy), 8, WIN, "blue")
    while not WIN.checkMouse():
        t += advance
        newx = R*math.sin(t)
        newy = R*math.cos(t)
        planet.move(newx-oldx, newy-oldy)
        oldx = newx
        oldy = newy
        time.sleep(delay)

The file orbit2.py does this with two planets, and is set up to update them according to a list, which makes it relatively easy to extend to the dozen circles of the stereokinetic illusion.