Adam Harte
Adam Harte

Reputation: 10510

Generating random tree branch

I want to generate (an image of) a single branch of a tree (the "woody plant" kind). Maybe similar to this branch, or this one.

I need it to be interesting but simple, so just one branch, with a few turns, and only a few splits (where it changes from one limb into two). It should start with one fat branch and split off into a few thin branches. I am not worried about leaves, as I am thinking that leaves are quite a separate issue, so can be handled later.

Where should I start? What is involved in this?

Thanks

Upvotes: 1

Views: 1854

Answers (1)

jtbandes
jtbandes

Reputation: 118681

Absolutely the best/easiest way to go is Context Free fractal image generator.

Here's something to get you started (hit Render until you like it):

tree

startshape TREE

rule TREE {
    BRANCH {}
}

rule BRANCH {
    NEXT {r -1}
}
rule BRANCH {
    NEXT {r 1}
}
rule BRANCH .01 {
    NEXT {r 45}
}
rule BRANCH .01 {
    NEXT {r -45}
}
rule BRANCH .01 {
    NEXT {r 30}
    NEXT {r -30}
}

rule NEXT {
    CIRCLE {}
    BRANCH {y .3 s .996}
}

Upvotes: 3

Related Questions