GithubHelp home page GithubHelp logo

imclab / lsys.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yuvadm/lsys.js

0.0 2.0 0.0 108 KB

3D L-Systems JavaScript Implementation

Home Page: http://yuvadm.github.com/lsys.js

License: ISC License

lsys.js's Introduction

L-Systems.JS

A complete, 3D L-Systems implementation in JavaScript. Generates trees by production rules and draws by converting to cartesian coordinates.

Usage

var lsys = new LSystem('F', { 'F' : 'F-F+FF' }).iterate(2);
var tree = lsys.print();
console.log(tree);  // F-F+FF-F-F+FF+F-F+FFF-F+FF
var coords = lsys.draw(Math.PI / 2);  // draw tree with alpha as 90 degrees
console.log(coords);  // [[0,0,0], [0,1,0], [1,1,0], ...

Definition

An L-system is a formal grammar defined as an initial axiom string, and a set of production rules. In the aforementioned example, F is the initial axiom, and only one production rule exists: F -> F-F+FF. The grammar alphabet is assumed to be all characters with a production rule mapping.

Syntax

  • F: draw and move one unit vector forward
  • +/-: turn right / left
  • &/^: pitch up / down
  • </>: roll right / left
  • |: reverse vector direction
  • [/]: push / pop current tree state

More

For more info and examples, check out http://yuvadm.github.com/lsys.js

lsys.js's People

Contributors

yuvadm avatar

Watchers

JT5D avatar James Cloos 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.