Giter VIP home page Giter VIP logo

l-system-explorations's Introduction

L-system-explorations

A repository tackeling the diverse visual outputs of L-Systems. Based on a introduction by Daniel Shiffmann and his book The Nature of Code

Basics

L-Systems are based on strings and are a way to apply a recursive function to a sentence.

Every L-System consists of:

  • Alphabet: e.g. A B
  • Axiom: Generation Zero Sentence, e.g. 'A'
  • Ruleset:
    • 'A' => A B A
    • 'B' => B B B
         A

  A      B      A

A B A  B B B  A B A 

Code Approach

We are using a recursive function to create an always growing array of characters. Check code example NOC_8_08_SimpleLSystem

Gen1  [A]
Gen2  [A, B, A]
Gen3  [A, B, A, B, B, B, A, B, A]

In Processing we use a StringBuffer for this, it's very efficent and comes with an append() method.

### Drawing with L-Systems

Similar to the Turtle Drawing approach. A turtle can:

  • 'F' => Draw a line (line(), translate())
  • 'G' => Move fwd without drawing (translate())
  • '+' => Turn right (at some angle) (rotate())
  • '-' => Turn left (at some angle) (rotate())

But in order to be able to draw fractal patterns you also need to be able to save some positions:

  • '[' => save state (position, direction) (pushMatrix())
  • ']' => restore state (go there) (popMatrix())

Check code example NOC_8_09_LSystem

References

l-system-explorations's People

Contributors

maxfrischknecht avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.