Pythagoras Tree

While casually browsing the net I came across this implementation of Pythagoras tree in F#. Just for fun, I have recreated this in Scala.

The Pythagoras Tree is a fractal constructed by geometric methods. It is rather easy to program since no substitution is involved. You can just pile on the newly created squares onto the existing ones, since they don't overlap immediately.

Eye candy

Here is the output of my Scala script:

Depth=10, No Skew

tree10.png

Depth=14, Skew = 0.8

tree14.png

The source code

Conclusion

This script is a bit more configurable than the F# one linked above, and hence is a bit more lengthy. I was quite happy with the script and the end result.


Add a New Comment