begin procedure generate-data
  define integer np 
  let np 50
  define real x[np,np] y[np,np] z[np,np]
  define real xc1 yc1 xc2 yc2 a1 a2 sig1 sig2
  let xc1 np*.3
  let yc1 np*.3
  let xc2 np*.7
  let yc2 np*.7
  let a1 1.
  let a2 .8
  let sig1 np/5.
  let sig2 np/7.
  define integer n
  let n 0
  !
  let x[i,j] i
  let y[i,j] j
  !
  let z       a1*exp(-(((x-xc1)^2+(y-yc1)^2))/2./sig1/sig1)
  let z     z+a2*exp(-(((x-xc2)^2+(y-yc2)^2))/2./sig2/sig2)
  ! let z[np,'0.1*np'] -1000.  ! A blank value
  g\rgdata x y z /blank -1000.
  del /var x y z n
  !
  g\levels 0. to 1. by 1./16.
end procedure generate-data
!
begin procedure plot-data
  g\limits /rg
  g\plot /blank -1000. 0. ! /scal lin 0. 1.
  ! g\box n n
  ! g\wedge
end procedure plot-data
!
begin procedure rgmap-data
  g\limits /rg
  g\rgmap quiet /grey /blank -1000. 0. ! /scal lin 0. 1.
  ! g\box n n
  ! g\wedge
end procedure rgmap-data
!
begin procedure draw-marker
  g\limits 0. 1. 8. 23.
  ! g\box
  for i 8 to 23
    g\pen /co i
    g\draw text .1 i 'i' /user
    !
    ! Simple line
    g\draw relo .25 i /user
    g\draw line .4 i /user
    !
    ! Marker filled polygon
    g\set marker 5 3 .5 0.
    g\draw marker .6 i /user
    !
    ! Marker vertex connected
    g\set marker 5 1 .5 0.
    g\draw marker .85 i /user
  next i
end procedure draw-marker
!
begin procedure display-data
  !
  let demo%xpos demo%xpos+demo%width+demo%inter
  !
  let demo%ypos demo%ystart
  g\set box_loc demo%xpos demo%xpos+demo%width demo%ypos demo%ypos+7.
  @ draw-marker
  !
  let demo%ypos demo%ypos+7.+demo%inter
  g\set box_loc demo%xpos demo%xpos+demo%width demo%ypos demo%ypos+demo%height
  @ rgmap-data
  !
  let demo%ypos demo%ypos+demo%height+demo%inter
  g\set box_loc demo%xpos demo%xpos+demo%width demo%ypos demo%ypos+demo%height
  @ plot-data
  !
end procedure display-data
!
begin procedure display-legend
  !
  let demo%xpos 1.
  !
  let demo%ypos demo%ystart
  g\set box_loc demo%xpos demo%xpos+demo%width demo%ypos demo%ypos+7.
  g\draw text .5 0. "DRAW TEXT, LINE, MARKER" 5 90. /box 4
  !
  let demo%ypos demo%ypos+7.+demo%inter
  g\set box_loc demo%xpos demo%xpos+demo%width demo%ypos demo%ypos+demo%height
  g\draw text .5 0. "RGMAP /GREY" 5 90. /box 4
  !
  let demo%ypos demo%ypos+demo%height+demo%inter
  g\set box_loc demo%xpos demo%xpos+demo%width demo%ypos demo%ypos+demo%height
  g\draw text .5 0. "PLOT" 5 90. /box 4
  !
  let demo%ypos demo%ystart
  g\set box_loc demo%xpos demo%xpos+demo%width demo%ypos demo%ypos+7.+demo%width
  g\axis yl /tick none /label none
  g\draw text -.5 0. "LUT /PEN" 5 90. /box 4
  !
  let demo%ypos demo%ypos+7.+demo%width+demo%inter
  g\set box_loc demo%xpos demo%xpos+demo%width demo%ypos demo%ypos+demo%height
  g\axis yl /tick none /label none
  g\draw text -.5 0. "LUT" 5 90. /box 4
  !
end procedure display-legend
!
begin procedure clean-demo
  delete /variable demo
  ! Reset
  g\change lut dynamic
  g\lut default
  g\clear
end procedure clean-demo

g\clear directory ! The current window
g\set /default
g\lut default

!-----------------------------------------------------------------------
! Load some dummy data
@ generate-data

!-----------------------------------------------------------------------

if exist(demo) delete /var demo
define structure demo /global
define real demo%width demo%height demo%inter /globa
let demo%inter 1.
let demo%width  6.
let demo%height 5.
define real demo%xstart demo%ystart demo%xpos demo%ypos /globa
let demo%xstart 2.
let demo%ystart 1.

g\change lut static

@ display-legend

let demo%xpos demo%xstart-demo%width-demo%inter

g\lut default
g\lut default /pen
@ display-data
g\pen /co 0
g\draw text 0. .2 "DEFAULT" /box 8

g\lut yellow
g\lut yellow /pen
@ display-data
g\pen /co 0
g\draw text 0. .2 "YELLOW" /box 8

g\lut mousse
g\lut mousse /pen
@ display-data
g\pen /co 0
g\draw text 0. .2 "MOUSSE" /box 8

g\lut rainbow1
g\lut rainbow1 /pen
@ display-data
g\pen /co 0
g\draw text 0. .2 "RAINBOW1" /box 8

pause "Type Continue to reset the LUTs"

@ clean-demo
