{"id":46346398,"url":"https://github.com/nylki/lindenmayer","last_synced_at":"2026-03-04T21:36:54.851Z","repository":{"id":39916215,"uuid":"42206412","full_name":"nylki/lindenmayer","owner":"nylki","description":"Feature complete classic L-System library (branching, context sensitive, parametric) \u0026 multi-purpose modern L-System/LSystem implementation that can take javascript functions as productions. It is not opinionated about how you do visualisations.","archived":false,"fork":false,"pushed_at":"2025-06-17T10:38:43.000Z","size":814,"stargazers_count":187,"open_issues_count":6,"forks_count":14,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-08-09T09:56:07.759Z","etag":null,"topics":["fractal","l-systems","lindenmayer","lsystem","turtle-graphics"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nylki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-09T21:43:21.000Z","updated_at":"2025-06-17T16:32:10.000Z","dependencies_parsed_at":"2022-08-31T22:01:39.143Z","dependency_job_id":null,"html_url":"https://github.com/nylki/lindenmayer","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/nylki/lindenmayer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylki%2Flindenmayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylki%2Flindenmayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylki%2Flindenmayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylki%2Flindenmayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nylki","download_url":"https://codeload.github.com/nylki/lindenmayer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylki%2Flindenmayer/sbom","scorecard":{"id":699920,"data":{"date":"2025-08-18","repo":{"name":"github.com/nylki/lindenmayer","commit":"94939c5f9de8de886665f382b4ea55b75192f3bf"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":1.5,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 15.3 not signed: https://api.github.com/repos/nylki/lindenmayer/releases/18164513","Warn: release artifact 1.5 not signed: https://api.github.com/repos/nylki/lindenmayer/releases/11755045","Warn: release artifact 1.4.0 not signed: https://api.github.com/repos/nylki/lindenmayer/releases/11687260","Warn: release artifact 1.3.7 not signed: https://api.github.com/repos/nylki/lindenmayer/releases/11425930","Warn: release artifact 1.3.3 not signed: https://api.github.com/repos/nylki/lindenmayer/releases/5843805","Warn: release artifact 15.3 does not have provenance: https://api.github.com/repos/nylki/lindenmayer/releases/18164513","Warn: release artifact 1.5 does not have provenance: https://api.github.com/repos/nylki/lindenmayer/releases/11755045","Warn: release artifact 1.4.0 does not have provenance: https://api.github.com/repos/nylki/lindenmayer/releases/11687260","Warn: release artifact 1.3.7 does not have provenance: https://api.github.com/repos/nylki/lindenmayer/releases/11425930","Warn: release artifact 1.3.3 does not have provenance: https://api.github.com/repos/nylki/lindenmayer/releases/5843805"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"25 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T04:57:36.923Z","repository_id":39916215,"created_at":"2025-08-22T04:57:36.923Z","updated_at":"2025-08-22T04:57:36.923Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30094143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T20:42:30.420Z","status":"ssl_error","status_checked_at":"2026-03-04T20:42:30.057Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fractal","l-systems","lindenmayer","lsystem","turtle-graphics"],"created_at":"2026-03-04T21:36:54.246Z","updated_at":"2026-03-04T21:36:54.841Z","avatar_url":"https://github.com/nylki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lindenmayer [![Build Status](https://travis-ci.org/nylki/lindenmayer.svg?branch=master)](https://travis-ci.org/nylki/lindenmayer) ![minified gzip size](https://badgen.net/bundlephobia/minzip/lindenmayer)\n\nLindenmayer is a [L-System](https://en.wikipedia.org/wiki/L-system) javascript library with focus on a concise syntax. The idea is to have a powerful but simple base functionality, that can handle most use-cases by simply allowing anonymous functions as productions, which makes it very flexible in comparison to classic L-Systems.\n\nThe library can also parse to some extent classic L-System syntax as defined in Aristid Lindenmayers original work *Algorithmic Beauty of Plants* from 1990. For example branches: `[]` or context sensitive productions: `\u003c\u003e`.\n\n\nIf you simply want to work with L-Systems in 3D and VR without defining your own draw methods, you can check out the accompanying [aframe-lsystem-component](https://github.com/nylki/aframe-lsystem-component).\n\n[Full API doc](https://github.com/nylki/lindenmayer/blob/master/docs/index.md) | [Getting Started](https://github.com/nylki/lindenmayer#quick-intro) | [A-Frame (VR) L-System component](https://github.com/nylki/aframe-lsystem-component)\n\n\n[![3D Hilbert Curve rendered in Interactive L-System builder.](https://cloud.githubusercontent.com/assets/1710598/16453037/a9016230-3e0b-11e6-8268-762437de3c29.png)](http://nylki.github.io/lindenmayer/examples/interactive_lsystem_builder/index_3d.html)\n\n## Examples\n-  [codepen collection (editable!)](https://codepen.io/collection/AVvqeg/)\n-  [Examples for the accompanying A-Frame component of this library](http://nylki.github.io/aframe-lsystem-component/)\n-  [Interactive L-System builder (2D turtle graphics)](http://nylki.github.io/lindenmayer/examples/interactive_lsystem_builder/index.html)\n-  [Interactive L-System builder (3D turtle graphics)](http://nylki.github.io/lindenmayer/examples/interactive_lsystem_builder/index_3d.html)\n-  [Basic Tree](http://nylki.github.io/lindenmayer/examples/tree.html)\n- [Basic Tree (rendered in three.js)](http://nylki.github.io/lindenmayer/examples/tree25d.html)\n\n## Install\n### Direct download\n- [Download latest `lindenmayer.browser.js`](https://github.com/nylki/lindenmayer/releases/latest):\n- Then in your `index.html`:\n\n```.html\n\u003cscript src=\"lindenmayer.browser.js\"\u003e\u003c/script\u003e\n```\n### npm\nIf you would like to use npm instead of directly downloading:\n\n```.sh\nnpm install --save lindenmayer\n```\n\nThen in your Node.js script:\n\n```.js\nvar LSystem = require('lindenmayer')\n```\n\nor via import syntax:\n\n```.js\nimport LSystem from 'lindenmayer'\n```\n\nOr in your `index.html`:\n\n```.html\n\u003cscript src=\"node_modules/lindenmayer/dist/lindenmayer.browser.js\"\u003e\u003c/script\u003e\n```\n\nSee [releases](https://github.com/nylki/lindenmayer/releases) for change logs.\n\n## Quick Intro\n\n```.js\n// Initializing a L-System that produces the Koch-curve\nlet kochcurve = new LSystem({\n      axiom: 'F++F++F',\n      productions: {'F': 'F-F++F-F'}\n})\n// Iterate the L-System two times and log the result.\nlet result = kochcurve.iterate(2)\nconsole.log(result)\n//'F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F++F\n//-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F'\n```\n\nThere are multiple ways to set productions, including javascript functions:\n\n```.js\n// Directly when initializing a new L-System object:\nlet lsystem = new LSystem({\n  axiom: 'ABC',\n  productions: { 'B': 'BB' }\n})\n\n// After initialization:\nlsystem.setProduction('B', 'F+F')\n\n\n// Stochastic L-System:\nlsystem.setProduction('B', {\n  successors: [\n  {weight: 50, successor: 'X'}, // 50% probability\n  {weight: 25, successor: 'XB'},// 25% probability\n  {weight: 25, successor: 'X+B'}// 25% probability\n]})\n\n// Context Sensitive:\nlsystem.setProduction('B', {leftCtx: 'A', successor: 'B', rightCtx: 'C'})\n\n// or if you prefer the concise *classic* syntax for context sensitive productions:\nlsystem.setProduction('A\u003cB\u003eC', 'Z')\n\n\n\n// You can also use ES6 arrow functions. Here a Simple (custom) stochastic production, producing `F` with 10% probability, `G` with 90%\nlsystem.setProduction('B', () =\u003e (Math.random() \u003c 0.1) ? 'F' : 'G')\n\n\n//Or make use of additional info fed into production functions on runtime.\n// Here: return 'B-' if 'B' is in first half of word/axiom, otherwise 'B+'\nlsystem.setProduction('B', (info) =\u003e (info.currentAxiom.length / 2) \u003c= info.index ? 'B-' : 'B+')\n```\n\n\n\n# Documentation\nThe following section is a quick overview. Please refer to the [full documentation](https://github.com/nylki/lindenmayer/blob/master/docs/index.md) for a detailed usage reference. \n\n## Initialization\n\n```.js\nlet lsystem = new LSystem(options)\n```\n\n`options` may contain:\n- `axiom`: A String or an Array of Objects to set the initial axiom (sometimes called axiom, start or initiator).\n- `productions`: key-value Object to set the productions from one symbol to its axiom. Used when calling iterate(). A production can be either a String, Object or a Function.\n- `finals`: Optional key-value Object to set functions that should be executed each symbol in sequential order when calling final(). Useful for visualization.\n\nadvanced options (see [API docs](https://github.com/nylki/lindenmayer/blob/master/docs/index.md) for details):\n\n- `branchSymbols`: A String of two characters. Only used when working with classic context sensitive productions. The first symbol is treated as start of a branch, the last symbol as end of a branch. (default: `\"[]\"`, but only when using classic CS syntax)\n- `ignoredSymbols`: A String of characters to ignore when using context sensitive productions. (default: `\"+-\u0026^/|\\\\\"`, but only when using classic CS syntax)\n\u003c!-- `classicParametricSyntax`: A Bool to enable *experimental* parsing of parametric L-Systems as defined in Lindenmayers book *Algorithmic Beauty of Plants*. (default: `false`)--\u003e\n\nMost often you will find yourself only setting `axiom`, `productions` and `finals`.\n\n## Setting an Axiom\nAs seen in the first section you can simply set your axiom when you init your L-System.\n\n```.js\nlet lsystem = new LSystem({\n      axiom: 'F++F++F'\n})\n```\n\nYou can also set an axiom after initialization:\n\n```.js\nlet lsystem = new LSystem({\n      axiom: 'F++F++F'\n})\nlsystem.setAxiom('F-F-F')\n```\n\n\n## Setting Productions\nProductions define how the symbols of an axiom get transformed. For example, if you want all `A`s to be replaced by `B` in your axiom, you could construct the following production:\n```.js\nlet lsystem = new LSystem({\n  axiom: 'ABC',\n  productions: {'A': 'B'}\n})\n//lsystem.iterate() === 'BBC'\n```\n\nYou can set as many productions on initialization as you like:\n\n```.js\nlet lsystem = new LSystem({\n      axiom: 'ABC',\n      productions: {\n        'A': 'A+',\n        'B': 'BA',\n        'C': 'ABC'\n      }\n})\n// lsystem.iterate() === 'A+BAABC'\n```\n\nYou could also start with an empty L-System object, and use `setAxiom()` and `setProduction()` to edit the L-System later:\n\n```.js\nlet lsystem = new LSystem()\nlsystem.setAxiom('ABC')\nlsystem.setProduction('A', 'AAB')\nlsystem.setProduction('B', 'CB')\n```\n\nThis can be useful if you want to dynamically generate and edit L-Systems. For example, you might have a UI, where the user can add new production via a text box.\n\nA major feature of this library is the possibility to use functions as productions, which could be used for stochastic L-Systems:\n\n```.js\n// This L-System produces `F+` with a 70% probability and `F-` with 30% probability\nlet lsystem = new LSystem({\n      axiom: 'F++F++F',\n      productions: {'F': () =\u003e (Math.random() \u003c= 0.7) ? 'F+' : 'F-'}\n})\n\n// Productions can also be changed later:\nlsys.setProduction('F', () =\u003e (Math.random() \u003c 0.2) ? 'F-F++F-F' : 'F+F')\n```\n\nIf you are using functions as productions, your function can make use of a number of additional parameters that are passed as an info object to the function (see [full docs](https://github.com/nylki/lindenmayer/blob/master/docs/index.md#function-based-productions) for more details):\n\n```.js\nlsys.setAxiom('FFFFF')\nlsys.setProduction('F', (info) =\u003e {\n  // Use the `index` to determine where inside the current axiom, the function is applied on.\n  if(info.index === 2) return 'X';\n})\n// lsys.iterate() === FFXFF\n```\n\nThe `info` object includes:\n- `index`: the index inside the axiom\n- `currentAxiom`: the current full axiom/word\n- `part`: the current part (symbol or object) the production is applied on. This is especially useful if you are using parametric L-Systems (see last chapter) to have access to parameters of a symbol.\n\nFor a shorter notation you could use the ES6 feature of [object destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring) (has support in most modern browsers):\n```.js\nlsys.setProduction('F', ({index}) =\u003e index === 2  ? 'X' : false);\n```\n\nIf `undefined` or `false` is returned in a production function, as above, the initiating symbol or symbol object is returned (in aboves example, that would be`'F'`).\n\n\n### Getting Results\nNow that we have set up our L-System set, we want to generate new axioms with `iterate()`:\n\n```.js\n// Iterate once\nlsystem.iterate();\n\n// Iterate n-times\nlsystem.iterate(5);\n```\n\n`iterate()` conveniently returns the resulting string:\n\n```.js\nconsole.log(lsystem.iterate())\n```\n\nIf you want to fetch the result later, use `getString()`:\n\n```.js\nlsystem.iterate()\nconsole.log(lsystem.getString())\n```\n\n\n### Putting it all together\n#### Final functions: Visualization and other post processing\n\nMost likely you want to visualize or post-process your L-Systems output in some way.\nYou could iterate and parse the result yourself, however `lindemayer` already offers an easy way to define\nsuch postprocessing: *final* functions. In those final functions you can define what should be done for each literal/character. The classic way to use L-Systems is to visualize axioms with [turtle graphics](https://en.wikipedia.org/wiki/Turtle_graphics).\nThe standard rules, found in Aristid Lindenmayer's and Przemyslaw Prusinkiewicz's classic work [Algorithmic Beauty of Plants](http://algorithmicbotany.org/papers/#abop) can be easily implented this way, to output the fractals onto a [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API).\n\n\nYou can fiddle with the following example in [this codepen](http://codepen.io/nylki/pen/QNYqzd)!\n```.html\n\u003cbody\u003e\n\t\u003ccanvas id=\"canvas\" width=\"1000\" height=\"1000\"\u003e\u003c/canvas\u003e\n\u003c/body\u003e\n\n```\n\n```.js\nvar canvas = document.getElementById('canvas')\nvar ctx = canvas.getContext(\"2d\")\n\n// translate to center of canvas\nctx.translate(canvas.width / 2, canvas.height / 4)\n\n// initialize a koch curve L-System that uses final functions\n// to draw the fractal onto a Canvas element.\n// F: draw a line with length relative to the current iteration (half the previous length for each step)\n//    and translates the current position to the end of the line\n// +: rotates the canvas 60 degree\n// -: rotates the canvas -60 degree\n\nvar koch = new LSystem({\n  axiom: 'F++F++F',\n  productions: {'F': 'F-F++F-F'},\n  finals: {\n    '+': () =\u003e { ctx.rotate((Math.PI/180) * 60) },\n    '-': () =\u003e { ctx.rotate((Math.PI/180) * -60) },\n    'F': () =\u003e {\n      ctx.beginPath()\n      ctx.moveTo(0,0)\n      ctx.lineTo(0, 40/(koch.iterations + 1))\n      ctx.stroke()\n      ctx.translate(0, 40/(koch.iterations + 1))}\n   }\n})\n\nkoch.iterate(3)\nkoch.final()\n```\n\nAnd the result:\n\n[![Resulting image](https://cloud.githubusercontent.com/assets/1710598/15099304/09a530d6-1552-11e6-8261-fd302c5c89f6.png)](http://codepen.io/nylki/pen/QNYqzd)\n\nAs this library is not opinionated about what your results should be like, you can write your own `finals`.\nTherefore you can draw 2D turtle graphics as seen above, but also 3D ones with WebGL/three.js, or even do other things like creating sound!\n\n## Advanced Usage\n### Parametric L-Systems\n\nWhen defining axioms you may also use an Array of Objects instead of basic Strings. This makes your L-System very flexible because you can inject custom parameters into your symbols. Eg. a symbol like a `A` may contain a `food` variable to simulate organic growth:\n\n```.js\nlet parametricLsystem = new lsys.LSystem({\n  axiom: [\n    {symbol: 'A', food:0.5},\n    {symbol: 'B'},\n    {symbol: 'A', , food:0.1},\n    {symbol: 'C'}\n  ],\n  // And then do stuff with those custom parameters in productions:\n  productions: {\n    'A': ({part, index}) =\u003e {\n      // split A into one A and a new B if it ate enough:\n      if(part.food \u003e= 1.0) {\n        return [{symbol: 'A', food:0}, {symbol: 'B', food:0}]\n      } else {\n        // otherwise eat a random amount of food\n        part.food += Math.random() * 0.1;\n        return part;\n      }\n    }\n  }\n});\n\n// parametricLsystem.iterate(60);\n// Depending on randomness:\n// parametricLsystem.getString() ~= 'ABBBBBABBBC';\n// The first part of B's has more B's because the first A got more initial food which in the end made a small difference, as you can see.\n```\n\nAs you can see above, you need to explicitly define the `symbol` value, so the correct production can be applied.\n\n[Full Documentation](https://github.com/nylki/lindenmayer/blob/master/docs/index.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnylki%2Flindenmayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnylki%2Flindenmayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnylki%2Flindenmayer/lists"}