Optical Illusions Part 1, For Loops

Write a program using dudraw to replicate any one of the optical illusions shown below (you choose). [Note to instructors: this can be modified to any language using most options for graphics packages.] Modify the image in some way to make the image distinct from what is shown below (change colors, number of lines, thickness of lines, or any other modifications)

Submit the project with the usual naming conventions for your file and the usual requirements for documentation (docstrings, comments and variable names).

Illusion 1: Gradient illusion

The background here is drawn with a gradient of gray colors ranging from a brightness of 0 to 255. But the rectangle in the middle is one rectangle of a mid-intensity gray, it does not have a color change in it!

Gradient Illusion

Illusion 2: Curving squares (the 3 purplish shapes really are squares, they are not curved)

Curving squares

The following three choices may require trigonometry. In python, the math.cos() and math.sin() functions accept the angle in radians as a parameter. The radiating lines are drawn from the center outwards are spaced with a constant angle between them.

Illusion 3: Hering's illusion (the red lines are not curved, they are actually straight parallel lines

Cafe Wall Illusion

Illusion 4: Eisenstein's illusion (the red shapes are a true circle and a true square. Their distorted appearance is an illusion.

Eisenstein Illusion

This is a recreation of a drawing called "Leviant Enigma". Most people see illusory motion or flow within the purple rings.

See Leviant Enigma, National Gallery of Art

Leviant Enigma