Programming Assignment 4 (Hilbert Curves)

Write a Python program (Hilbert.py) to draw "Hilbert Curves" using the Graphics package that we used in Assignment 2. The program should accept size of curve as command line parameter:
python3 Hilbert.py 4

Hilbert curves come in different sizes, starting at 0. They come in four varieties, H-curve, A-curve, B-curve, and C-curve. Hilbert curves of size 0 occupy no space. Hilbert curves of higher sizes are defined recursively as follows:

The arrows are shown for directional purposes; the actual curves do not contain the arrow. You may assume that each of these "arrow" segment is a straight line of 32 pixels. You can imagine drawing these curves by starting at a point on the canvas with a pen and continue to draw the curve without lifting the pen. Hilbert curves of size i are defined in terms of other curves of size i-1.

Your program should take as command line input the size of the H-curve to be drawn and launch a Graphics canvas on which the H-curve is drawn.

Here are sample H-curves:

Size 1

Size 2

Size 3

Size 4

Size 5

Implementation Hints

It will be helpful to write the following functions:
goEast()
goWest()
goNorth()
goSouth()
aCurve()
bCurve()
cCurve()
hCurve()
Note: You need to decide on the parameters.

What to Submit?

Hilbert.py