---input---
############################################################################
#
#       File:     kaleid.icn
#
#       Subject:  Program to produce kaleidoscope
#
#       Author:   Stephen B. Wampler
#
#       Date:     May 2, 2001
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#    Lots of options, most easily set by with the interface after
#    startup.  The only one that isn't set that way is -wn where 'n' is
#    the size of the kaleidoscope window (default is 600 square).
#
#    Terminology (and options):
#
#       Window_size (-wN): How big of a display window to use.
#           At the current time, this can only be set via a
#           command line argument.
#
#       Density (-dN): How many circles per octant to keep on display
#           at any one time.  There is NO LIMIT to the density.
#
#       Duration (-lN): How long to keep drawing circles (measured in
#           in circles) once the density is reached.  There is NO LIMIT
#           to the duration.
#
#       MaxRadius (-MN): Maximum radius of any circle.
#
#       MinRadius (-mN): Preferred minimum radius.  Circles with centers
#           near the edge have their radii forced down to fit entirely
#           on the display
#
#       MaxOffset (-XN): Maximum offset from center of display (may wrap).
#
#       MinOffset (-xN): Minimum offset
#
#       Skew (-sN): Shift probability of placing a circle at a 'typical'
#           offset.
#
#       Fill (-F): Turns off filling the circles.
#
#       Clear (-C): After the duration, reduces density back to 0 before
#           quitting.
#
#       Random Seed: (-rN): Sets the random number seed.
#
# Thanks to Jon Lipp for help on using vidgets, and to Mary Camaron
#   for her Interface Builder.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################
#
#  Links:  vidgets, vslider, vtext, vbuttons, vradio, wopen, xcompat
#
############################################################################

link vidgets
link vslider
link vtext
link vbuttons
link vradio
link wopen
link xcompat

global Clear, fill, duration, density, maxoff, minoff
global maxradius, minradius, r_seed, skew, win_size, mid_win
global root, check1, mainwin, use_dialog
global draw_circle

global du_v, de_v, rs_v, sk_v

procedure main (args)

   draw_circle := DrawCircle

   init_globs()
   process_args(args)

   if \use_dialog then {        # have vidgets, so use them for args.
      mainwin := WOpen("label=Kaleidoscope", "width=404", "height=313", 
                       "font=6x12") |
                 stop ("bad mainwin")
      root := ui (mainwin)
      GetEvents (root, quit)
      }
   else {                       # just rely on command line arguments
      kaleidoscope(r_seed)
      }

end

procedure init_globs()

   duration := 500                    # set default characteristics
   density := 30
   win_size := 600
   minoff := 1
   maxradius := 150
   minradius := 1
   skew := 1
   fill := "On"
   draw_circle := FillCircle
   Clear := "Off"
   r_seed := map("HhMmYy", "Hh:Mm:Yy", &clock)
   # See if the Vidget library is available or not
   if \VSet then use_dialog := "yes"
            else use_dialog := &null

end

procedure process_args(args)
   local arg

   # really only needed if you don't use the dialog box
   every arg := !args do case arg[1+:2] of {
      "-w" : win_size := integer(arg[3:0])       # window size
      "-d" : density := integer(arg[3:0])        # density of circles
      "-l" : duration := integer(arg[3:0])       # duration
      "-M" : maxradius := integer(arg[3:0])      # maximum radius
      "-m" : minradius := integer(arg[3:0])      # minimum radius
      "-X" : maxoff := integer(arg[3:0])         # maximum offset
      "-x" : minoff := integer(arg[3:0])         # minimum offset
      "-s" : skew := numeric(arg[3:0])           # set skewedness
      "-F" : fill := &null                       # turn off fill
      "-C" : Clear := "yes"                      # turn on clear mode
      "-r" : r_seed := integer(arg[3:0])         # random seed
      "-h" : stop("usage: kal [-wn] [-dn] [-ln] [-Mn] [-mn] [-Xn] [-xn] _
                     [-sn] [-F] [-C] [-rn]")
      }
   # adjust parameters that depend on the window size...
   mid_win := win_size/2
   maxoff := win_size-1
end

# Lorraine Callahan's kaleidoscope program, translated into icon.
#  (some of the things she did were too sophisticated for me
#   to spend time to figure out, so the output is square instead of
#   round), and I use 'xor' to draw instead of writing to separate
#   bit planes.

global putcircle, clrcircle

procedure kaleidoscope(r)
   local colors

   # What colors to use?  This can be changed to whatever!
   colors := ["red","green","blue","cyan","magenta","yellow"]

   &window := WOpen("label=Kaleidoscope: 'q' quits", "width="||win_size,
                                  "height="||win_size, "bg=black")
   WAttrib("drawop=xor")

   # Create two *indentical* sequences of circles, one to use when
   #   when drawing, one for erasing.  (Since 'xor' is used to
   #   place them, these both just draw the circles!)

   putcircle := create {                # draws sequence of circles
      &random :=: r
      |{
       Fg(?colors)
       outcircle()
       &random <-> r
       }
      }

   clrcircle := create {                # erases sequence of circles
      &random :=: r
      |{
       Fg(?colors)
       outcircle()
       &random <-> r
       }
      }

   every 1 to density do @putcircle     # fill screen to density

   every 1 to duration do {             # maintain steady state
      @putcircle
      @clrcircle
      if *Pending(&window) > 0 then break
      }

   every (Clear == "On") & 1 to density do @clrcircle

   close(&window)
end


procedure outcircle()                   # select a circle at random,
local radius, xoff, yoff                #  draw it in kaleidoscopic form

        # get a random center point and radius
   xoff := (?(maxoff - minoff) + minoff) % mid_win
   yoff := (?(maxoff - minoff) + minoff) % mid_win
   radius := ?0 ^ skew
        # force radius to 'fit'
   radius := ((maxradius-minradius) * radius + minradius) %
             (mid_win - ((xoff < yoff)|xoff))

        # put into all 8 octants
   draw_circle(mid_win+xoff, mid_win+yoff, radius)
   draw_circle(mid_win+xoff, mid_win-yoff, radius)
   draw_circle(mid_win-xoff, mid_win+yoff, radius)
   draw_circle(mid_win-xoff, mid_win-yoff, radius)

   draw_circle(mid_win+yoff, mid_win+xoff, radius)
   draw_circle(mid_win+yoff, mid_win-xoff, radius)
   draw_circle(mid_win-yoff, mid_win+xoff, radius)
   draw_circle(mid_win-yoff, mid_win-xoff, radius)

   return
end


############################################################################
#
#   Vidget-based user interface -- developed originally using Mary
#       Camaron's XIB program.  Don't expect this to be very readable -
#       you should have to play with it!
#
############################################################################
procedure ui (win)
   local cv1, cv2, cv3, cv4
   local 
         radio_button2, 
         radio_button1, 
         text_input6, 
         text_input5, 
         slider4, 
         slider3, 
         text_input4, 
         text_input3, 
         slider2, 
         slider1 

   /win := WOpen("label=ui", "width=404", "height=313", "font=6x12") | 
           stop ("bad win")
   root := Vroot_frame (win)

   VInsert (root, Vmessage(win, win_size/2), 168, 98)
   VInsert (root, Vmessage(win, "1"), 108, 97)

   VInsert (root, sk_v := Vtext(win,"Skew:\\=1",get_skew,,6), 280, 39)

   VInsert (root, du_v := Vtext(win, "Duration:\\="||duration, get_duration,,9),
                237, 15)

   VInsert (root, Vmessage(win, "Clear at end?"), 232, 145)
   VInsert (root, Vmessage(win, "Fill?"), 105, 142)
   VInsert (root, Vmessage(win,"Quit?"), 267, 259)
   VInsert (root, Vmessage(win,"Display it?"), 26, 260)

   VInsert (root, Vcheckbox(win, do_quit, "check2",20), 305, 255, 20, 20)

   VInsert (root, check1:=Vcheckbox(win, do_display, "check1",20),
                106, 258, 20, 20)

   radio_button2 := Vradio_buttons (win, ["On", "Off"], get_clear, , V_CIRCLE)
   VSet(radio_button2,Clear)
   VInsert (root, radio_button2, 253, 165)

   radio_button1 := Vradio_buttons (win, ["On", "Off"], get_fill, , V_CIRCLE)
   VSet(radio_button1,fill)
   VInsert (root, radio_button1, 99, 165)

   cv1 := Vcoupler()
   VAddClient(cv1, get_max_offset)
   text_input6 := Vtext (win, "Max Offset:\\="||(win_size-1), cv1, , 3)
   VAddClient(cv1, text_input6)
   slider4 := Vhoriz_slider (win, cv1, "slider4", 70, 12, 0,
                         win_size-1, win_size-1, )
   VAddClient(cv1, slider4)
   VInsert (root, text_input6, 196, 103)
   VInsert (root, slider4, 306, 106)

   cv2 := Vcoupler()
   VAddClient(cv2, get_min_offset)
   text_input5 := Vtext (win, "Min Offset\\=1", cv2, , 3)
   VAddClient(cv2, text_input5)
   slider3 := Vhoriz_slider (win, cv2, "slider3", 70, 12, 1, win_size-1, 1, )
   VAddClient(cv2, slider3)
   VInsert (root, text_input5, 201, 80)
   VInsert (root, slider3, 307, 82)

   cv3 := Vcoupler()
   VAddClient(cv3, get_max_radius)
   text_input4 := Vtext (win, "Max Radius\\="||(win_size/4), cv3, , 3)
   VAddClient(cv3, text_input4)
   slider2 := Vhoriz_slider (win, cv3, "slider2", 70, 12, 1, win_size/2,
         win_size/4, )
   VAddClient(cv3, slider2)
   VInsert (root, text_input4, 10, 104)
   VInsert (root, slider2, 110, 108)

   cv4 := Vcoupler()
   VAddClient(cv4, get_min_radius)
   text_input3 := Vtext (win, "Min Radius\\=1", cv4, , 3)
   VAddClient(cv4, text_input3)
   slider1 := Vhoriz_slider (win, cv4, "slider1", 70, 12, 1, win_size/2, 1, )
   VAddClient(cv4, slider1)
   VInsert (root, text_input3, 10, 81)
   VInsert (root, slider1, 110, 84)

   VInsert (root, rs_v := Vtext(win,"Random Seed:\\="||r_seed, get_random,, 11),
              30, 41)
   VInsert (root, de_v := Vtext(win,"Density:\\="||density, get_density,,8),
              71, 16)

   VResize (root)
   return root
end

procedure get_skew (wit, value)
   skew := value
end

procedure get_duration (wit, value)
   duration := value
end

procedure do_quit (wit, value)
   stop()
end

procedure do_display (wit, value)
   r_seed   := numeric(rs_v.data)
   duration := integer(du_v.data)
   density  := integer(de_v.data)
   skew     := integer(sk_v.data)
   kaleidoscope(r_seed)
   wit.callback.value := &null
   VDraw(check1)
end

procedure get_clear (wit, value)
   Clear := value
end

procedure get_fill (wit, value)
   fill := value
   if fill == "Off" then draw_circle := DrawCircle
   else draw_circle := FillCircle
end

procedure get_max_offset (wit, value)
   maxoff := value
end

procedure get_min_offset (wit, value)
   minoff := value
end

procedure get_max_radius (wit, value)
   maxradius := value
end

procedure get_min_radius (wit, value)
   minradius := value
end

procedure get_random (wit, value)
   r_seed := integer(value)
end

procedure get_density (wit, value)
   density := integer(value)
end

procedure quit(e)
   if e === "q" then stop ("Exiting Kaleidoscope")
end

---tokens---
'############################################################################\n' Comment.Single

'#\n'         Comment.Single

'#       File:     kaleid.icn\n' Comment.Single

'#\n'         Comment.Single

'#       Subject:  Program to produce kaleidoscope\n' Comment.Single

'#\n'         Comment.Single

'#       Author:   Stephen B. Wampler\n' Comment.Single

'#\n'         Comment.Single

'#       Date:     May 2, 2001\n' Comment.Single

'#\n'         Comment.Single

'############################################################################\n' Comment.Single

'#\n'         Comment.Single

'#   This file is in the public domain.\n' Comment.Single

'#\n'         Comment.Single

'############################################################################\n' Comment.Single

'#\n'         Comment.Single

'#    Lots of options, most easily set by with the interface after\n' Comment.Single

"#    startup.  The only one that isn't set that way is -wn where 'n' is\n" Comment.Single

'#    the size of the kaleidoscope window (default is 600 square).\n' Comment.Single

'#\n'         Comment.Single

'#    Terminology (and options):\n' Comment.Single

'#\n'         Comment.Single

'#       Window_size (-wN): How big of a display window to use.\n' Comment.Single

'#           At the current time, this can only be set via a\n' Comment.Single

'#           command line argument.\n' Comment.Single

'#\n'         Comment.Single

'#       Density (-dN): How many circles per octant to keep on display\n' Comment.Single

'#           at any one time.  There is NO LIMIT to the density.\n' Comment.Single

'#\n'         Comment.Single

'#       Duration (-lN): How long to keep drawing circles (measured in\n' Comment.Single

'#           in circles) once the density is reached.  There is NO LIMIT\n' Comment.Single

'#           to the duration.\n' Comment.Single

'#\n'         Comment.Single

'#       MaxRadius (-MN): Maximum radius of any circle.\n' Comment.Single

'#\n'         Comment.Single

'#       MinRadius (-mN): Preferred minimum radius.  Circles with centers\n' Comment.Single

'#           near the edge have their radii forced down to fit entirely\n' Comment.Single

'#           on the display\n' Comment.Single

'#\n'         Comment.Single

'#       MaxOffset (-XN): Maximum offset from center of display (may wrap).\n' Comment.Single

'#\n'         Comment.Single

'#       MinOffset (-xN): Minimum offset\n' Comment.Single

'#\n'         Comment.Single

"#       Skew (-sN): Shift probability of placing a circle at a 'typical'\n" Comment.Single

'#           offset.\n' Comment.Single

'#\n'         Comment.Single

'#       Fill (-F): Turns off filling the circles.\n' Comment.Single

'#\n'         Comment.Single

'#       Clear (-C): After the duration, reduces density back to 0 before\n' Comment.Single

'#           quitting.\n' Comment.Single

'#\n'         Comment.Single

'#       Random Seed: (-rN): Sets the random number seed.\n' Comment.Single

'#\n'         Comment.Single

'# Thanks to Jon Lipp for help on using vidgets, and to Mary Camaron\n' Comment.Single

'#   for her Interface Builder.\n' Comment.Single

'#\n'         Comment.Single

'############################################################################\n' Comment.Single

'#\n'         Comment.Single

'#  Requires:  Version 9 graphics\n' Comment.Single

'#\n'         Comment.Single

'############################################################################\n' Comment.Single

'#\n'         Comment.Single

'#  Links:  vidgets, vslider, vtext, vbuttons, vradio, wopen, xcompat\n' Comment.Single

'#\n'         Comment.Single

'############################################################################\n' Comment.Single

'\n'          Text

'link'        Keyword.Declaration
' '           Text
'vidgets'     Name
'\n'          Text

'link'        Keyword.Declaration
' '           Text
'vslider'     Name
'\n'          Text

'link'        Keyword.Declaration
' '           Text
'vtext'       Name
'\n'          Text

'link'        Keyword.Declaration
' '           Text
'vbuttons'    Name
'\n'          Text

'link'        Keyword.Declaration
' '           Text
'vradio'      Name
'\n'          Text

'link'        Keyword.Declaration
' '           Text
'wopen'       Name
'\n'          Text

'link'        Keyword.Declaration
' '           Text
'xcompat'     Name
'\n\n'        Text

'global'      Keyword.Reserved
' '           Text
'Clear'       Name
','           Punctuation
' '           Text
'fill'        Name
','           Punctuation
' '           Text
'duration'    Name
','           Punctuation
' '           Text
'density'     Name
','           Punctuation
' '           Text
'maxoff'      Name
','           Punctuation
' '           Text
'minoff'      Name
'\n'          Text

'global'      Keyword.Reserved
' '           Text
'maxradius'   Name
','           Punctuation
' '           Text
'minradius'   Name
','           Punctuation
' '           Text
'r_seed'      Name
','           Punctuation
' '           Text
'skew'        Name
','           Punctuation
' '           Text
'win_size'    Name
','           Punctuation
' '           Text
'mid_win'     Name
'\n'          Text

'global'      Keyword.Reserved
' '           Text
'root'        Name
','           Punctuation
' '           Text
'check1'      Name
','           Punctuation
' '           Text
'mainwin'     Name
','           Punctuation
' '           Text
'use_dialog'  Name
'\n'          Text

'global'      Keyword.Reserved
' '           Text
'draw_circle' Name
'\n\n'        Text

'global'      Keyword.Reserved
' '           Text
'du_v'        Name
','           Punctuation
' '           Text
'de_v'        Name
','           Punctuation
' '           Text
'rs_v'        Name
','           Punctuation
' '           Text
'sk_v'        Name
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'main'        Name.Function
' '           Text
'('           Punctuation
'args'        Name.Variable
')'           Punctuation
'\n\n'        Text

'   '         Text
'draw_circle' Name
' '           Text
':='          Operator
' '           Text
'DrawCircle'  Name.Function
'\n\n'        Text

'   '         Text
'init_globs'  Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'   '         Text
'process_args' Name
'('           Punctuation
'args'        Name.Function
')'           Punctuation
'\n\n'        Text

'   '         Text
'if'          Keyword.Reserved
' '           Text
'\\'          Operator
'use_dialog'  Name
' '           Text
'then'        Keyword.Reserved
' '           Text
'{'           Punctuation
'        '    Text
'# have vidgets, so use them for args.\n' Comment.Single

'      '      Text
'mainwin'     Name
' '           Text
':='          Operator
' '           Text
'WOpen'       Name
'('           Punctuation
'"label=Kaleidoscope"' Literal.String
','           Punctuation
' '           Text
'"width=404"' Literal.String
','           Punctuation
' '           Text
'"height=313"' Literal.String
','           Punctuation
' '           Text
'\n'          Text

'                       ' Text
'"font=6x12"' Literal.String
')'           Punctuation
' '           Text
'|'           Operator
'\n'          Text

'                 ' Text
'stop'        Name.Function
' '           Text
'('           Punctuation
'"bad mainwin"' Literal.String
')'           Punctuation
'\n'          Text

'      '      Text
'root'        Name
' '           Text
':='          Operator
' '           Text
'ui'          Name
' '           Text
'('           Punctuation
'mainwin'     Name
')'           Punctuation
'\n'          Text

'      '      Text
'GetEvents'   Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'quit'        Name
')'           Punctuation
'\n'          Text

'      '      Text
'}'           Punctuation
'\n'          Text

'   '         Text
'else'        Keyword.Reserved
' '           Text
'{'           Punctuation
'                       ' Text
'# just rely on command line arguments\n' Comment.Single

'      '      Text
'kaleidoscope' Name
'('           Punctuation
'r_seed'      Name
')'           Punctuation
'\n'          Text

'      '      Text
'}'           Punctuation
'\n\n'        Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'init_globs'  Name.Function
'('           Punctuation
')'           Punctuation
'\n\n'        Text

'   '         Text
'duration'    Name
' '           Text
':='          Operator
' '           Text
'500'         Literal.Number.Integer
'                    ' Text
'# set default characteristics\n' Comment.Single

'   '         Text
'density'     Name
' '           Text
':='          Operator
' '           Text
'30'          Literal.Number.Integer
'\n'          Text

'   '         Text
'win_size'    Name
' '           Text
':='          Operator
' '           Text
'600'         Literal.Number.Integer
'\n'          Text

'   '         Text
'minoff'      Name
' '           Text
':='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'   '         Text
'maxradius'   Name
' '           Text
':='          Operator
' '           Text
'150'         Literal.Number.Integer
'\n'          Text

'   '         Text
'minradius'   Name
' '           Text
':='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'   '         Text
'skew'        Name
' '           Text
':='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'   '         Text
'fill'        Name
' '           Text
':='          Operator
' '           Text
'"On"'        Literal.String
'\n'          Text

'   '         Text
'draw_circle' Name
' '           Text
':='          Operator
' '           Text
'FillCircle'  Name.Function
'\n'          Text

'   '         Text
'Clear'       Name
' '           Text
':='          Operator
' '           Text
'"Off"'       Literal.String
'\n'          Text

'   '         Text
'r_seed'      Name
' '           Text
':='          Operator
' '           Text
'map'         Name.Function
'('           Punctuation
'"HhMmYy"'    Literal.String
','           Punctuation
' '           Text
'"Hh:Mm:Yy"'  Literal.String
','           Punctuation
' '           Text
'&clock'      Keyword.Reserved
')'           Punctuation
'\n'          Text

'   '         Text
'# See if the Vidget library is available or not\n' Comment.Single

'   '         Text
'if'          Keyword.Reserved
' '           Text
'\\'          Operator
'VSet'        Name
' '           Text
'then'        Keyword.Reserved
' '           Text
'use_dialog'  Name
' '           Text
':='          Operator
' '           Text
'"yes"'       Literal.String
'\n'          Text

'            ' Text
'else'        Keyword.Reserved
' '           Text
'use_dialog'  Name
' '           Text
':='          Operator
' '           Text
'&null'       Keyword.Constant
'\n\n'        Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'process_args' Name.Function
'('           Punctuation
'args'        Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'local'       Keyword.Reserved
' '           Text
'arg'         Name
'\n\n'        Text

'   '         Text
"# really only needed if you don't use the dialog box\n" Comment.Single

'   '         Text
'every'       Keyword.Reserved
' '           Text
'arg'         Name
' '           Text
':='          Operator
' '           Text
'!'           Operator
'args'        Name.Function
' '           Text
'do'          Keyword.Reserved
' '           Text
'case'        Keyword.Reserved
' '           Text
'arg'         Name
'['           Punctuation
'1'           Literal.Number.Integer
'+'           Operator
':'           Punctuation
'2'           Literal.Number.Integer
']'           Punctuation
' '           Text
'of'          Keyword.Reserved
' '           Text
'{'           Punctuation
'\n'          Text

'      '      Text
'"-w"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'win_size'    Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'arg'         Name
'['           Punctuation
'3'           Literal.Number.Integer
':'           Punctuation
'0'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'       '     Text
'# window size\n' Comment.Single

'      '      Text
'"-d"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'density'     Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'arg'         Name
'['           Punctuation
'3'           Literal.Number.Integer
':'           Punctuation
'0'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'        '    Text
'# density of circles\n' Comment.Single

'      '      Text
'"-l"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'duration'    Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'arg'         Name
'['           Punctuation
'3'           Literal.Number.Integer
':'           Punctuation
'0'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'       '     Text
'# duration\n' Comment.Single

'      '      Text
'"-M"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'maxradius'   Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'arg'         Name
'['           Punctuation
'3'           Literal.Number.Integer
':'           Punctuation
'0'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'      '      Text
'# maximum radius\n' Comment.Single

'      '      Text
'"-m"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'minradius'   Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'arg'         Name
'['           Punctuation
'3'           Literal.Number.Integer
':'           Punctuation
'0'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'      '      Text
'# minimum radius\n' Comment.Single

'      '      Text
'"-X"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'maxoff'      Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'arg'         Name
'['           Punctuation
'3'           Literal.Number.Integer
':'           Punctuation
'0'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'         '   Text
'# maximum offset\n' Comment.Single

'      '      Text
'"-x"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'minoff'      Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'arg'         Name
'['           Punctuation
'3'           Literal.Number.Integer
':'           Punctuation
'0'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'         '   Text
'# minimum offset\n' Comment.Single

'      '      Text
'"-s"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'skew'        Name
' '           Text
':='          Operator
' '           Text
'numeric'     Name.Function
'('           Punctuation
'arg'         Name
'['           Punctuation
'3'           Literal.Number.Integer
':'           Punctuation
'0'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'           ' Text
'# set skewedness\n' Comment.Single

'      '      Text
'"-F"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'fill'        Name
' '           Text
':='          Operator
' '           Text
'&null'       Keyword.Constant
'                       ' Text
'# turn off fill\n' Comment.Single

'      '      Text
'"-C"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'Clear'       Name
' '           Text
':='          Operator
' '           Text
'"yes"'       Literal.String
'                      ' Text
'# turn on clear mode\n' Comment.Single

'      '      Text
'"-r"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'r_seed'      Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'arg'         Name
'['           Punctuation
'3'           Literal.Number.Integer
':'           Punctuation
'0'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'         '   Text
'# random seed\n' Comment.Single

'      '      Text
'"-h"'        Literal.String
' '           Text
':'           Punctuation
' '           Text
'stop'        Name.Function
'('           Punctuation
'"usage: kal [-wn] [-dn] [-ln] [-Mn] [-mn] [-Xn] [-xn] _\n                     [-sn] [-F] [-C] [-rn]"' Literal.String
')'           Punctuation
'\n'          Text

'      '      Text
'}'           Punctuation
'\n'          Text

'   '         Text
'# adjust parameters that depend on the window size...\n' Comment.Single

'   '         Text
'mid_win'     Name
' '           Text
':='          Operator
' '           Text
'win_size'    Name
'/'           Operator
'2'           Literal.Number.Integer
'\n'          Text

'   '         Text
'maxoff'      Name
' '           Text
':='          Operator
' '           Text
'win_size'    Name
'-1'          Literal.Number.Integer
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

"# Lorraine Callahan's kaleidoscope program, translated into icon.\n" Comment.Single

'#  (some of the things she did were too sophisticated for me\n' Comment.Single

'#   to spend time to figure out, so the output is square instead of\n' Comment.Single

"#   round), and I use 'xor' to draw instead of writing to separate\n" Comment.Single

'#   bit planes.\n' Comment.Single

'\n'          Text

'global'      Keyword.Reserved
' '           Text
'putcircle'   Name
','           Punctuation
' '           Text
'clrcircle'   Name
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'kaleidoscope' Name.Function
'('           Punctuation
'r'           Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'local'       Keyword.Reserved
' '           Text
'colors'      Name
'\n\n'        Text

'   '         Text
'# What colors to use?  This can be changed to whatever!\n' Comment.Single

'   '         Text
'colors'      Name
' '           Text
':='          Operator
' '           Text
'['           Punctuation
'"red"'       Literal.String
','           Punctuation
'"green"'     Literal.String
','           Punctuation
'"blue"'      Literal.String
','           Punctuation
'"cyan"'      Literal.String
','           Punctuation
'"magenta"'   Literal.String
','           Punctuation
'"yellow"'    Literal.String
']'           Punctuation
'\n\n'        Text

'   '         Text
'&window'     Keyword.Reserved
' '           Text
':='          Operator
' '           Text
'WOpen'       Name
'('           Punctuation
'"label=Kaleidoscope: \'q\' quits"' Literal.String
','           Punctuation
' '           Text
'"width="'    Literal.String
'||'          Operator
'win_size'    Name
','           Punctuation
'\n'          Text

'                                  ' Text
'"height="'   Literal.String
'||'          Operator
'win_size'    Name
','           Punctuation
' '           Text
'"bg=black"'  Literal.String
')'           Punctuation
'\n'          Text

'   '         Text
'WAttrib'     Name.Function
'('           Punctuation
'"drawop=xor"' Literal.String
')'           Punctuation
'\n\n'        Text

'   '         Text
'# Create two *indentical* sequences of circles, one to use when\n' Comment.Single

'   '         Text
"#   when drawing, one for erasing.  (Since 'xor' is used to\n" Comment.Single

'   '         Text
'#   place them, these both just draw the circles!)\n' Comment.Single

'\n'          Text

'   '         Text
'putcircle'   Name
' '           Text
':='          Operator
' '           Text
'create'      Keyword.Reserved
' '           Text
'{'           Punctuation
'                ' Text
'# draws sequence of circles\n' Comment.Single

'      '      Text
'&random'     Keyword.Reserved
' '           Text
':=:'         Operator
' '           Text
'r'           Name
'\n'          Text

'      '      Text
'|'           Operator
'{'           Punctuation
'\n'          Text

'       '     Text
'Fg'          Name.Function
'('           Punctuation
'?'           Operator
'colors'      Name
')'           Punctuation
'\n'          Text

'       '     Text
'outcircle'   Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'       '     Text
'&random'     Keyword.Reserved
' '           Text
'<->'         Operator
' '           Text
'r'           Name
'\n'          Text

'       '     Text
'}'           Punctuation
'\n'          Text

'      '      Text
'}'           Punctuation
'\n\n'        Text

'   '         Text
'clrcircle'   Name
' '           Text
':='          Operator
' '           Text
'create'      Keyword.Reserved
' '           Text
'{'           Punctuation
'                ' Text
'# erases sequence of circles\n' Comment.Single

'      '      Text
'&random'     Keyword.Reserved
' '           Text
':=:'         Operator
' '           Text
'r'           Name
'\n'          Text

'      '      Text
'|'           Operator
'{'           Punctuation
'\n'          Text

'       '     Text
'Fg'          Name.Function
'('           Punctuation
'?'           Operator
'colors'      Name
')'           Punctuation
'\n'          Text

'       '     Text
'outcircle'   Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'       '     Text
'&random'     Keyword.Reserved
' '           Text
'<->'         Operator
' '           Text
'r'           Name
'\n'          Text

'       '     Text
'}'           Punctuation
'\n'          Text

'      '      Text
'}'           Punctuation
'\n\n'        Text

'   '         Text
'every'       Keyword.Reserved
' '           Text
'1'           Literal.Number.Integer
' '           Text
'to'          Keyword.Reserved
' '           Text
'density'     Name
' '           Text
'do'          Keyword.Reserved
' '           Text
'@'           Operator
'putcircle'   Name
'     '       Text
'# fill screen to density\n' Comment.Single

'\n'          Text

'   '         Text
'every'       Keyword.Reserved
' '           Text
'1'           Literal.Number.Integer
' '           Text
'to'          Keyword.Reserved
' '           Text
'duration'    Name
' '           Text
'do'          Keyword.Reserved
' '           Text
'{'           Punctuation
'             ' Text
'# maintain steady state\n' Comment.Single

'      '      Text
'@'           Operator
'putcircle'   Name
'\n'          Text

'      '      Text
'@'           Operator
'clrcircle'   Name
'\n'          Text

'      '      Text
'if'          Keyword.Reserved
' '           Text
'*'           Operator
'Pending'     Name.Function
'('           Punctuation
'&window'     Keyword.Reserved
')'           Punctuation
' '           Text
'>'           Operator
' '           Text
'0'           Literal.Number.Integer
' '           Text
'then'        Keyword.Reserved
' '           Text
'break'       Keyword.Reserved
'\n'          Text

'      '      Text
'}'           Punctuation
'\n\n'        Text

'   '         Text
'every'       Keyword.Reserved
' '           Text
'('           Punctuation
'Clear'       Name
' '           Text
'=='          Operator
' '           Text
'"On"'        Literal.String
')'           Punctuation
' '           Text
'&'           Operator
' '           Text
'1'           Literal.Number.Integer
' '           Text
'to'          Keyword.Reserved
' '           Text
'density'     Name
' '           Text
'do'          Keyword.Reserved
' '           Text
'@'           Operator
'clrcircle'   Name
'\n\n'        Text

'   '         Text
'close'       Name.Function
'('           Punctuation
'&window'     Keyword.Reserved
')'           Punctuation
'\n'          Text

'end'         Keyword.Reserved
'\n\n\n'      Text

'procedure'   Keyword.Declaration
' '           Text
'outcircle'   Name.Function
'('           Punctuation
')'           Punctuation
'                   ' Text
'# select a circle at random,\n' Comment.Single

'local'       Keyword.Reserved
' '           Text
'radius'      Name
','           Punctuation
' '           Text
'xoff'        Name
','           Punctuation
' '           Text
'yoff'        Name
'                ' Text
'#  draw it in kaleidoscopic form\n' Comment.Single

'\n'          Text

'        '    Text
'# get a random center point and radius\n' Comment.Single

'   '         Text
'xoff'        Name
' '           Text
':='          Operator
' '           Text
'('           Punctuation
'?'           Operator
'('           Punctuation
'maxoff'      Name
' '           Text
'-'           Operator
' '           Text
'minoff'      Name
')'           Punctuation
' '           Text
'+'           Operator
' '           Text
'minoff'      Name
')'           Punctuation
' '           Text
'%'           Punctuation
' '           Text
'mid_win'     Name
'\n'          Text

'   '         Text
'yoff'        Name
' '           Text
':='          Operator
' '           Text
'('           Punctuation
'?'           Operator
'('           Punctuation
'maxoff'      Name
' '           Text
'-'           Operator
' '           Text
'minoff'      Name
')'           Punctuation
' '           Text
'+'           Operator
' '           Text
'minoff'      Name
')'           Punctuation
' '           Text
'%'           Punctuation
' '           Text
'mid_win'     Name
'\n'          Text

'   '         Text
'radius'      Name
' '           Text
':='          Operator
' '           Text
'?'           Operator
'0'           Literal.Number.Integer
' '           Text
'^'           Punctuation
' '           Text
'skew'        Name
'\n'          Text

'        '    Text
"# force radius to 'fit'\n" Comment.Single

'   '         Text
'radius'      Name
' '           Text
':='          Operator
' '           Text
'('           Punctuation
'('           Punctuation
'maxradius'   Name
'-'           Operator
'minradius'   Name
')'           Punctuation
' '           Text
'*'           Operator
' '           Text
'radius'      Name
' '           Text
'+'           Operator
' '           Text
'minradius'   Name
')'           Punctuation
' '           Text
'%'           Punctuation
'\n'          Text

'             ' Text
'('           Punctuation
'mid_win'     Name
' '           Text
'-'           Operator
' '           Text
'('           Punctuation
'('           Punctuation
'xoff'        Name
' '           Text
'<'           Operator
' '           Text
'yoff'        Name
')'           Punctuation
'|'           Operator
'xoff'        Name
')'           Punctuation
')'           Punctuation
'\n\n'        Text

'        '    Text
'# put into all 8 octants\n' Comment.Single

'   '         Text
'draw_circle' Name
'('           Punctuation
'mid_win'     Name
'+'           Operator
'xoff'        Name
','           Punctuation
' '           Text
'mid_win'     Name
'+'           Operator
'yoff'        Name
','           Punctuation
' '           Text
'radius'      Name
')'           Punctuation
'\n'          Text

'   '         Text
'draw_circle' Name
'('           Punctuation
'mid_win'     Name
'+'           Operator
'xoff'        Name
','           Punctuation
' '           Text
'mid_win'     Name
'-'           Operator
'yoff'        Name
','           Punctuation
' '           Text
'radius'      Name
')'           Punctuation
'\n'          Text

'   '         Text
'draw_circle' Name
'('           Punctuation
'mid_win'     Name
'-'           Operator
'xoff'        Name
','           Punctuation
' '           Text
'mid_win'     Name
'+'           Operator
'yoff'        Name
','           Punctuation
' '           Text
'radius'      Name
')'           Punctuation
'\n'          Text

'   '         Text
'draw_circle' Name
'('           Punctuation
'mid_win'     Name
'-'           Operator
'xoff'        Name
','           Punctuation
' '           Text
'mid_win'     Name
'-'           Operator
'yoff'        Name
','           Punctuation
' '           Text
'radius'      Name
')'           Punctuation
'\n\n'        Text

'   '         Text
'draw_circle' Name
'('           Punctuation
'mid_win'     Name
'+'           Operator
'yoff'        Name
','           Punctuation
' '           Text
'mid_win'     Name
'+'           Operator
'xoff'        Name
','           Punctuation
' '           Text
'radius'      Name
')'           Punctuation
'\n'          Text

'   '         Text
'draw_circle' Name
'('           Punctuation
'mid_win'     Name
'+'           Operator
'yoff'        Name
','           Punctuation
' '           Text
'mid_win'     Name
'-'           Operator
'xoff'        Name
','           Punctuation
' '           Text
'radius'      Name
')'           Punctuation
'\n'          Text

'   '         Text
'draw_circle' Name
'('           Punctuation
'mid_win'     Name
'-'           Operator
'yoff'        Name
','           Punctuation
' '           Text
'mid_win'     Name
'+'           Operator
'xoff'        Name
','           Punctuation
' '           Text
'radius'      Name
')'           Punctuation
'\n'          Text

'   '         Text
'draw_circle' Name
'('           Punctuation
'mid_win'     Name
'-'           Operator
'yoff'        Name
','           Punctuation
' '           Text
'mid_win'     Name
'-'           Operator
'xoff'        Name
','           Punctuation
' '           Text
'radius'      Name
')'           Punctuation
'\n\n'        Text

'   '         Text
'return'      Keyword.Reserved
'\n'          Text

'end'         Keyword.Reserved
'\n\n\n'      Text

'############################################################################\n' Comment.Single

'#\n'         Comment.Single

'#   Vidget-based user interface -- developed originally using Mary\n' Comment.Single

"#       Camaron's XIB program.  Don't expect this to be very readable -\n" Comment.Single

'#       you should have to play with it!\n' Comment.Single

'#\n'         Comment.Single

'############################################################################\n' Comment.Single

'procedure'   Keyword.Declaration
' '           Text
'ui'          Name.Function
' '           Text
'('           Punctuation
'win'         Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'local'       Keyword.Reserved
' '           Text
'cv1'         Name
','           Punctuation
' '           Text
'cv2'         Name
','           Punctuation
' '           Text
'cv3'         Name
','           Punctuation
' '           Text
'cv4'         Name
'\n'          Text

'   '         Text
'local'       Keyword.Reserved
' '           Text
'\n'          Text

'         '   Text
'radio_button2' Name
','           Punctuation
' '           Text
'\n'          Text

'         '   Text
'radio_button1' Name
','           Punctuation
' '           Text
'\n'          Text

'         '   Text
'text_input6' Name
','           Punctuation
' '           Text
'\n'          Text

'         '   Text
'text_input5' Name
','           Punctuation
' '           Text
'\n'          Text

'         '   Text
'slider4'     Name
','           Punctuation
' '           Text
'\n'          Text

'         '   Text
'slider3'     Name
','           Punctuation
' '           Text
'\n'          Text

'         '   Text
'text_input4' Name
','           Punctuation
' '           Text
'\n'          Text

'         '   Text
'text_input3' Name
','           Punctuation
' '           Text
'\n'          Text

'         '   Text
'slider2'     Name
','           Punctuation
' '           Text
'\n'          Text

'         '   Text
'slider1'     Name
' '           Text
'\n\n'        Text

'   '         Text
'/'           Operator
'win'         Name
' '           Text
':='          Operator
' '           Text
'WOpen'       Name
'('           Punctuation
'"label=ui"'  Literal.String
','           Punctuation
' '           Text
'"width=404"' Literal.String
','           Punctuation
' '           Text
'"height=313"' Literal.String
','           Punctuation
' '           Text
'"font=6x12"' Literal.String
')'           Punctuation
' '           Text
'|'           Operator
' '           Text
'\n'          Text

'           ' Text
'stop'        Name.Function
' '           Text
'('           Punctuation
'"bad win"'   Literal.String
')'           Punctuation
'\n'          Text

'   '         Text
'root'        Name
' '           Text
':='          Operator
' '           Text
'Vroot_frame' Name
' '           Text
'('           Punctuation
'win'         Name
')'           Punctuation
'\n\n'        Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'Vmessage'    Name
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'win_size'    Name
'/'           Operator
'2'           Literal.Number.Integer
')'           Punctuation
','           Punctuation
' '           Text
'168'         Literal.Number.Integer
','           Punctuation
' '           Text
'98'          Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'Vmessage'    Name
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'"1"'         Literal.String
')'           Punctuation
','           Punctuation
' '           Text
'108'         Literal.Number.Integer
','           Punctuation
' '           Text
'97'          Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'sk_v'        Name
' '           Text
':='          Operator
' '           Text
'Vtext'       Name
'('           Punctuation
'win'         Name
','           Punctuation
'"Skew:\\\\=1"' Literal.String
','           Punctuation
'get_skew'    Name
','           Punctuation
','           Punctuation
'6'           Literal.Number.Integer
')'           Punctuation
','           Punctuation
' '           Text
'280'         Literal.Number.Integer
','           Punctuation
' '           Text
'39'          Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'du_v'        Name
' '           Text
':='          Operator
' '           Text
'Vtext'       Name
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'"Duration:\\\\="' Literal.String
'||'          Operator
'duration'    Name
','           Punctuation
' '           Text
'get_duration' Name
','           Punctuation
','           Punctuation
'9'           Literal.Number.Integer
')'           Punctuation
','           Punctuation
'\n'          Text

'                ' Text
'237'         Literal.Number.Integer
','           Punctuation
' '           Text
'15'          Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'Vmessage'    Name
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'"Clear at end?"' Literal.String
')'           Punctuation
','           Punctuation
' '           Text
'232'         Literal.Number.Integer
','           Punctuation
' '           Text
'145'         Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'Vmessage'    Name
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'"Fill?"'     Literal.String
')'           Punctuation
','           Punctuation
' '           Text
'105'         Literal.Number.Integer
','           Punctuation
' '           Text
'142'         Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'Vmessage'    Name
'('           Punctuation
'win'         Name
','           Punctuation
'"Quit?"'     Literal.String
')'           Punctuation
','           Punctuation
' '           Text
'267'         Literal.Number.Integer
','           Punctuation
' '           Text
'259'         Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'Vmessage'    Name
'('           Punctuation
'win'         Name
','           Punctuation
'"Display it?"' Literal.String
')'           Punctuation
','           Punctuation
' '           Text
'26'          Literal.Number.Integer
','           Punctuation
' '           Text
'260'         Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'Vcheckbox'   Name
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'do_quit'     Name
','           Punctuation
' '           Text
'"check2"'    Literal.String
','           Punctuation
'20'          Literal.Number.Integer
')'           Punctuation
','           Punctuation
' '           Text
'305'         Literal.Number.Integer
','           Punctuation
' '           Text
'255'         Literal.Number.Integer
','           Punctuation
' '           Text
'20'          Literal.Number.Integer
','           Punctuation
' '           Text
'20'          Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'check1'      Name
':='          Operator
'Vcheckbox'   Name
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'do_display'  Name
','           Punctuation
' '           Text
'"check1"'    Literal.String
','           Punctuation
'20'          Literal.Number.Integer
')'           Punctuation
','           Punctuation
'\n'          Text

'                ' Text
'106'         Literal.Number.Integer
','           Punctuation
' '           Text
'258'         Literal.Number.Integer
','           Punctuation
' '           Text
'20'          Literal.Number.Integer
','           Punctuation
' '           Text
'20'          Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'radio_button2' Name
' '           Text
':='          Operator
' '           Text
'Vradio_buttons' Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'['           Punctuation
'"On"'        Literal.String
','           Punctuation
' '           Text
'"Off"'       Literal.String
']'           Punctuation
','           Punctuation
' '           Text
'get_clear'   Name
','           Punctuation
' '           Text
','           Punctuation
' '           Text
'V_CIRCLE'    Name
')'           Punctuation
'\n'          Text

'   '         Text
'VSet'        Name
'('           Punctuation
'radio_button2' Name
','           Punctuation
'Clear'       Name
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'radio_button2' Name
','           Punctuation
' '           Text
'253'         Literal.Number.Integer
','           Punctuation
' '           Text
'165'         Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'radio_button1' Name
' '           Text
':='          Operator
' '           Text
'Vradio_buttons' Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'['           Punctuation
'"On"'        Literal.String
','           Punctuation
' '           Text
'"Off"'       Literal.String
']'           Punctuation
','           Punctuation
' '           Text
'get_fill'    Name
','           Punctuation
' '           Text
','           Punctuation
' '           Text
'V_CIRCLE'    Name
')'           Punctuation
'\n'          Text

'   '         Text
'VSet'        Name
'('           Punctuation
'radio_button1' Name
','           Punctuation
'fill'        Name
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'radio_button1' Name
','           Punctuation
' '           Text
'99'          Literal.Number.Integer
','           Punctuation
' '           Text
'165'         Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'cv1'         Name
' '           Text
':='          Operator
' '           Text
'Vcoupler'    Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv1'         Name
','           Punctuation
' '           Text
'get_max_offset' Name
')'           Punctuation
'\n'          Text

'   '         Text
'text_input6' Name
' '           Text
':='          Operator
' '           Text
'Vtext'       Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'"Max Offset:\\\\="' Literal.String
'||'          Operator
'('           Punctuation
'win_size'    Name
'-1'          Literal.Number.Integer
')'           Punctuation
','           Punctuation
' '           Text
'cv1'         Name
','           Punctuation
' '           Text
','           Punctuation
' '           Text
'3'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv1'         Name
','           Punctuation
' '           Text
'text_input6' Name
')'           Punctuation
'\n'          Text

'   '         Text
'slider4'     Name
' '           Text
':='          Operator
' '           Text
'Vhoriz_slider' Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'cv1'         Name
','           Punctuation
' '           Text
'"slider4"'   Literal.String
','           Punctuation
' '           Text
'70'          Literal.Number.Integer
','           Punctuation
' '           Text
'12'          Literal.Number.Integer
','           Punctuation
' '           Text
'0'           Literal.Number.Integer
','           Punctuation
'\n'          Text

'                         ' Text
'win_size'    Name
'-1'          Literal.Number.Integer
','           Punctuation
' '           Text
'win_size'    Name
'-1'          Literal.Number.Integer
','           Punctuation
' '           Text
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv1'         Name
','           Punctuation
' '           Text
'slider4'     Name
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'text_input6' Name
','           Punctuation
' '           Text
'196'         Literal.Number.Integer
','           Punctuation
' '           Text
'103'         Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'slider4'     Name
','           Punctuation
' '           Text
'306'         Literal.Number.Integer
','           Punctuation
' '           Text
'106'         Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'cv2'         Name
' '           Text
':='          Operator
' '           Text
'Vcoupler'    Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv2'         Name
','           Punctuation
' '           Text
'get_min_offset' Name
')'           Punctuation
'\n'          Text

'   '         Text
'text_input5' Name
' '           Text
':='          Operator
' '           Text
'Vtext'       Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'"Min Offset\\\\=1"' Literal.String
','           Punctuation
' '           Text
'cv2'         Name
','           Punctuation
' '           Text
','           Punctuation
' '           Text
'3'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv2'         Name
','           Punctuation
' '           Text
'text_input5' Name
')'           Punctuation
'\n'          Text

'   '         Text
'slider3'     Name
' '           Text
':='          Operator
' '           Text
'Vhoriz_slider' Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'cv2'         Name
','           Punctuation
' '           Text
'"slider3"'   Literal.String
','           Punctuation
' '           Text
'70'          Literal.Number.Integer
','           Punctuation
' '           Text
'12'          Literal.Number.Integer
','           Punctuation
' '           Text
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'win_size'    Name
'-1'          Literal.Number.Integer
','           Punctuation
' '           Text
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv2'         Name
','           Punctuation
' '           Text
'slider3'     Name
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'text_input5' Name
','           Punctuation
' '           Text
'201'         Literal.Number.Integer
','           Punctuation
' '           Text
'80'          Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'slider3'     Name
','           Punctuation
' '           Text
'307'         Literal.Number.Integer
','           Punctuation
' '           Text
'82'          Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'cv3'         Name
' '           Text
':='          Operator
' '           Text
'Vcoupler'    Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv3'         Name
','           Punctuation
' '           Text
'get_max_radius' Name
')'           Punctuation
'\n'          Text

'   '         Text
'text_input4' Name
' '           Text
':='          Operator
' '           Text
'Vtext'       Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'"Max Radius\\\\="' Literal.String
'||'          Operator
'('           Punctuation
'win_size'    Name
'/'           Operator
'4'           Literal.Number.Integer
')'           Punctuation
','           Punctuation
' '           Text
'cv3'         Name
','           Punctuation
' '           Text
','           Punctuation
' '           Text
'3'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv3'         Name
','           Punctuation
' '           Text
'text_input4' Name
')'           Punctuation
'\n'          Text

'   '         Text
'slider2'     Name
' '           Text
':='          Operator
' '           Text
'Vhoriz_slider' Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'cv3'         Name
','           Punctuation
' '           Text
'"slider2"'   Literal.String
','           Punctuation
' '           Text
'70'          Literal.Number.Integer
','           Punctuation
' '           Text
'12'          Literal.Number.Integer
','           Punctuation
' '           Text
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'win_size'    Name
'/'           Operator
'2'           Literal.Number.Integer
','           Punctuation
'\n'          Text

'         '   Text
'win_size'    Name
'/'           Operator
'4'           Literal.Number.Integer
','           Punctuation
' '           Text
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv3'         Name
','           Punctuation
' '           Text
'slider2'     Name
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'text_input4' Name
','           Punctuation
' '           Text
'10'          Literal.Number.Integer
','           Punctuation
' '           Text
'104'         Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'slider2'     Name
','           Punctuation
' '           Text
'110'         Literal.Number.Integer
','           Punctuation
' '           Text
'108'         Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'cv4'         Name
' '           Text
':='          Operator
' '           Text
'Vcoupler'    Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv4'         Name
','           Punctuation
' '           Text
'get_min_radius' Name
')'           Punctuation
'\n'          Text

'   '         Text
'text_input3' Name
' '           Text
':='          Operator
' '           Text
'Vtext'       Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'"Min Radius\\\\=1"' Literal.String
','           Punctuation
' '           Text
'cv4'         Name
','           Punctuation
' '           Text
','           Punctuation
' '           Text
'3'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv4'         Name
','           Punctuation
' '           Text
'text_input3' Name
')'           Punctuation
'\n'          Text

'   '         Text
'slider1'     Name
' '           Text
':='          Operator
' '           Text
'Vhoriz_slider' Name
' '           Text
'('           Punctuation
'win'         Name
','           Punctuation
' '           Text
'cv4'         Name
','           Punctuation
' '           Text
'"slider1"'   Literal.String
','           Punctuation
' '           Text
'70'          Literal.Number.Integer
','           Punctuation
' '           Text
'12'          Literal.Number.Integer
','           Punctuation
' '           Text
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'win_size'    Name
'/'           Operator
'2'           Literal.Number.Integer
','           Punctuation
' '           Text
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
')'           Punctuation
'\n'          Text

'   '         Text
'VAddClient'  Name
'('           Punctuation
'cv4'         Name
','           Punctuation
' '           Text
'slider1'     Name
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'text_input3' Name
','           Punctuation
' '           Text
'10'          Literal.Number.Integer
','           Punctuation
' '           Text
'81'          Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'slider1'     Name
','           Punctuation
' '           Text
'110'         Literal.Number.Integer
','           Punctuation
' '           Text
'84'          Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'rs_v'        Name
' '           Text
':='          Operator
' '           Text
'Vtext'       Name
'('           Punctuation
'win'         Name
','           Punctuation
'"Random Seed:\\\\="' Literal.String
'||'          Operator
'r_seed'      Name
','           Punctuation
' '           Text
'get_random'  Name
','           Punctuation
','           Punctuation
' '           Text
'11'          Literal.Number.Integer
')'           Punctuation
','           Punctuation
'\n'          Text

'              ' Text
'30'          Literal.Number.Integer
','           Punctuation
' '           Text
'41'          Literal.Number.Integer
')'           Punctuation
'\n'          Text

'   '         Text
'VInsert'     Name
' '           Text
'('           Punctuation
'root'        Name
','           Punctuation
' '           Text
'de_v'        Name
' '           Text
':='          Operator
' '           Text
'Vtext'       Name
'('           Punctuation
'win'         Name
','           Punctuation
'"Density:\\\\="' Literal.String
'||'          Operator
'density'     Name
','           Punctuation
' '           Text
'get_density' Name
','           Punctuation
','           Punctuation
'8'           Literal.Number.Integer
')'           Punctuation
','           Punctuation
'\n'          Text

'              ' Text
'71'          Literal.Number.Integer
','           Punctuation
' '           Text
'16'          Literal.Number.Integer
')'           Punctuation
'\n\n'        Text

'   '         Text
'VResize'     Name
' '           Text
'('           Punctuation
'root'        Name
')'           Punctuation
'\n'          Text

'   '         Text
'return'      Keyword.Reserved
' '           Text
'root'        Name
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_skew'    Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'skew'        Name
' '           Text
':='          Operator
' '           Text
'value'       Name
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_duration' Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'duration'    Name
' '           Text
':='          Operator
' '           Text
'value'       Name
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'do_quit'     Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'stop'        Name.Function
'('           Punctuation
')'           Punctuation
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'do_display'  Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'r_seed'      Name
'   '         Text
':='          Operator
' '           Text
'numeric'     Name.Function
'('           Punctuation
'rs_v'        Name
'.'           Literal.Number.Float
'data'        Name
')'           Punctuation
'\n'          Text

'   '         Text
'duration'    Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'du_v'        Name
'.'           Literal.Number.Float
'data'        Name
')'           Punctuation
'\n'          Text

'   '         Text
'density'     Name
'  '          Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'de_v'        Name
'.'           Literal.Number.Float
'data'        Name
')'           Punctuation
'\n'          Text

'   '         Text
'skew'        Name
'     '       Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'sk_v'        Name
'.'           Literal.Number.Float
'data'        Name
')'           Punctuation
'\n'          Text

'   '         Text
'kaleidoscope' Name
'('           Punctuation
'r_seed'      Name
')'           Punctuation
'\n'          Text

'   '         Text
'wit'         Name
'.'           Literal.Number.Float
'callback'    Name
'.'           Literal.Number.Float
'value'       Name
' '           Text
':='          Operator
' '           Text
'&null'       Keyword.Constant
'\n'          Text

'   '         Text
'VDraw'       Name
'('           Punctuation
'check1'      Name
')'           Punctuation
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_clear'   Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'Clear'       Name
' '           Text
':='          Operator
' '           Text
'value'       Name
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_fill'    Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'fill'        Name
' '           Text
':='          Operator
' '           Text
'value'       Name
'\n'          Text

'   '         Text
'if'          Keyword.Reserved
' '           Text
'fill'        Name
' '           Text
'=='          Operator
' '           Text
'"Off"'       Literal.String
' '           Text
'then'        Keyword.Reserved
' '           Text
'draw_circle' Name
' '           Text
':='          Operator
' '           Text
'DrawCircle'  Name.Function
'\n'          Text

'   '         Text
'else'        Keyword.Reserved
' '           Text
'draw_circle' Name
' '           Text
':='          Operator
' '           Text
'FillCircle'  Name.Function
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_max_offset' Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'maxoff'      Name
' '           Text
':='          Operator
' '           Text
'value'       Name
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_min_offset' Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'minoff'      Name
' '           Text
':='          Operator
' '           Text
'value'       Name
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_max_radius' Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'maxradius'   Name
' '           Text
':='          Operator
' '           Text
'value'       Name
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_min_radius' Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'minradius'   Name
' '           Text
':='          Operator
' '           Text
'value'       Name
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_random'  Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'r_seed'      Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'value'       Name
')'           Punctuation
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'get_density' Name.Function
' '           Text
'('           Punctuation
'wit'         Name.Variable
','           Punctuation
' '           Text
'value'       Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'density'     Name
' '           Text
':='          Operator
' '           Text
'integer'     Name.Function
'('           Punctuation
'value'       Name
')'           Punctuation
'\n'          Text

'end'         Keyword.Reserved
'\n\n'        Text

'procedure'   Keyword.Declaration
' '           Text
'quit'        Name.Function
'('           Punctuation
'e'           Name.Variable
')'           Punctuation
'\n'          Text

'   '         Text
'if'          Keyword.Reserved
' '           Text
'e'           Name
' '           Text
'==='         Operator
' '           Text
'"q"'         Literal.String
' '           Text
'then'        Keyword.Reserved
' '           Text
'stop'        Name.Function
' '           Text
'('           Punctuation
'"Exiting Kaleidoscope"' Literal.String
')'           Punctuation
'\n'          Text

'end'         Keyword.Reserved
'\n'          Text
