  #compact
  % Title "PineCone"
  % Animated
  % ScaleUp
 '% PlaceCentral
 '% AnchorCentral
 '% NoEscape
  % MultiSamples 4

  $filename "t.exe"
 'uses RTL64
  uses consoleG


  function makelist() as int
  ==========================

  type coor float x,y,z

  static coor z
  static float golden_angle = 137.508  
  static float golden       = golden_angle*Pi/180 
                                     
  macro floret(n, r,ang,xc,yc) 'inner procedure
  ----------------------------
  float r , ang , xc , yc
  r =(5.3 * Sqr(n*golden))
  ang = (n*golden)
  xc = r*Cos(ang)/100
  yc = r*Sin(ang)/100
  z.x=xc : z.y=yc 
  end macro    

  int i
  static int seeds
  seeds=CompileList seeds
  for i=1 to 140
    floret(i)
    glPushMatrix
    glTranslatef z.x , z.y , i/100
    scale 0.11+i/900
    go sphere
    glPopMatrix   
  next  
  for i=144 To 1 step -1
    floret(i)  
    glPushMatrix
    glTranslatef -z.x , -z.y , 2.2-i/200
    Scale  0.11+i/1000
    go sphere
    glPopMatrix   
  next
  glEndList
  return seeds
  end function


 function main()
  ===============
  int i,p
  string s
  float  a
  cls 0,0.1,0.2
  '
  shading
  '
  pushstate
  move 15,-15,-20
  static MoveableObject seeds
  static int            seedform
  static int            idf
  if opening
    idf=100  
    seeds.snap=.5
    seeds.id=idf
    seeds.mode=0x100 'keyboard & mouse (left button rotate)
    SeedForm=MakeList()
  end if
  picked=idf 'always selected
  seeds.act
  scale 10
  move 0,0,-1
 'static float ay
 'rotateY ay : ay+=.2
  if not pick then
    Material Silver
  end if
  go SeedForm
  'go cylinder
  popstate
  '
  'F1 HELP
  '
  if key[0x70]
    flat
    pushstate
    move 20,0
    color .9,.9,.9
    scale  1.5,1.0
    printl "Active Keys:"
    printl
    scale  1/1.5,1.0
    printl "Esc"    tab "Exit"
    printl "Ctrl-P" tab "Take snapshot"
    printl "F1 This help panel"
    printl "Arrow keys PgUp PgDn to move"
    printl "Ctrl Arrow keys PgUp PgDn to rotate"
    printl "+ - keys to scale up and scale down"
    printl "Ctrl Home to reset rotation"
    printl "Shift for faster movement"
    printl
    scale 1.5,1.0
    printl "Mouse:"
    printl		
    scale 1/1.5,1.0
    printl "Point to Object, then"
    printl "Left button to move"
    printl "Middle button to scale"
    printl "Right button to rotate"
    printl "Wheel to move in Z direction"
    popstate
  end if
  picklabel 0
  lastkey=0
  lastchar=0
  end function

  EndScript



             
