32 lines
872 B
Text
32 lines
872 B
Text
/*
|
|
Execute with:
|
|
|
|
$ hopper jm/tree.jambo -x -o bin/tree
|
|
$ rxvt -g 280x250 -fn "xft:FantasqueSansMono-Regular:pixelsize=1" -e ./bin/tree
|
|
|
|
*/
|
|
|
|
#include <jambo.h>
|
|
|
|
Main
|
|
Set '25, 0.76, 160, 100, 10' Init 'Spread, Scale, SizeX, SizeY, Depth'
|
|
Color back '22', Cls
|
|
Color back '15'
|
|
Set '{SizeX} Mul by (2), -30, Div(SizeY,2), 90, Depth' Gosub 'Branch'
|
|
Pause
|
|
End
|
|
|
|
Subrutines
|
|
|
|
Define 'Branch, x1, y1, size, angle, depth'
|
|
x2=0, y2=0
|
|
Let ( x2 := #(x1 + size * cos(d2r(angle))) )
|
|
Let ( y2 := #(y1 + size * sin(d2r(angle))) )
|
|
Draw a line ( #(180-y1), #(180-x1), #(180-y2), #(180-x2))
|
|
If ( #( depth > 0) )
|
|
Set (x2, y2, {size} Mul by 'Scale', {angle} Minus 'Spread',\
|
|
Minus one(depth)) Gosub 'Branch'
|
|
Set (x2, y2, {size} Mul by 'Scale', {angle} Plus 'Spread',\
|
|
Minus one(depth)) Gosub 'Branch'
|
|
End If
|
|
Return
|