Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aurbano/treegenerator
:evergreen_tree: Trees with JavaScript, just because why not?
https://github.com/aurbano/treegenerator
canvas experiment javascript tree-generator
Last synced: about 3 hours ago
JSON representation
:evergreen_tree: Trees with JavaScript, just because why not?
- Host: GitHub
- URL: https://github.com/aurbano/treegenerator
- Owner: aurbano
- License: mit
- Created: 2014-09-30T16:26:42.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-12-18T20:57:39.000Z (almost 5 years ago)
- Last Synced: 2024-04-15T06:46:11.261Z (7 months ago)
- Topics: canvas, experiment, javascript, tree-generator
- Language: JavaScript
- Homepage: https://aurbano.github.io/TreeGenerator/
- Size: 16.6 KB
- Stars: 27
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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](http://static.urbanoalvarez.es/blog/wp-content/uploads/2013/01/tree3.png)--------
Generating some trees on a canvas element:
```javascript
$(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:
```javascript
// 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](https://ga-beacon.appspot.com/UA-3181088-16/TreeGenerator/readme)](https://github.com/aurbano)