Step 1: Create Branches

[img]https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjykaX-y-YZh5qXY2yjW2ym6otUpTki_tzamXcCtTf5PncS9cAelxfabNVzyF90yxlIqT2IfLmDV_haDJeTVXLPXuunZjFGy8Fwffbdk4RVv_V3kx6QoJy2K0J-R2jtjHem3h5xiEvOy77kRORF_u1WUy-c9jaCCsN_Uz5ptth6XYiv2Hw/s1600/trees-ggb.gif[/img][br][br][size=150]To create these amazing trees we can use [url=https://en.wikipedia.org/wiki/Recursion]recursion[/url]. [br][br]First we need to define the branches of our tree.[/size]
Scripting
f = Segment((0, 0), (0, 2))[br][br]A = Point(f, 0)[br]B = Point(f, 1)[br][br]C = Dilate(Rotate(A, π + random( ) * π / 4, B), 0.5 + 0.5 * random(), B)[br]D = Dilate(Rotate(A, π - random( ) * π / 4, B), 0.5 + 0.5 * random(), B)[br]E = Dilate(Rotate(A, π + π/8 + random( ) * π / 4, B), 0.5 + 0.5 * random(), B)[br][br]ListOutPut = {Segment(B, C), Segment(B, D), If(random() > 0.7, Segment(B, E), Segment(B, B))}
Step 1: Demo

Information