From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Recursive graphics

Recursive graphics

- [Instructor] Last week I showed you how to add turtle graphics to core graphics. This time I'd like to show you one of my favorite uses for turtle graphics, making fractal shapes like this Koch snowflake. To explain fractals, let's look at the simple line. I can put a spike in it like this. If I were to describe that spike, I could do it in the relative terms of turtle graphics. It would be four lines, each of a distance of one-third the original line and a 60 degree turn, and then reversing that 60 degree turn. Now, what if I replaced each of these current lines with the same kind of spikes? It would look like this. I could do that again and get this. If I did that over a triangle, I'd get a snowflake looking thing called a Koch snowflake, demonstrating some of the basic principles of fractal geometry. Let's try drawing this. If you download the starter code, you'll find a modified version of the turtle graphics…

Contents