rep_str2bin_struct
No arguments
Description:
Create a binary tree image from a control string as interpreted by BinArbor coding language
(Also made by Reptorian.).
Control characters:
^ = Move to parent node.
< = Create left child if needed, then move to it.
> = Create right child if needed, then move to it.
: = Create missing left/right children without moving.
. = Move to a random branch of current node. If the node has no children, create
one on a random side first, before moving into a branch. If it has only one branch, then move to that branch.
~ = Move to sibling branch. Creates sibling if missing.
* = Move to current subtree root.*
+ = Move upward along same branch direction.
- = Move downward along same branch direction.
% = Mirror a branch across a mirror point (left/right swapped at
every level). If the current node has exactly one child, that
child's branch is mirrored onto the empty side of the current
node.
& = Clone a branch onto the empty side of the current node
(same as %, but without swapping left/right). Does nothing
unless the node has exactly one child.
*A subtree root is the node where the current local branch context began.
Random leaf navigation:
( = Move to random node missing a left child.
) = Move to random node missing a right child.
| = Move to random node missing either child.
Expressions and local branching:
{...} = Evaluate expression and store result in node.
[...] = Evaluate inside local subtree context.
Variables:
name = Assign current node to variable name.*
@name = Move to variable node.
Cannot begin with _ or a number!
Repeat loops:
N{...} = Repeat enclosed block N times.
N... = Repeat next section until ''.
Expression Functions:
dir() = Return current branch direction.
Error at subtree root.
root() = Return value of current subtree root.
Error at subtree root.
L() = Return value of left child.
Error if no left child exists.
R() = Return value of right child.
Error if no right child exists.
sibling() = Return value of the sibling node.
Error at subtree root or if no sibling exists.
depth() = Return depth of the current node relative to the
current subtree root (0 at the root).
isleaf() = Return 1 if the current node has no children,
otherwise 0. Only reflects the tree built so far.
For this implementation, all G'MIC JIT expressions are supported.
Ignored characters:
space, newline, /
Output Binary tree node layout:
0 = parent index*
1 = left child index
2 = right child index
3 = depth level
4+ = stored values (if vector_size > 0)
*For the very first pixel at the top, parent index is actually maximum depth level
Example:
<>~:
Produces:
o
/
o
/
o o
/
o o
Author: Reptorian.