8 Queens Problem
Abhivadaye
Anagram Finder
Bouncing Spheres
Break Out
Classic Snake
Cycloids
Deflection Demo
Double Pendulum
EV Savings
Flocking
Fog fly through
Forces on Objects
Fractals
Game of Life
Horizontal Stars
Image Scanning
JSON Beautify
Julia Sets
Kaleidoscope
Kock Fractals
Lorenz Attractor
Mandlebrot Set
Meta Balls
Natural Flocking
Number Convert
Number Game
Pandemic Simulator
Particles & Nodes
Perlin Noise
Poisson Disk
QuadTree Search
Ripples
Set Demonstration
Sierpiński Triangles
Simple Pendulum
Sine Waves
Starfield
Super Shapes 2D
Target Finder
Tic Tac Toe
Voronoi Diagram
Who Moved My...
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.