Recursive Tree Animation

john's Avatar


04 Sep, 2018 02:56 AM

This realistic, leafy, swaying 3D tree is actually a VERY simple 2D recursive tree graph. I came across the formula in a recent book by David Auerbach, Bitwise. Translated from Logo the algorithm goes something like this:

define tree ( level, size, scale, angle):
   if level > 0:
      draw left branch
      tree (level-2, size*scale, scale, angle)
      draw right branch
      tree (level-1, size*scale, scale, angle)
   end if
end tree

Sadly, NodeBox doesn't do recursion. But you can come close by making a subnetwork that can take itself as an input and string together as many as you need to reach a desired recursion depth. After seven levels (over 8700 line segments) NodeBox starts to bog down, but that is enough for a nice rendering. Add a little color, attach a frame and wave node to the angle parameter, and you have a beautiful bouncing baby tree.

Screenshot, zipped NodeBox file, and animated GIF attached. Enjoy!


  1. Support Staff 1 Posted by Frederik De Ble... on 10 Sep, 2018 07:13 PM

    Frederik De Bleser's Avatar

    Very cool! I often use L-systems for this type of animations.

    The ultimate book about this is "The Algorithmic Beauty of Plants" (PDF) by Aristid Lindenmayer himself. My colleague Stefan translated these algorithms to NodeBox Live — I'll ask him for a link.

  2. Support Staff 2 Posted by john on 10 Sep, 2018 10:34 PM

    john's Avatar


    Thanks for the book reference - this looks *very* interesting. I look forward to getting Stefan's link.

    There has been some discussion about L-systems before in the NodeBox forum. In fact you created a GitHub issue to track it back in 2013:

    But my understanding is that NodeBox 3 still does not play well with L-systems due its lack of recursion and state. So when you say you often use L-systems for this type of animation, did you mean using Stefan's NodeBox Live code? Or some other tool?

    As you know, I would very much like to see support for L-systems, fractals, and recursion in general within NodeBox 3. I gather you had something in Nodebox 2. Any chance of porting it to 3?



  3. Support Staff 3 Posted by Stefan Gabriels on 11 Sep, 2018 08:23 AM

    Stefan Gabriels's Avatar

    The L-systems demo of NodeBox Live lives here:

    But the recursion happens within the LSystem code/node itself and not on the network level. This is something we can't do yet. In NodeBox Live we have a stateLoad and stateSave node though and with those we can reuse the output of nodes between animation frames. For example this way we can implement something like a counter in a recursive way, but this only works when using it with successive frames.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • tree_screenshot.png 1.45 MB
  • 3.97 KB
  • tree.gif 2.22 MB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

16 Jun, 2022 05:30 AM
15 Jun, 2022 06:03 AM
06 Jun, 2022 01:07 PM
02 Jun, 2022 11:58 PM
30 May, 2022 07:48 AM


24 May, 2022 06:27 PM
20 May, 2022 04:12 PM
05 May, 2022 02:25 AM
03 May, 2022 04:46 AM
01 May, 2022 09:22 AM
18 Apr, 2022 09:01 PM