Function Repository Resource:

LSystem

Source Notebook

Generate an L-system

Contributed by: Renan Soares Germano

ResourceFunction["LSystem"][rules,init,t,θ]

returns an Association containing the word and the branches generated after executing the L-system represented by rules from initial word init for t steps, with movement specified by the angle θ.

Details and Options

L-system is also known as a Lindenmayer system.
θ is taken to be in degrees.
The following special symbols, when present in rules, represent the following instructions:
+increase the current angle by θ
-decrease the current angle by θ
[start a new branch
]close the current branch
ResourceFunction["LSystem"] takes the following options:
"InitialAngle"90initial angle in degrees from which the next points will be generated
"InitialPoint"{0,0}intial point from which the next points will be generated
"MoveLength"1distance of a new point from the previous one
Any other symbol will be interpreted as an instruction to move forward.
In an L-system with brackets, every left bracket "[" must be paired with a right bracket "]" in the rules and the initial word.

Examples

Basic Examples (4) 

Run a simple L-system for one iteration:

In[1]:=
simpleLSystem = ResourceFunction["LSystem"][{"A" -> "B+B", "B" -> "A-B"}, "AAA", 1, 45]
Out[1]=

Because this L-system doesn't use brackets, it contains only one branch:

In[2]:=
{#, Graphics[{Line@#}]} & /@ simpleLSystem["Branches"] // Grid[Join[{Style[#, Bold] & /@ {"Branch", "Plot"}}, #], Frame -> All] &
Out[2]=

Run a simple L-system with brackets for one iteration:

In[3]:=
simpleLSystemWithBrackets = ResourceFunction["LSystem"][{"A" -> "B+[B]", "B" -> "A-B"}, "AAA", 1,
   45]
Out[3]=

Because this L-system uses brackets, it contains multiple branches:

In[4]:=
{#, Graphics[{Line@#}]} & /@ simpleLSystemWithBrackets["Branches"] // Grid[Join[{Style[#, Bold] & /@ {"Branch", "Plot"}}, #], Frame -> All] &
Out[4]=

Show a fractal:

In[5]:=
branches = Lookup[ResourceFunction["LSystem"][{"F" -> "FF-F-F-F-F-F+F"}, "F-F-F-F", 4, 90], "Branches"];
Graphics[Line[branches]]
Out[5]=

Show a tree:

In[6]:=
branches = Lookup[ResourceFunction[
    "LSystem"][{"G" -> "F+[[G]-G]-F[-FG]+G", "F" -> "FF"}, "G", 5, 22.5], "Branches"];
Graphics[Line[branches]]
Out[6]=

Scope (2) 

Display a variety of fractals:

In[7]:=
fractals = {{"32-segment curve", {{"F" -> "-F+F-F-F+F+FF-F+F+FF+F-F-FF+FF-FF+F+F-FF-F-F+FF-F-F+F+F-F+"},
      "F+F+F+F", 2, 90}}, {"Box fractal", {{"F" -> "F-F+F+F-F"}, "F-F-F-F", 4, 90}}, {"Dragon curve", {{"X" -> "X+YF+", "Y" -> "-FX-Y"}, "FX", 11, 90}}, {"Hilbert curve", {{"L" -> "+RF-LFL-FR+", "R" -> "-LF+RFR+FL-"}, "L", 5, 90}}, {"Hilbert curve II", {{"X" -> "XFYFX+F+YFXFY-F-XFYFX", "Y" -> "YFXFY-F-XFYFX+F+YFXFY"}, "X", 3, 90}}, {"Koch snowflake", {{"F" -> "F+F--F+F"}, "F--F--F", 4, 60}}, {"Peano curve", {{"F" -> "F+F-F-F-F+F+F+F-F"}, "F", 3, 90}}, {"Peano-Gosper curve", {{"X" -> "X+YF++YF-FX--FXFX-YF+", "Y" -> "-FX+YFYF++YF+FX--FX-Y"}, "FX", 4, 60}}, {"Quadratic Koch island", {{"F" -> "F-F+F+FFF-F-F+F"}, "F+F+F+F", 3, 90}}, {"Siepiński sieve", {{"F" -> "FF", "X" -> "--FXF++FXF++FXF--"}, "FXF--FF--FF", 5, 60}}, {"Sierpiński arrowhead", {{"X" -> "YF+XF+Y", "Y" -> "XF-YF-X"}, "YF", 6, 60}}, {"Sierpiński curve", {{"X" -> "XF-F+F-XF+F+XF-F+F-X"}, "F+XF+F+XF", 5, 90}}};
With[{name = First@#, fractal = ResourceFunction["LSystem"] @@ Last@#},
   Graphics[Line[fractal["Branches"]], PlotLabel -> Style[name, Bold]]
   ] & /@ fractals
Out[7]=

Plot different trees:

In[8]:=
plants = {{"Plant 1", {{"F" -> "FF", "G" -> "FG[-F[G]-G][G+G][+F[G]+G]"}, "G", 4, 22.5}}, {"Plant 2", {{"G" -> "F+[[G]-G]-F[-FG]+G", "F" -> "FF"}, "G", 5, 22.5}}, {"Plant 3", {{"F" -> "FF+[+F-F-F]-[-F+F+F]"}, "F", 4, 22.5}}, {"Plant 4", {{"G" -> "F[+FFG][G]-FG", "F" -> "FF"}, "G", 6, 22.5}}, {"Plant 5", {{"G" -> "F[-G]F[+G]-G", "F" -> "FF"}, "G", 6, 20}}, {"Plant 6", {{"G" -> "F[-G][+G]FG", "F" -> "FF"}, "G", 7, 25.7}}};
With[{name = First@#, plant = ResourceFunction["LSystem"] @@ Last@#},
   Graphics[Line[plant["Branches"]], PlotLabel -> Style[name, Bold]]
   ] & /@ plants
Out[8]=

Options (3) 

InitialAngle (1) 

Show the effect of changing the initial angle:

In[9]:=
Graphics[Line /@ ResourceFunction[
      "LSystem"][{"F" -> "FF", "X" -> "--FXF++FXF++FXF--"}, "FXF--FF--FF", 5, 60, "InitialAngle" -> #]["Branches"]] & /@ {0,
   45, 90, 135, 180}
Out[9]=
In[10]:=
Graphics[Line /@ ResourceFunction["LSystem"][{"G" -> "F[-G]F[+G]-G", "F" -> "FF"}, "G", 6, 20, "InitialAngle" -> #]["Branches"]] & /@ {0, 45, 90, 135, 180}
Out[10]=

InitialPoint (1) 

Show the effect of changing the initial point:

In[11]:=
Graphics[Line /@ ResourceFunction[
      "LSystem"][{"X" -> "X+YF++YF-FX--FXFX-YF+", "Y" -> "-FX+YFYF++YF+FX--FX-Y"}, "FX", 3, 60, "InitialPoint" -> #]["Branches"], Axes -> True] & /@ RandomInteger[{-10, 10}, {5, 2}]
Out[11]=
In[12]:=
Graphics[Line /@ ResourceFunction["LSystem"][{"F" -> "FF+[+F-F-F]-[-F+F+F]"}, "F", 3, 22.5, "InitialPoint" -> #]["Branches"], Axes -> True] & /@ RandomInteger[{-10, 10}, {5, 2}]
Out[12]=

MoveLength (1) 

Show the effect of using different values for "MoveLength":

In[13]:=
Block[{branches, allSegments, segmentsLengths},
   branches = ResourceFunction["LSystem"][{"X" -> "YF+XF+Y", "Y" -> "XF-YF-X"}, "YF", 5, 60, "MoveLength" -> #]@"Branches";
   allSegments = Partition[Flatten[branches, 1] // DeleteDuplicates, 2, 1];
   segmentsLengths = EuclideanDistance @@ # & /@ allSegments;
   Grid[{
     Style[#, Bold] & /@ {"Plot", "MoveLength", "Segments length average"},
     {Graphics[Line /@ branches, Axes -> True, ImageSize -> Small], #,
       N@Mean@segmentsLengths}
     }, Frame -> All]
   ] & /@ RandomInteger[{1, 10}, 4]
Out[13]=

Applications (6) 

Show the step-by-step creation of the dragon curve:

In[14]:=
dragonCurve = ResourceFunction["LSystem"][{"X" -> "X+YF+", "Y" -> "-FX-Y"}, "FX", 10, 90, "InitialAngle" -> 0]@"Branches" // First; segments = Partition[dragonCurve, 2, 1];
segments = If[#[[1]] != #[[-1]], #, Missing[]] & /@ segments;
segments = segments // DeleteMissing;
graphics = Graphics[{Thick, Pink, Line[segments[[1 ;; #]]]}, ImageSize -> Medium] & /@ Range[2, Length@segments];
In[15]:=
Manipulate[Indexed[graphics, i], {{i, 26}, 1, Length[graphics], 1}]
Out[15]=

Show the step-by-step creation of the Peano curve:

In[16]:=
peanoCurve = ResourceFunction["LSystem"][{"F" -> "F+F-F-F-F+F+F+F-F"}, "F", 3, 90,
     "InitialAngle" -> 0]@"Branches" // First; segments2 = Partition[peanoCurve, 2, 1];
segments2 = If[#[[1]] != #[[-1]], #, Missing[]] & /@ segments2;
segments2 = segments2 // DeleteMissing;
graphics2 = Graphics[{Thick, Pink, Line[segments2[[1 ;; #]]]}, ImageSize -> Medium] & /@ Range[2, Length@segments2];
In[17]:=
Manipulate[Indexed[graphics2, i], {{i, 24}, 1, Length[graphics2], 1}]
Out[17]=

Create a colorful tree:

In[18]:=
colorfulPlant = ResourceFunction[
    "LSystem"][{"G" -> "F+[[G]-G]-F[-FG]+G", "F" -> "FF"}, "G", 5, 22.5]@"Branches";
Graphics[{Thick, RandomColor[], Line[#]} & /@ colorfulPlant // Flatten]
Out[18]=

Create a tree with green leaves:

In[19]:=
plantWithLeaves = ResourceFunction["LSystem"][{"G" -> "F[-G]F[+G]-G", "F" -> "FF"}, "G", 6, 20]@"Branches";
leafPoints = Last /@ plantWithLeaves;
leaves = Disk[#, 0.7] & /@ leafPoints;
Graphics[{Thick, Brown, Line /@ plantWithLeaves, Green, leaves}]
Out[19]=

Create a colorful plant with leaves:

In[20]:=
colorfulPlantWithLeaves = ResourceFunction[
    "LSystem"][{"F" -> "FF", "G" -> "FG[-F[G]-G][G+G][+F[G]+G]"}, "G",
     4, 22.5]@"Branches";
colorfulPlantLeafPoints = Last /@ colorfulPlantWithLeaves;
colorfulPlantLeaves = {RandomColor[], Disk[#, 0.5]} & /@ colorfulPlantLeafPoints;
Graphics[{Thick, {RandomColor[], Line@#} & /@ colorfulPlantWithLeaves,
   colorfulPlantLeaves}]
Out[20]=

Create a colorful tree with grapes:

In[21]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/37a87474-7ec5-4ccb-9f2c-5395f804f8f0"]
Out[21]=

Possible Issues (1) 

The execution time tends to grow very fast according to the number of iterations:

In[22]:=
First@AbsoluteTiming[
    ResourceFunction["LSystem"][{"F" -> "FF-F-F-F-F-F+F"}, "F-F-F-F", #, 90];] & /@ Range@4
Out[22]=
In[23]:=
First@AbsoluteTiming[
    ResourceFunction["LSystem"][{"F" -> "FF+[+F-F-F]-[-F+F+F]"}, "F", #, 22.5];] & /@ Range@5
Out[23]=

Neat Examples (2) 

An animated orange tree:

In[24]:=
greenColors = {
RGBColor[
   0.07450980392156863, 0.4196078431372549, 0.09803921568627451], 
RGBColor[0.6431372549019608, 0.7764705882352941, 0.2235294117647059], RGBColor[0., 0.439216, 0.235294], 
RGBColor[0.23649999999999993`, 0.48949999999999994`, 0.08250000000000002], 
RGBColor[0.47, 1., 0.040000000000000036`], 
RGBColor[0., 0.529412, 0.317647], 
RGBColor[0.639216, 0.686275, 0.027451], 
RGBColor[0.37, 1., 0.030000000000000027`], 
RGBColor[0., 0.309804, 0.223529], 
RGBColor[0.6, 1., 0.19999999999999996`], 
RGBColor[0.37, 1., 0.030000000000000027`], 
RGBColor[0.729412, 0.847059, 0.0392157], 
RGBColor[0., 0.337255, 0.247059], 
RGBColor[0.6235294117647059, 0.7098039215686275, 0.6823529411764706], RGBColor[0.24313725490196078`, 0.2627450980392157, 0.25882352941176473`], 
RGBColor[0.19607843137254902`, 0.3254901960784314, 0.25098039215686274`], 
RGBColor[0.2196078431372549, 0.3058823529411765, 0.2627450980392157], RGBColor[0.16470588235294117`, 0.30196078431372547`, 0.24705882352941178`], 
RGBColor[0.24705882352941178`, 0.2784313725490196, 0.25882352941176473`], 
RGBColor[0.20392156862745098`, 0.2980392156862745, 0.2627450980392157], 
RGBColor[0.6666666666666666, 0.6784313725490196, 0.6], 
RGBColor[0.5333333333333333, 0.5058823529411764, 0.403921568627451], 
RGBColor[0.32941176470588235`, 0.42745098039215684`, 0.3254901960784314], 
RGBColor[0.011764705882352941`, 0.6470588235294118, 0.5215686274509804], 
RGBColor[0.4392156862745098, 0.4117647058823529, 0.3254901960784314], RGBColor[0.5647058823529412, 0.5843137254901961, 0.5215686274509804], RGBColor[0.7529411764705882, 0.8196078431372549, 0.7686274509803922], RGBColor[0.5294117647058824, 0.5647058823529412, 0.4745098039215686], RGBColor[0.7137254901960784, 0.7254901960784313, 0.6509803921568628], RGBColor[0.7372549019607844, 0.8, 0.7803921568627451], 
RGBColor[0.9019607843137255, 0.9098039215686274, 0.8274509803921568], RGBColor[0.39215686274509803`, 0.6901960784313725, 0.5294117647058824], 
RGBColor[0.5529411764705883, 0.7294117647058823, 0.5215686274509804], RGBColor[0.3764705882352941, 0.5137254901960784, 0.3411764705882353], RGBColor[0.5490196078431373, 0.8235294117647058, 0.7372549019607844], RGBColor[0.4549019607843137, 0.47843137254901963`, 0.403921568627451], 
RGBColor[0.807843137254902, 0.8, 0.44313725490196076`], 
RGBColor[0.6745098039215687, 0.6431372549019608, 0.5568627450980392], RGBColor[0.5372549019607843, 0.4666666666666667, 0.3607843137254902], RGBColor[0.7843137254901961, 0.8235294117647058, 0.7843137254901961], RGBColor[0.8352941176470589, 0.8588235294117647, 0.7254901960784313], RGBColor[0.4196078431372549, 0.4745098039215686, 0.30196078431372547`], 
RGBColor[0.8705882352941177, 0.8823529411764706, 0.7607843137254902], RGBColor[0.6274509803921569, 0.6039215686274509, 0.5058823529411764], RGBColor[0.43529411764705883`, 0.5254901960784314, 0.4980392156862745], 
RGBColor[0.1803921568627451, 0.32941176470588235`, 0.3254901960784314], 
RGBColor[0.7254901960784313, 0.7647058823529411, 0.6823529411764706], RGBColor[0.4588235294117647, 0.42745098039215684`, 0.36470588235294116`], 
RGBColor[0.7098039215686275, 0.6509803921568628, 0.5568627450980392], RGBColor[0.1411764705882353, 0.5450980392156862, 0.4470588235294118], RGBColor[0.7686274509803922, 0.8392156862745098, 0.7686274509803922], RGBColor[0.5098039215686274, 0.5333333333333333, 0.3568627450980392], RGBColor[0.5294117647058824, 0.6313725490196078, 0.5607843137254902], RGBColor[0.4117647058823529, 0.5333333333333333, 0.5215686274509804], RGBColor[0.5215686274509804, 0.8431372549019608, 0.7294117647058823], RGBColor[0.47058823529411764`, 0.47058823529411764`, 0.38823529411764707`], 
RGBColor[0.8235294117647058, 0.8470588235294118, 0.7176470588235294], RGBColor[0.8549019607843137, 0.8509803921568627, 0.7568627450980392], RGBColor[0.8352941176470589, 0.8235294117647058, 0.7137254901960784], RGBColor[0.3333333333333333, 0.4117647058823529, 0.34509803921568627`], 
RGBColor[0.7529411764705882, 0.7490196078431373, 0.6627450980392157], RGBColor[0.4627450980392157, 0.40784313725490196`, 0.29411764705882354`], 
RGBColor[0.8470588235294118, 0.8901960784313725, 0.8470588235294118], RGBColor[0.8823529411764706, 0.9098039215686274, 0.792156862745098], 
RGBColor[0.8901960784313725, 0.9058823529411765, 0.8235294117647058], RGBColor[0.8862745098039215, 0.8823529411764706, 0.796078431372549], 
RGBColor[0.615686274509804, 0.5176470588235295, 0.3803921568627451], 
RGBColor[0.7529411764705882, 0.8352941176470589, 0.796078431372549], 
RGBColor[0.5686274509803921, 0.6196078431372549, 0.5294117647058824], RGBColor[0.611764705882353, 0.6392156862745098, 0.45098039215686275`], 
RGBColor[0.7254901960784313, 0.8705882352941177, 0.8156862745098039], RGBColor[0.9294117647058824, 0.8784313725490196, 0.7490196078431373], RGBColor[0.25882352941176473`, 0.47058823529411764`, 0.40784313725490196`], 
RGBColor[0.6313725490196078, 0.596078431372549, 0.44313725490196076`], 
RGBColor[0.5843137254901961, 0.5882352941176471, 0.28627450980392155`], 
RGBColor[0.7647058823529411, 0.8509803921568627, 0.8235294117647058], RGBColor[0.21176470588235294`, 0.44313725490196076`, 0.4235294117647059], 
RGBColor[0.28627450980392155`, 0.5098039215686274, 0.41568627450980394`], 
RGBColor[0.5882352941176471, 0.7058823529411765, 0.6823529411764706], RGBColor[0.5882352941176471, 0.7686274509803922, 0.6980392156862745], RGBColor[0.5607843137254902, 0.7450980392156863, 0.3843137254901961], RGBColor[0.8352941176470589, 0.9019607843137255, 0.8588235294117647], RGBColor[0.6588235294117647, 0.807843137254902, 0.47843137254901963`], 
RGBColor[0.7176470588235294, 0.6823529411764706, 0.5372549019607843], RGBColor[0.8235294117647058, 0.8980392156862745, 0.8392156862745098], RGBColor[0.8823529411764706, 0.9058823529411765, 0.7294117647058823], RGBColor[0.615686274509804, 0.7372549019607844, 0.30196078431372547`], 
RGBColor[0.17647058823529413`, 0.6941176470588235, 0.5450980392156862], 
RGBColor[0., 0.5490196078431373, 0.47058823529411764`], 
RGBColor[0.8274509803921568, 0.8588235294117647, 0.803921568627451], 
RGBColor[0.7764705882352941, 0.8823529411764706, 0.7490196078431373], RGBColor[0.25098039215686274`, 0.3411764705882353, 0.34509803921568627`], 
RGBColor[0.8235294117647058, 0.8901960784313725, 0.6941176470588235], RGBColor[0.6470588235294118, 0.7725490196078432, 0.5333333333333333], RGBColor[0.792156862745098, 0.8666666666666667, 0.7137254901960784], 
RGBColor[0.5882352941176471, 0.5803921568627451, 0.5058823529411764], RGBColor[0.38823529411764707`, 0.5215686274509804, 0.30196078431372547`], 
RGBColor[0.8901960784313725, 0.9058823529411765, 0.6941176470588235], RGBColor[0.4196078431372549, 0.7176470588235294, 0.5882352941176471], RGBColor[0.34901960784313724`, 0.592156862745098, 0.44313725490196076`], 
RGBColor[0.2, 0.6941176470588235, 0.6039215686274509], 
RGBColor[0.8196078431372549, 0.8352941176470589, 0.6941176470588235], RGBColor[0.6549019607843137, 0.7176470588235294, 0.3764705882352941], RGBColor[0.6862745098039216, 0.8941176470588236, 0.8], 
RGBColor[0.8784313725490196, 0.8627450980392157, 0.7686274509803922], RGBColor[0.3764705882352941, 0.592156862745098, 0.2627450980392157], 
RGBColor[0.8196078431372549, 0.8862745098039215, 0.8431372549019608], RGBColor[0.6509803921568628, 0.6509803921568628, 0.42745098039215684`], 
RGBColor[0.6980392156862745, 0.788235294117647, 0.38823529411764707`], 
RGBColor[0.9176470588235294, 0.9254901960784314, 0.7607843137254902], RGBColor[0.6862745098039216, 0.7294117647058823, 0.6745098039215687], RGBColor[0.6509803921568628, 0.6823529411764706, 0.47058823529411764`], 
RGBColor[0.13333333333333333`, 0.30980392156862746`, 0.25098039215686274`], 
RGBColor[0.6705882352941176, 0.7843137254901961, 0.6470588235294118], RGBColor[0.3764705882352941, 0.7529411764705882, 0.5607843137254902], RGBColor[0.5333333333333333, 0.47058823529411764`, 0.3411764705882353], 
RGBColor[0.26666666666666666`, 0.32941176470588235`, 0.33725490196078434`], 
RGBColor[0.8470588235294118, 0.8274509803921568, 0.3843137254901961], RGBColor[0.40784313725490196`, 0.38823529411764707`, 0.3215686274509804], 
RGBColor[0.8392156862745098, 0.9411764705882353, 0.9058823529411765], RGBColor[0.23529411764705882`, 0.7647058823529411, 0.6509803921568628], 
RGBColor[0.36470588235294116`, 0.5098039215686274, 0.1803921568627451], 
RGBColor[0.12156862745098039`, 0.3254901960784314, 0.3333333333333333], 
RGBColor[0.6509803921568628, 0.8549019607843137, 0.6666666666666666], RGBColor[0., 0.5764705882352941, 0.40784313725490196`], 
RGBColor[0.2, 0.4235294117647059, 0.24705882352941178`], 
RGBColor[0.07058823529411765, 0.34901960784313724`, 0.2784313725490196], 
RGBColor[0.5137254901960784, 0.8549019607843137, 0.7607843137254902], RGBColor[0.5098039215686274, 0.6627450980392157, 0.4666666666666667], RGBColor[0.9254901960784314, 0.9058823529411765, 0.7411764705882353], RGBColor[0.1568627450980392, 0.36470588235294116`, 0.2627450980392157], 
RGBColor[0.5725490196078431, 0.7725490196078432, 0.47058823529411764`], 
RGBColor[0.21568627450980393`, 0.4235294117647059, 0.2235294117647059], 
RGBColor[0.5843137254901961, 0.5647058823529412, 0.49019607843137253`], 
RGBColor[0.33725490196078434`, 0.3137254901960784, 0.27058823529411763`], 
RGBColor[0.10196078431372549`, 0.3568627450980392, 0.25882352941176473`], 
RGBColor[0.2196078431372549, 0.32941176470588235`, 0.3137254901960784], 
RGBColor[0.7254901960784313, 0.8666666666666667, 0.6509803921568628], RGBColor[0.30980392156862746`, 0.7411764705882353, 0.6392156862745098], 
RGBColor[0.8117647058823529, 0.6705882352941176, 0.13333333333333333`], 
RGBColor[0.29411764705882354`, 0.28627450980392155`, 0.24705882352941178`], 
RGBColor[0.796078431372549, 0.7607843137254902, 0.611764705882353], 
RGBColor[0.20392156862745098`, 0.36470588235294116`, 0.30980392156862746`], 
RGBColor[0.15294117647058825`, 0.2980392156862745, 0.25882352941176473`], 
RGBColor[0.30980392156862746`, 0.6196078431372549, 0.3058823529411765], 
RGBColor[0., 0.4627450980392157, 0.3568627450980392], 
RGBColor[0.5647058823529412, 0.4745098039215686, 0.2627450980392157], RGBColor[0.8431372549019608, 0.792156862745098, 0.38823529411764707`], 
RGBColor[0.03529411764705882, 0.37254901960784315`, 0.28627450980392155`], 
RGBColor[0.043137254901960784`, 0.35294117647058826`, 0.27450980392156865`], 
RGBColor[0.49019607843137253`, 0.8392156862745098, 0.7607843137254902], 
RGBColor[0.25098039215686274`, 0.4823529411764706, 0.40784313725490196`], 
RGBColor[0.32941176470588235`, 0.3058823529411765, 0.25882352941176473`], 
RGBColor[0., 0.6078431372549019, 0.4588235294117647], 
RGBColor[0.1568627450980392, 0.37254901960784315`, 0.27450980392156865`], 
RGBColor[0.2196078431372549, 0.7529411764705882, 0.6470588235294118], RGBColor[0.8392156862745098, 0.8549019607843137, 0.8235294117647058], RGBColor[0.30980392156862746`, 0.5450980392156862, 0.37254901960784315`], 
RGBColor[0.5803921568627451, 0.8549019607843137, 0.7254901960784313], RGBColor[0.8980392156862745, 0.8196078431372549, 0.6431372549019608], RGBColor[0., 0.6039215686274509, 0.4470588235294118], 
RGBColor[0.19215686274509805`, 0.26666666666666666`, 0.23529411764705882`], 
RGBColor[0.5019607843137255, 0.5725490196078431, 0.15294117647058825`], 
RGBColor[0.8705882352941177, 0.9176470588235294, 0.8705882352941177], RGBColor[0.12549019607843137`, 0.4980392156862745, 0.2823529411764706], 
RGBColor[0.1803921568627451, 0.6, 0.3686274509803922], 
RGBColor[0.00392156862745098, 0.5607843137254902, 0.4392156862745098], 
RGBColor[0., 0.4745098039215686, 0.34901960784313724`], 
RGBColor[0.7725490196078432, 0.8588235294117647, 0.788235294117647], 
RGBColor[0.6509803921568628, 0.5254901960784314, 0.25882352941176473`], 
RGBColor[0.6352941176470588, 0.6901960784313725, 0.08627450980392157], 
RGBColor[0.3254901960784314, 0.5725490196078431, 0.1843137254901961], RGBColor[0.4470588235294118, 0.6627450980392157, 0.24313725490196078`], 
RGBColor[0.19215686274509805`, 0.30196078431372547`, 0.2980392156862745], 
RGBColor[0.09019607843137255, 0.41568627450980394`, 0.3411764705882353], 
RGBColor[0.796078431372549, 0.9137254901960784, 0.788235294117647], 
RGBColor[0.4745098039215686, 0.7254901960784313, 0.5647058823529412], RGBColor[0.5176470588235295, 0.8431372549019608, 0.7450980392156863], RGBColor[0.2980392156862745, 0.7647058823529411, 0.6352941176470588], RGBColor[0.8313725490196079, 0.9411764705882353, 0.8941176470588236], RGBColor[0.6627450980392157, 0.6901960784313725, 0.6431372549019608], RGBColor[0.39215686274509803`, 0.7372549019607844, 0.6], 
RGBColor[0.2627450980392157, 0.5411764705882353, 0.1803921568627451], RGBColor[0.2627450980392157, 0.43529411764705883`, 0.41568627450980394`], 
RGBColor[0.5333333333333333, 0.45098039215686275`, 0.25098039215686274`], 
RGBColor[0.24705882352941178`, 0.4823529411764706, 0.30980392156862746`], 
RGBColor[0.17647058823529413`, 0.4196078431372549, 0.42745098039215684`], 
RGBColor[0.4549019607843137, 0.6392156862745098, 0.16862745098039217`], 
RGBColor[0.7764705882352941, 0.7686274509803922, 0.41568627450980394`], 
RGBColor[0.20784313725490197`, 0.3568627450980392, 0.33725490196078434`], 
RGBColor[0.8, 0.8313725490196079, 0.615686274509804], 
RGBColor[0.2196078431372549, 0.5607843137254902, 0.40784313725490196`], 
RGBColor[0., 0.4745098039215686, 0.33725490196078434`], 
RGBColor[0.22745098039215686`, 0.25882352941176473`, 0.2627450980392157], 
RGBColor[0.050980392156862744`, 0.5490196078431373, 0.4470588235294118], 
RGBColor[0.4980392156862745, 0.596078431372549, 0.24705882352941178`], 
RGBColor[0.7411764705882353, 0.9137254901960784, 0.8274509803921568], RGBColor[0.7254901960784313, 0.5764705882352941, 0.2980392156862745], RGBColor[0.49411764705882355`, 0.8431372549019608, 0.7764705882352941], 
RGBColor[0.7058823529411765, 0.9098039215686274, 0.8431372549019608], RGBColor[0.5882352941176471, 0.8117647058823529, 0.7568627450980392], RGBColor[0.5333333333333333, 0.8313725490196079, 0.7647058823529411], RGBColor[0.7725490196078432, 0.7529411764705882, 0.15294117647058825`], 
RGBColor[0.8117647058823529, 0.9411764705882353, 0.8980392156862745], RGBColor[0.6784313725490196, 0.788235294117647, 0.4196078431372549], 
RGBColor[0.6235294117647059, 0.7686274509803922, 0.6705882352941176], RGBColor[0.6784313725490196, 0.7294117647058823, 0.42745098039215684`], 
RGBColor[0.4588235294117647, 0.6431372549019608, 0.5019607843137255], RGBColor[0.37254901960784315`, 0.615686274509804, 0.5372549019607843], 
RGBColor[0.7058823529411765, 0.9058823529411765, 0.8509803921568627], RGBColor[0.7803921568627451, 0.9058823529411765, 0.8196078431372549], RGBColor[0.5333333333333333, 0.5019607843137255, 0.2901960784313726], RGBColor[0.3176470588235294, 0.5803921568627451, 0.21176470588235294`], 
RGBColor[0.37254901960784315`, 0.6039215686274509, 0.1843137254901961], 
RGBColor[0.11372549019607843`, 0.3607843137254902, 0.27450980392156865`], 
RGBColor[0.396078431372549, 0.36470588235294116`, 0.27450980392156865`], 
RGBColor[0.3215686274509804, 0.3137254901960784, 0.27058823529411763`], 
RGBColor[0.17254901960784313`, 0.44313725490196076`, 0.3411764705882353], 
RGBColor[0.24705882352941178`, 0.4549019607843137, 0.24313725490196078`], 
RGBColor[0.8705882352941177, 0.8549019607843137, 0.6], 
RGBColor[0.615686274509804, 0.4980392156862745, 0.23529411764705882`], 
RGBColor[0.6823529411764706, 0.9058823529411765, 0.8509803921568627], RGBColor[0.17254901960784313`, 0.5098039215686274, 0.21176470588235294`], 
RGBColor[0.7803921568627451, 0.7411764705882353, 0.054901960784313725`], 
RGBColor[0.20784313725490197`, 0.3176470588235294, 0.2980392156862745], 
RGBColor[0.8352941176470589, 0.8235294117647058, 0.7137254901960784], RGBColor[0.5764705882352941, 0.5607843137254902, 0.4196078431372549], RGBColor[0.5882352941176471, 0.5803921568627451, 0.5058823529411764], RGBColor[0.7686274509803922, 0.788235294117647, 0.7568627450980392], 
RGBColor[0.43137254901960786`, 0.4588235294117647, 0.3843137254901961], 
RGBColor[0.36470588235294116`, 0.40784313725490196`, 0.3686274509803922], 
RGBColor[0.4549019607843137, 0.5647058823529412, 0.4666666666666667], RGBColor[0.39215686274509803`, 0.42745098039215684`, 0.36470588235294116`], 
RGBColor[0.3843137254901961, 0.4823529411764706, 0.38823529411764707`], 
RGBColor[0.7098039215686275, 0.6784313725490196, 0.5333333333333333], RGBColor[0.4588235294117647, 0.4627450980392157, 0.3607843137254902], RGBColor[0.7098039215686275, 0.6274509803921569, 0.5176470588235295], RGBColor[0.5764705882352941, 0.403921568627451, 0.27058823529411763`], 
RGBColor[0.9254901960784314, 0.8666666666666667, 0.7372549019607844], RGBColor[0.7843137254901961, 0.7725490196078432, 0.6470588235294118], RGBColor[0.8196078431372549, 0.8235294117647058, 0.7137254901960784], RGBColor[0.5372549019607843, 0.6392156862745098, 0.5647058823529412], RGBColor[0.788235294117647, 0.803921568627451, 0.7333333333333333], 
RGBColor[0.5490196078431373, 0.5725490196078431, 0.4745098039215686], RGBColor[0.7411764705882353, 0.7607843137254902, 0.6392156862745098], RGBColor[0.26666666666666666`, 0.34901960784313724`, 0.3058823529411765], 
RGBColor[0.45098039215686275`, 0.5450980392156862, 0.4588235294117647], 
RGBColor[0.592156862745098, 0.5803921568627451, 0.49019607843137253`], 
RGBColor[0.25098039215686274`, 0.30196078431372547`, 0.3137254901960784], 
RGBColor[0.24705882352941178`, 0.32941176470588235`, 0.3568627450980392], 
RGBColor[0.3411764705882353, 0.3843137254901961, 0.30980392156862746`], 
RGBColor[0.7333333333333333, 0.7529411764705882, 0.6784313725490196], RGBColor[0.6784313725490196, 0.6941176470588235, 0.611764705882353], 
RGBColor[0.6509803921568628, 0.6705882352941176, 0.5450980392156862], RGBColor[0.5215686274509804, 0.6352941176470588, 0.5411764705882353], RGBColor[0.47843137254901963`, 0.4470588235294118, 0.3568627450980392], 
RGBColor[0.2549019607843137, 0.3254901960784314, 0.30196078431372547`], 
RGBColor[0.7843137254901961, 0.8196078431372549, 0.7215686274509804], RGBColor[0.4117647058823529, 0.5372549019607843, 0.49019607843137253`], 
RGBColor[0.3843137254901961, 0.4666666666666667, 0.39215686274509803`], 
RGBColor[0.2627450980392157, 0.3333333333333333, 0.33725490196078434`], 
RGBColor[0.20392156862745098`, 0.24705882352941178`, 0.23921568627450981`], 
RGBColor[0.21568627450980393`, 0.27450980392156865`, 0.24705882352941178`], 
RGBColor[0.26666666666666666`, 0.3137254901960784, 0.30196078431372547`], 
RGBColor[0.2235294117647059, 0.26666666666666666`, 0.25098039215686274`], 
RGBColor[0.17254901960784313`, 0.30980392156862746`, 0.3058823529411765], 
RGBColor[0.047058823529411764`, 0.41568627450980394`, 0.38823529411764707`], 
RGBColor[0.109804, 0.827451, 0.635294], 
RGBColor[0.427451, 0.682353, 0.505882], 
RGBColor[0.109804, 0.67451, 0.470588], 
RGBColor[0.941176, 0.909804, 0.568627], 
RGBColor[0.231373, 0.690196, 0.560784], 
RGBColor[0.729412, 0.721569, 0.423529], 
RGBColor[0.0823529, 0.501961, 0.470588], 
RGBColor[0.462745, 1., 0.478431], 
RGBColor[0.623529, 0.886275, 0.74902], 
RGBColor[0.92549, 0.917647, 0.745098], 
RGBColor[0.772549, 0.890196, 0.517647], 
RGBColor[0., 0.39215686274509803`, 0.], 
RGBColor[0.3333333333333333, 0.4196078431372549, 0.1843137254901961], RGBColor[0.5607843137254902, 0.7372549019607844, 0.5607843137254902], RGBColor[0.13333333333333333`, 0.5450980392156862, 0.13333333333333333`], 
RGBColor[0., 0.5019607843137255, 0.], 
RGBColor[0.6784313725490196, 1., 0.1843137254901961], 
RGBColor[0.48627450980392156`, 0.9882352941176471, 0.], 
RGBColor[0.5647058823529412, 0.9333333333333333, 0.5647058823529412], RGBColor[0.12549019607843137`, 0.6980392156862745, 0.6666666666666666], 
RGBColor[0.19607843137254902`, 0.803921568627451, 0.19607843137254902`], 
RGBColor[0.23529411764705882`, 0.7019607843137254, 0.44313725490196076`], 
RGBColor[0., 0.9803921568627451, 0.6039215686274509], 
RGBColor[0.596078431372549, 0.984313725490196, 0.596078431372549], 
RGBColor[0.1803921568627451, 0.5450980392156862, 0.3411764705882353], RGBColor[0., 1., 0.4980392156862745], 
RGBColor[0.6039215686274509, 0.803921568627451, 0.19607843137254902`], 
RGBColor[0.400006, 0.5, 0.080004], 
RGBColor[0.380001, 0.700003, 0.159993], 
RGBColor[0.239998, 0.569994, 0.250008], 
RGBColor[0., 0.790002, 0.340007], 
RGBColor[0.039995, 0.790002, 0.170003], 
RGBColor[0.189993, 0.5, 0.080004], 
RGBColor[0., 1., 0.], 
RGBColor[0.88, 1., 0.88], 
RGBColor[0.294118, 0.32549, 0.12549], 
RGBColor[0.4, 1., 0.], 
RGBColor[0.470588, 0.52549, 0.419608], 
RGBColor[0.309804, 0.47451, 0.258824], 
RGBColor[0.133333, 0.545098, 0.133333], 
RGBColor[0.21176470588235294`, 0.45098039215686275`, 0.09803921568627451], 
RGBColor[0.207843, 0.368627, 0.231373], 
RGBColor[0.0745098, 0.533333, 0.0313725], 
RGBColor[0., 0.6, 0.], 
RGBColor[0.298039, 0.733333, 0.0901961], 
RGBColor[0., 0.980392, 0.603922], 
RGBColor[0., 0.286275, 0.32549], 
RGBColor[0.596078, 1., 0.596078], 
RGBColor[0.678431, 0.87451, 0.678431], 
RGBColor[0.164706, 0.501961, 0.], 
RGBColor[0., 0.501961, 0.], 
RGBColor[0.466667, 0.866667, 0.466667], 
RGBColor[0., 0.65098, 0.576471], 
RGBColor[0., 0.647059, 0.313725], 
RGBColor[0.00392157, 0.47451, 0.435294], 
RGBColor[0.254902, 0.282353, 0.2], 
RGBColor[0.313725, 0.490196, 0.164706], 
RGBColor[0.67451, 0.717647, 0.556863], 
RGBColor[0.815686, 0.941176, 0.752941], 
RGBColor[0.00392157, 0.266667, 0.129412], 
RGBColor[0., 0.4822845599240016, 0.], 
RGBColor[0.7330658705825285, 0.8231824417303318, 0.21563079543063812`], 
RGBColor[0.12594453153684895`, 0.39266194522144654`, 0.282962833135841], 
RGBColor[0.4042380439567008, 0.7060561571912258, 0.26713702092275227`], 
RGBColor[0.45801849406438694`, 0.513638449648967, 0.]};
orangeColors = {
RGBColor[1., 0.560784, 0.], 
RGBColor[0.976471, 0.607843, 0.0470588], 
RGBColor[0.8980392156862745, 0.4235294117647059, 0.27450980392156865`], 
RGBColor[0.8705882352941177, 0.5137254901960784, 0.3803921568627451], RGBColor[0.9882352941176471, 0.7411764705882353, 0.48627450980392156`], 
RGBColor[0.9137254901960784, 0.6078431372549019, 0.3843137254901961], RGBColor[0.9411764705882353, 0.7647058823529411, 0.6705882352941176], RGBColor[1., 0.803921568627451, 0.592156862745098], 
RGBColor[0.9176470588235294, 0.6901960784313725, 0.4627450980392157], RGBColor[0.9921568627450981, 0.7803921568627451, 0.611764705882353], 
RGBColor[0.9568627450980393, 0.8627450980392157, 0.7843137254901961], RGBColor[0.9764705882352941, 0.788235294117647, 0.6078431372549019], 
RGBColor[0.9686274509803922, 0.6901960784313725, 0.47058823529411764`], 
RGBColor[0.788235294117647, 0.3843137254901961, 0.3137254901960784], 
RGBColor[0.7333333333333333, 0.4196078431372549, 0.17647058823529413`], 
RGBColor[0.8666666666666667, 0.3176470588235294, 0.24313725490196078`], 
RGBColor[0.9529411764705882, 0.4980392156862745, 0.24313725490196078`], 
RGBColor[0.9294117647058824, 0.4745098039215686, 0.16470588235294117`], 
RGBColor[0.9294117647058824, 0.7294117647058823, 0.5882352941176471], RGBColor[0.9058823529411765, 0.40784313725490196`, 0.16862745098039217`], 
RGBColor[0.8784313725490196, 0.33725490196078434`, 0.1843137254901961], 
RGBColor[0.7019607843137254, 0.3058823529411765, 0.20392156862745098`], 
RGBColor[0.9803921568627451, 0.5843137254901961, 0.11764705882352941`], 
RGBColor[0.8313725490196079, 0.2627450980392157, 0.19215686274509805`], 
RGBColor[0.8313725490196079, 0.4627450980392157, 0.29411764705882354`], 
RGBColor[0.9411764705882353, 0.4470588235294118, 0.1843137254901961], RGBColor[0.9450980392156862, 0.48627450980392156`, 0.14901960784313725`], 
RGBColor[0.8705882352941177, 0.32941176470588235`, 0.21176470588235294`], 
RGBColor[0.796078431372549, 0.36470588235294116`, 0.23529411764705882`], 
RGBColor[0.9803921568627451, 0.5607843137254902, 0.09019607843137255], 
RGBColor[0.8392156862745098, 0.29411764705882354`, 0.18823529411764706`], 
RGBColor[0.7607843137254902, 0.32941176470588235`, 0.20784313725490197`], 
RGBColor[0.8980392156862745, 0.37254901960784315`, 0.20392156862745098`], 
RGBColor[0.8705882352941177, 0.3568627450980392, 0.30196078431372547`], 
RGBColor[0.9215686274509803, 0.44313725490196076`, 0.1607843137254902], 
RGBColor[1., 0.7098039215686275, 0.40784313725490196`], 
RGBColor[0.8980392156862745, 0.3764705882352941, 0.21176470588235294`], 
RGBColor[0.9137254901960784, 0.6352941176470588, 0.48627450980392156`], 
RGBColor[0.7529411764705882, 0.34509803921568627`, 0.23529411764705882`], 
RGBColor[1., 0.498039, 0.286275], 
RGBColor[1., 0.458824, 0.219608], 
RGBColor[1., 0.168627, 0.168627], 
RGBColor[0.972549, 0.835294, 0.407843], 
RGBColor[1., 0.431373, 0.290196], 
RGBColor[1., 0.32549, 0.286275], 
RGBColor[0.992157, 0.368627, 0.32549], 
RGBColor[1., 0.682353, 0.258824], 
RGBColor[1., 0.5490196078431373, 0.], 
RGBColor[1., 0.6470588235294118, 0.], 
RGBColor[1., 0.27058823529411763`, 0.], 
RGBColor[1., 0.380001, 0.009995], 
RGBColor[0.589999, 0.269997, 0.080004], 
RGBColor[1., 0.9, 0.8], 
RGBColor[1., 0.5, 0.], 
RGBColor[0.8, 0.333333, 0.], 
RGBColor[0.929412, 0.568627, 0.129412], 
RGBColor[1., 0.309804, 0.], 
RGBColor[1., 0.627451, 0.], 
RGBColor[1., 0.8, 0.6], 
RGBColor[0.85098, 0.564706, 0.345098], 
RGBColor[1., 0.6, 0.4], 
RGBColor[1., 0.352941, 0.211765], 
RGBColor[1., 0.4, 0.], 
RGBColor[1., 0.647059, 0.], 
RGBColor[0.6771103074998008, 0.3165076195652117, 0.], 
RGBColor[0.9086505659574677, 0.532690827881931, 0.1724751598639609], 
RGBColor[0.6910561136456048, 0.3049284613273353, 0.], 
RGBColor[0.7488221988352509, 0.42069039059645064`, 0.]};
In[25]:=
plant = ResourceFunction[
    "LSystem"][{"G" -> "F+[[G]-G]-F[-FG]+G", "F" -> "FF"}, "G", 4, 22.5]@"Branches";
plantOrangePoints = Last /@ plant;
plantOrangePoints = SortBy[plantOrangePoints, Last];
plantOranges = {RandomChoice[orangeColors], , Disk[#, RandomChoice[{.3, .4, .5}]]} & /@ plantOrangePoints;
plantSegments = Flatten[Partition[#, 2, 1] & /@ plant, 1] // DeleteDuplicates;
plantSegments = SortBy[plantSegments, {First, Last}];
plantSegments = Select[plantSegments, #[[1]] != #[[-1]] &];
plantGraphic = Flatten[{RandomChoice[greenColors], Line@#} & /@ plantSegments];
plantGraphics = {};
AppendTo[plantGraphics, Graphics[Flatten[{plantGraphic, plantOranges[[1 ;; #]]}], Background -> LightBlue]] & /@ Range@Length@plantOranges;
In[26]:=
Animate[plantGraphics[[n]], {n, Range@Length@plantGraphics}, DefaultDuration -> Length[plantGraphics]*0.1, AnimationRunning -> False]
Out[26]=

Generate a snowflake:

In[27]:=
angles = N /@ Range[1, 360, 360/5];
fractals = ResourceFunction["LSystem"][{"G" -> "F[-G][+G]FG", "F" -> "FF"}, "G", 2, 45, "InitialAngle" -> #]["Branches"] & /@ angles;
Graphics[Flatten[{Thick, Cyan, Line /@ fractals}], Background -> Black]
Out[27]=

Publisher

Wolfram Summer School

Version History

  • 1.0.0 – 21 June 2021

Source Metadata

Related Resources

License Information