PIPRIME.FR BLOG

Live fully to honor life

Category L-System -- Asymptote Gallery

đź”—lsystem-fig001

Figure lsystem 001 Generated with Asymptote

Show lsystem/fig0010.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(10cm);

string[][] rules={{"F","FF"}, {"X","--FXF++FXF++FXF--"}};
Lsystem Sierpinski=Lsystem("FXF--FF--FF", rules, La=60, Lai=0);
Sierpinski.iterate(5);
draw(Sierpinski.paths(), bp+0.2*green);

shipout(bbox(Fill(paleyellow)));

đź”—lsystem-fig002

Figure lsystem 002 Generated with Asymptote

Show lsystem/fig0020.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(15cm,0);

Lsystem SierpinskiCurve=
  Lsystem("YF",
          new string[][]{{"X","YF+XF+Y"},{"Y","XF-YF-X"}},
          La=60, Lai=0);
SierpinskiCurve.iterate(7);
draw(SierpinskiCurve.paths(), bp+0.2*green);

shipout(bbox(Fill(paleyellow)));

đź”—lsystem-fig003

Figure lsystem 003 Generated with Asymptote

Show lsystem/fig0030.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(15cm,0);

Lsystem SierpinskiCarpet=
  Lsystem("F+F+F+F",
          new string[][]{{"F","FF+F+F+F+FF"}},
          La=90, Lai=0);
SierpinskiCarpet.iterate(4);
draw(SierpinskiCarpet.paths(), bp+0.2*green);

shipout(bbox(Fill(paleyellow)));

đź”—lsystem-fig004

Figure lsystem 004 Generated with Asymptote

Source

Show lsystem/fig0040.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;

size(15cm,0);
Lsystem Koch=Lsystem("+F--F--F",
                     new string[][]{{"F","F+F--F+F"}},
                     La=60, Lai=0);
Koch.iterate(4);
filldraw(Koch.paths()[0]&cycle, paleyellow, 1bp+black);
shipout(bbox(2mm, Fill(lightyellow)));

đź”—lsystem-fig005

Figure lsystem 005 Generated with Asymptote

Show lsystem/fig0050.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;

size(15cm,0);
Lsystem Koch=Lsystem("+F+F+F+F+F",
                     new string[][]{{"F","F-F++F-F"}},
                     La=72);
Koch.iterate(4);
filldraw(Koch.paths()[0]&cycle, paleyellow, 1bp+black);
shipout(bbox(2mm, Fill(lightyellow)));

đź”—lsystem-fig006

Figure lsystem 006 Generated with Asymptote

Show lsystem/fig0060.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;

size(10cm,0);
Lsystem Koch=Lsystem("-F--F--F",
                     new string[][]{{"F","F-F++F-F"}},
                     La=60);
Koch.iterate(4);
filldraw(Koch.paths()[0]&cycle, paleyellow, 1bp+black);
shipout(bbox(2mm, Fill(lightyellow)));

đź”—lsystem-fig007

Figure lsystem 007 Generated with Asymptote

Show lsystem/fig0070.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

// Quadratic Koch Island
import Lsystem;
size(10cm,0);

string[][] rules={{"F","F-F+F+FFF-F-F+F"}};
Lsystem QuadraticKochIsland=Lsystem("F+F+F+F", rules, La=90, Lai=0);
QuadraticKochIsland.iterate(3);
draw(QuadraticKochIsland.paths(), bp+0.9*yellow);
shipout(bbox(3mm, Fill(black)));

đź”—lsystem-fig008

Figure lsystem 008 Generated with Asymptote

Source.

Show lsystem/fig0080.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(10cm,0);

Lsystem HilbertCurve=Lsystem("X",
                             new string[][]{{"X","-YF+XFX+FY-"},{"Y","+XF-YFY-FX+"}},
                             La=90, Lai=0);
HilbertCurve.iterate(6);
draw(HilbertCurve.paths(), linewidth(1bp));

shipout(bbox(Fill(lightgrey)));

đź”—lsystem-fig009

Figure lsystem 009 Generated with Asymptote

Show lsystem/fig0090.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(10cm,0);

Lsystem Fass=Lsystem("-L",
                     new string[][]{{"L","LFLF+RFR+FLFL-FRF-LFL-FR+F+RF-LFL-FRFRFR+"},
                                    {"R","-LFLFLF+RFR+FL-F-LF+RFR+FLF+RFRF-LFL-FRFR"}},
                     La=90);
Fass.iterate(3);
draw(Fass.paths(), linewidth(1bp));

shipout(bbox(Fill(lightgrey)));

đź”—lsystem-fig010

Figure lsystem 010 Generated with Asymptote

Show lsystem/fig0100.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(10cm,0);
currentprojection=currentprojection=orthographic((10,5,6));

string[][] rules={{"X","^<XF^<XFX-F^>>XFX&F+>>XFX-F>X->"}};
Lsystem3 HilbertCurve3D=Lsystem3("X", rules, La=90);
HilbertCurve3D.iterate(3);

// !! Use a lot of memory !!
/* path3[] g=HilbertCurve3D.paths3();
   draw(g[0], linewidth(bp)+0.9*yellow);
*/

HilbertCurve3D.drawpaths3(linewidth(bp)+0.9*yellow);

shipout(bbox(3mm, Fill(black)));

đź”—lsystem-fig011

Figure lsystem 011 Generated with Asymptote

Show lsystem/fig0110.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(15cm,0);

string[][] rules={{"F","FF"},
                  {"H","+F+FH++FFH++F+FF+FH++FFH++F+F-"}};

Lsystem H=Lsystem("+H",rules, La=90);
H.iterate(5);
draw(H.paths(), white);

shipout(bbox(3mm, Fill(black)));

đź”—lsystem-fig012

Figure lsystem 012 Generated with Asymptote

Source.

Show lsystem/fig0120.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(10cm,0);

string[][] rules=new string[][]{{"F",""},{"X","-FX++FY-"},{"Y","+FX--FY+"}};
Lsystem dragon=Lsystem("X",rules, La=45, Lai=0);
dragon.iterate(12);
draw(dragon.paths(), white);

shipout(bbox(3mm, Fill(black)));

đź”—lsystem-fig013

Figure lsystem 013 Generated with Asymptote

Show lsystem/fig0130.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(12cm,0);

string[][] rules={{"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+"}};
Lsystem segment32Curve= Lsystem("F+F+F+F", rules, La=90, Lai=45);
segment32Curve.iterate(2);
filldraw(segment32Curve.paths()[0]&cycle, 0.8*yellow, blue);
shipout(bbox(3mm, Fill(black)));

đź”—lsystem-fig014

Figure lsystem 014 Generated with Asymptote

Show lsystem/fig0140.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

// Peano Gosper curve
import Lsystem;
size(12cm,0);

Lsystem PeanoGosperCurve=
  Lsystem("FX",
          new string[][]{{"X","X+YF++YF-FX--FXFX-YF+"},{"Y","-FX+YFYF++YF+FX--FX-Y"}},
          La=60, Lai=0);
PeanoGosperCurve.iterate(4);
draw(PeanoGosperCurve.paths(), bp+0.9*yellow);

shipout(bbox(3mm, Fill(black)));

đź”—lsystem-fig015

Figure lsystem 015 Generated with Asymptote

Show lsystem/fig0150.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(12cm,0);

string[][] rules={{"X","XF-F+F-XF+F+XF-F+F-X"}};
Lsystem squareCurve= Lsystem("F+XF+F+XF", rules, La=90, Lai=45);
squareCurve.iterate(5);
filldraw(squareCurve.paths()[0]&cycle, grey, 1bp+0.9*yellow);
shipout(bbox(3mm, Fill(black)));

đź”—lsystem-fig016

Figure lsystem 016 Generated with Asymptote

Show lsystem/fig0160.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(12cm,0);

string[][] rules={{"L","+R-F-R+"}, {"R","-L+F+L-"}};
Lsystem squareCurve= Lsystem("L--F--L--F", rules, La=45, Lai=45);
squareCurve.iterate(9);
filldraw(squareCurve.paths()[0]&cycle, grey, 1bp+0.9*yellow);

shipout(bbox(3mm, Fill(black)));

đź”—lsystem-fig017

Figure lsystem 017 Generated with Asymptote

Show lsystem/fig0170.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(10cm,0);

string[][] rules={
  {"F", "F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF"},
  {"f", "ffffff"}
};

Lsystem oer=Lsystem("F+F+F+F",rules,La=91);

oer.iterate(2);
draw(oer.paths(), bp+0.8*yellow);
shipout(bbox(2mm, Fill(black)));

đź”—lsystem-fig018

Figure lsystem 018 Generated with Asymptote

Show lsystem/fig0180.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(15cm,0);

string[][] rules={
  {"F", ""},
  {"P", "--FR++++FS--FU"},
  {"Q", "FT++FR----FS++"},
  {"R", "++FP----FQ++FT"},
  {"S", "FU--FP++++FQ--"},
  {"T", "+FU--FP+"},
  {"U", "-FQ++FT-"}
};

Lsystem pentive=Lsystem("Q", rules, La=36, Lai=180);

pentive.iterate(8);
draw(pentive.paths(), 0.8*yellow);
shipout(bbox(2mm, Fill(black)));

đź”—lsystem-fig019

Figure lsystem 019 Generated with Asymptote

Show lsystem/fig0190.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(12cm,0);

string[][] rules={
  {"A", "X+X+X+X+X+X+"},
  {"X", "[F+F+F+F[---X-Y]+++++F++++++++F-F-F-F]"},
  {"Y", "[F+F+F+F[---Y]+++++F++++++++F-F-F-F]"}
};

Lsystem spiral=Lsystem("AAAA",rules,La=15);

spiral.iterate(6);
draw(spiral.paths(), 0.9*green);

shipout(bbox(2mm, Fill(black)));

đź”—lsystem-fig020

Figure lsystem 020 Generated with Asymptote

Rhombus tiling (P3)).

Show lsystem/fig0200.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Tiling

import Lsystem;
size(12cm,0);

string[][] rules={
  {"6","8F++9F----7F[-8F----6F]++"},
  {"7","+8F--9F[---6F--7F]+"},
  {"8","-6F++7F[+++8F++9F]-"},
  {"9","--8F++++6F[+9F++++7F]--7F"},
  {"F",""}
};

Lsystem Penrose=Lsystem("[7]++[7]++[7]++[7]++[7]", rules, La=36);
Penrose.iterate(4);
draw(Penrose.paths(), linewidth(bp));

shipout(bbox(2mm, FillDraw(lightyellow,linewidth(1mm))));

đź”—lsystem-fig021

Figure lsystem 021 Generated with Asymptote

Penrose tiling

Show lsystem/fig0210.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Tiling

import Lsystem;
size(12cm,0);

string[][] rules={
  {"W", "YF++ZF----XF[-YF----WF]++"},
  {"X", "+YF--ZF[---WF--XF]+"},
  {"Y", "-WF++XF[+++YF++ZF]-"},
  {"Z", "--YF++++WF[+ZF++++XF]--XF"},
  {"F", ""}
};

Lsystem Penrose=Lsystem("++ZF----XF-YF----WF",rules,La=36);

Penrose.iterate(4);
draw(Penrose.paths(), linewidth(bp));

shipout(bbox(2mm, FillDraw(lightyellow,linewidth(1mm))));

đź”—lsystem-fig022

Figure lsystem 022 Generated with Asymptote

Show lsystem/fig0220.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Tiling

import Lsystem;
size(12cm,0);

string[][] rules={
  {"W", "YF++ZF----XF[-YF----WF]++"},
  {"X", "+YF--ZF[---WF--XF]+"},
  {"Y", "-WF++XF[+++YF++ZF]-"},
  {"Z", "--YF++++WF[+ZF++++XF]--XF"},
  {"F", ""}
};

Lsystem Penrose=Lsystem("[X][Y]++[X][Y]++[X][Y]++[X][Y]++[X][Y]",rules,La=36);

Penrose.iterate(3);
draw(Penrose.paths(), linewidth(bp));

shipout(bbox(2mm, FillDraw(lightyellow,linewidth(1mm))));

đź”—lsystem-fig023

Figure lsystem 023 Generated with Asymptote

Inspiration.

Show lsystem/fig0230.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(10cm, 10cm);
settings.outformat="pdf"; // for opacity

string[][] rules=new string[][]{{"F", "FF-[-F+F+F]+[+F-F-F]"}};
Lsystem plant=Lsystem("F", rules, La=22.5, Lai=90);
plant.iterate(5);
path[] g=plant.paths();

tree g=plant.tree();

for (int i:g.keys) {
  if((g[i].depth == 0)) draw(g[i].g, yellow);
}

for (int i:g.keys) {
  if((g[i].depth > 0 )) draw(g[i].g, green+opacity(0.5));
}

for (int i:g.keys) {
  if((g[i].depth > 15)) draw(g[i].g, brown+opacity(0.3));
}

shipout(bbox(Fill(paleyellow)));

đź”—lsystem-fig024

Figure lsystem 024 Generated with Asymptote

Inspirtaion.

Show lsystem/fig0240.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | L-System
Tags : #L-System | #Fractals

import Lsystem;
size(10cm,10cm);
settings.outformat="pdf"; // for opacity

string[][] rules=new string[][]{{"F", "FF"},{"X", "F-[[X]+X]+F[+FX]-X"}};
Lsystem plant=Lsystem("X", rules, La=22.5, Lai=90);
plant.iterate(8);
path[] g=plant.paths();

tree g=plant.tree();

for (int i:g.keys) {
  if((g[i].depth <= 2 )) draw(g[i].g, yellow);
}

for (int i:g.keys) {
  if((g[i].depth > 2 ) && (g[i].depth <= 10 )) draw(g[i].g, green+opacity(0.5));
}

for (int i:g.keys) {
  if((g[i].depth > 11)) draw(g[i].g, brown+opacity(0.3));
}

shipout(bbox(Fill(paleyellow)));

0%