  % Title "Stacked Graph Demo (press 0..9 to highlight data layer)"
 '% Animated
  % ScaleUp
 '% PlaceCentral
 '% AnchorCentral
  uses Chaos
  uses glo2\GraphUtil


  sub main
  ========
  static sys   imgn,res,wi,ht
  static float fg=0.1
  cls 0,0,0

  pushstate 'FOR GRAPH SCALE
  '
  static MoveableObject gr
  if not gr.id
    gr.mode=0x111
    gr.snap=.1
    gr.set 100, 0, 5, -16, 0
  end if
  gr.act
  TouchZone
  'color 0,.8,.8,1
  linescale 20.0, 1.0,  .3, 5  'X AXIS
  glRotatef  90,0,1,0
  linescale 20.0, 1.0,  .3, 5  'Z AXIS
  glRotatef -90,0,1,0
  glRotatef  90,0,0,1
  linescale  10.0, 1.0, -.3, 5 'Y AXIS
  glRotatef -90,0,0,1
  '
  'GRIDS
  thickness 1
  color      0,.8,.8,1.
  glRotatef -90,1,0,0
  grid       1,20,20 'FLOOR GRID
  glRotatef  90,1,0,0
  '
  glRotatef  90,0,1,0
  grid       1,20,10 'SIDE GRID
  glRotatef -90,0,1,0
  '
  'X AXIS VALUES
  color .5,1
  pushstate
  move 0,-1.5
  numscale 0,0,10,0,  0,10,2,1,  3 'X NUMBERS
  glRotatef  90,0,1,0
  numscale 0,0,10,0,  0,10,2,1,  3 'Z NUMBERS
  glRotatef -90,0,1,0
  '
  popstate
  'Y AXIS VALUES
  color .99,.50
  pushstate
  move -3
  numscale 0,0,0,5,  0,500,3,0,  3 'Y NUMBERS
  popstate

    color .2,.3,.6
    QuadTex 1000,1000,-100 'BACK PLATE
    '
  'PLOTS
    flat 'shading
    'DEMO DATA
    sys   c,i
    float a,x,y,z,s
    'seed=123456789
    c=lastChar - 48
    for i=10 to 0 step-1
      'a=1.0-i*.09
      a=.5 'alpha
      if i=c then a=1.0
      PushState
      move 0,0,-i*2
      float d={1,1+i, 3,2+i, 5,3+i, 7,4+i, 9,5+i}
      if i=c then
        color .9,.9,.9,a  : VertBarPlot  5,d, 1.0
      else
        color .9,.5,.0,a  : VertBarPlot  5,d, 1.0
      end if
      PopState
    next
    flat

    '
    PushState
    for i=10 to 0 step-1
      'color .3,.4,.8,.1 'TRANSPARENT HAZE LAYERS
      'QuadTex 100,100,-i*2.0 -.5
    next
    '
    PopState
  '
  popstate 'WHOLE GRAPH
  '
  'TITLE
  pushstate
  static MoveableObject title
  if not title.id
    title.mode=0x111
    title.snap=.1
    title.set 200, 0, 2, -3, 0
  end if
  title.act 
  TouchZone .5
  scale 2
  printl "3D Graphs"
  popstate
  end sub 'main

  EndScript