# Draw a tree at s1,s2 with height s3
# Script by pv (23/10/08)

if s1=0 then assign s1 50
if s2=0 then assign s2 30
if s3=0 then assign s3 80

assign wd 8
assign lx lastx
assign ly lasty

# Draw trunk and position pointer at top of tree
colour brown
rectangle fill s1 s2 wd s3
assign s1 lastx
assign s2 lasty
inc s2 wd
half wd
dec s1 wd

# step size for branches to 'grow' down trunk
if s4=0 then assign s4 4

# step size for branches to move down trunk
if s5=0 then assign s5 -6

# step sizes for branches to grow outwards
if s6=0 then assign s6 3

# number of branches
if s7=0 then assign s7 8

loop a s7
  colour green
  triangle fill s1 s2 0 s5 s6 0
  triangle fill s1 s2 0 s5 -s6 0
  dec s2 s4
  inc s4
  inc s6 6
  dec s5 2
endloop a

# restore graphic coordinate to before command
move lx ly
