Koch Fractals (Or Koch Snowflake)
24 Nov 2019
The Koch fractal (also known as the Koch snowflake, Koch curve or Koch star) is a mathematical curve and one of the earliest fractals to have been described. It is based on the Koch curve, which appeared in a 1904 paper titled "On a Continuous Curve Without Tangents, Constructible from Elementary Geometry" by the Swedish mathematician Helge von Koch.
Sorry, your browser does not support Canvas. Sorry, your browser does not support Canvas.
This was easier to do than I was expecting. This was done by using a set of very simple text instructions. There are just 3 instructions. F, +, and -. In our case, the angle is 60 degrees. Thus a string with the text "F--F--F" will draw a triangle. And that's exactly how this works. We start with two strings.
initialString = "F+F--F+F";
theString = "F--F--F";
At the start of each iteration, we replace each "F" of the variable "theString" with the value in "initialString". Rendering the resultant string on the canvas produces the Koch Fractal. Of course the strings here can be replaced with other values as well so as to generate other shapes.
I have two canvases above. One draws the fractal at each iteration and the other animates the fractal.

Javascript Demos

Here's a bunch of javascript... things I wrote over the years whenever time permitted.