Git Product home page Git Product logo

treegenerator's Introduction

TreeGenerator

2D trees with JavaScript, just because. Although by tweaking the settings you can get pretty much any kind of drawing.

With the colorful setting on: Tree generator


Generating some trees on a canvas element:

$(document).ready(function(){
	var canvas = $('canvas');
	var tree = new TreeGenerator(canvas);
	tree.start();
});

Custom options can be passed as a second argument to the tree generator:

// Customization options, along with their default values:
loss: 0.03, // Width loss per cycle
minSleep: 10, // Min sleep time (For the animation)
branchLoss: 0.8, // % width maintained for branches
mainLoss: 0.8, // % width maintained after branching
speed: 0.3, // Movement speed
newBranch: 0.8, // Chance of not starting a new branch 
colorful: false, // Use colors for new trees
fastMode: true, // Fast growth mode
fadeOut: true, // Fade slowly to black
fadeAmount: 0.05, // How much per iteration
autoSpawn: true, // Automatically create trees
spawnInterval: 250, // Spawn interval in ms
initialWidth: 10, // Initial branch width
indicateNewBranch: false, // Display a visual indicator when a new branch is born
fitScreen: true // Resize canvas to fit screen

Try the dat.gui controls on the demo to find the optimal settings for you.

Contributing

This project was done mainly for fun, and as such is lacking many features that might be useful if someone actually wants to implement it seriously. If you do so, please feel free to contribute to the project.

License

TreeGenerator is released under the MIT license

Analytics

treegenerator's People

Contributors

aurbano avatar yehonal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.