Here's how to make the Koch snowflake.
One starts with a triangle:
forward, 120d right, forward, 120d right, forward, 120d right
Then replaces each edge with
forward, 60d left, forward, 120d right, forward, 60d left, forward
and then repeats this operation
Functions
(* Construct the points with 3*3 matrices: {rotation | translation - 0 | 1 } *)
(* Primitives are translation and rotation -- can also do reflection if desired *)
PrZero = {{{1,0},{0,1}},{0,0}};
PrTrans[x_] := {{{1,0},{0,1}},x}
PrRot[a_] := {{{Cos[a],-Sin[a]},{Sin[a],Cos[a]}},{0,0}}
(* Data format: init (initial), next (production rules: symbols become lists of symbols), geom (geometrical interpretations) *)
(* Functions for making a curve *)
LSNext[params_,curve_] := Flatten[curve /. params["next"],1]
LSSeq[params_,nmax_] := NestList[LSNext[params,#]&,params["init"],nmax]
LSTraverse[pr1_,pr2_] := {pr1[[1]].pr2[[1]],pr1[[2]]+pr1[[1]].pr2[[2]]}
LSGeom[params_,curve_] := FoldList[LSTraverse,PrZero,curve /. params["geom"]]
LSGeomSeq[params_,nmax_] := LSGeom[params,#]& /@ LSSeq[params,nmax]
LSPoints[curve_] := First /@ Split[#[[2]]& /@ curve]
LSMakeCurves[params_,nmax_] := LSPoints /@ LSGeomSeq[params,nmax]
ColoredLine[pts_] := Module[{npts,k},
npts = Length[pts];
Line[pts,VertexColors->If[npts>=3,Table[Hue[(k-1)/(npts-1)],{k,npts}],None]]
]
ShowLines[ptsets_] := Graphics[Line[#]]& /@ ptsets
ShowColoredLines[ptsets_] := Graphics[ColoredLine[#]]& /@ ptsets
Koch Snowflake Curve
(* 1: F segment, 2: +, 3: -- Angle: 60d *)
KochSnowParams["init"] ={1,3,1,3,1,3};
KochSnowParams["next"] = {1->{1,2,1,3,1,2,1},2->{2},3->{3}};
KochSnowParams["geom"] = {1->PrTrans[{1,0}], 2->PrRot[Pi/3], 3->PrRot[-2Pi/3]};
ShowColoredLines[LSMakeCurves[KochSnowParams,4]]