  % Title "Intersections Demo"
 '% Animated
 '% ScaleUp
 '% PlaceCentral
 '% AnchorCentral
  uses consoleG
  uses GLO2\GeoPlanar
  uses chaos

  sub drawintersections()
  =======================

  string tab="    "
  point  p
  int    a

  seed=0x123567

  'generate random lines
  line d[200]
  indexbase 0

  int i,j,k,q
  q=100
  float r[16]
  for i=0 to q-1
    'create dispersed set of coords
    r[0]=rnd
    r[1]=rnd
    r[2]=rnd
    r[3]=rnd
    d[i]={ r[0],r[1]r[2],r[3]}
  next
  '


  'shading
  'flat 'default

  '
  color 0,1,1
  'printl "intersect" tab p.x tab p.y

  scale 16,16

  move 1,-1
  '

  color 0,1,1

  int e=25
  for i=0 to e
    drawline @d[i]
  next
  pointsize 5
  color 1,1,0
  for i=0 to e-1
    for j=i+1 to e
      a=intersected d[i],d[j],p
      if a
        drawpoint @p
      endif
    next
  next

  end sub


  sub main()
  ==========
  string s
  cls 0,0,0
  pushstate
  scale 2,2
  'typeface=1
  printl "Intersection Points"
  popstate
  '
  move 0,-2
  '
  PushState
  move 1,-1
  DrawIntersections
  PopState
  '
  
  end sub

  EndScript
