links to this page:    Squeak bons mots Squeak for Mathematicians PolygonMorph Pen Swiki Page List
Drawing a Hilbert Curve
Last updated at 9:31 am UTC on 29 October 2019

```   World addMorph: (PolygonMorph
shapeFromPen: [:p | p hilbert: 4 side: 5. p go: 5.
p hilbert: 4 side: 5. p go: 5]
color: Color red borderWidth: 1 borderColor: Color black)```

Copy the code above to a Workspace and evaluate it.

Found on the class side of PolygonMorph in the method:

shapeFromPen: penBlock color: c borderWidth: bw borderColor: bc

This exemplifies that it's worth to hunt the code for little gems hidden there. Besides that you learn quite a bit by reading the code.

Maybe this is not a Hilbert curve; see http://www.shodor.org/interactivate/activities/hilbert1/what.html
Please change the text if this is not correct.

The explanation linked above is not correct (it shows a picture of a different Peano curve). This one is better: http://mathworld.wolfram.com/HilbertCurve.html and shows that the example code does generate two Hilbert curves.

It looks more like a Peano curve to me. http://www.geom.umn.edu/docs/reference/CRC-formulas/node36.html

Note: A Peano curve is ANY curve that fills the entire 2-dimensional plane, so the Hilbert curve is one example of a Peano curve.

Question: What would be be Squeak code for a dragon curve?

Answer: See http://www.math.okstate.edu/mathdept/dynamics/dragon.html; now here https://web.archive.org/web/20070826160025/http://www.math.okstate.edu/mathdept/dynamics/dragon.html