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