  % Title "Sphere Mapping Demo"
  % Animated
  % ScaleUp
 '% PlaceCentral
 '% AnchorCentral
  uses ConsoleG


  sub main()
  ==========
  static int   imgn,res,wi,ht
  static int   defmat,m
  static float angx,angy
  static float ma[13] 'for material
  static float amb,namb
  float f1,f2,f3
  int i,j
  if not defmat
    defmat=1
    amb=.0
    namb=1.0-amb
    ma[5]={amb,amb,amb,1.} 'ambient
  end if
  cls 0,.0,0
  pushstate
  move -2,3,-4.0
  shading
  for j=1 to 8
    pushstate
    move 0,-4*j
    m=1
    for i=1 to 8
      pushstate
      move 4.1*i
      scale 2
      rotateY angY
      f1=namb*j/8
      f2=namb-f1
      f3=m
      m+=m 'log scale 1 2 4 8 16 .. 256
      ma[1]={f1,f1,f1,1} 'diffuse
      ma[9]={f2,f2,f2,1} 'specular
      ma[13]=f3
      material ma
      go sphere
      popstate
    next
    popstate
  next
  popstate
  angx+=.100 : if angx>=360 then angx-=360
  angy+=.125 : if angy>=360 then angy-=360
  end sub 'main

  EndScript