// load a pointlist file and display using dotfill/curvefill and dotmove...

include dotmove
include tracer
logo backcolor "black"

repeat untilbreak [
  pointlist clearall
  
  // ptfilename can be set on the command line.. if it wasn't, ask user now..
  setifnotgiven ptfilename = ""  
  if :ptfilename = "" [
    set ptfilename = filepick "Name of points file to load:" "ptsfiles" "*" 
    if :ptfilename = "cancel" [ return 0 ]
    set filltype = buttonchoice "Processing:" "None|Dots|Curve fit"
    set disptype = buttonchoice "Display using:" "Lines|Dot move|Tracer"
    if :disptype = "dot move" [ set spacing = buttonchoice "Space red dots every:" "3|4|5|8|10|20|40" ]
    ]
  else [ set filltype = "Dots"; set disptype = "dot move"; set spacing = "3"; ]
  
  set ptfilename = concat 2 "ptsfiles/" :ptfilename
  
  clear
  pointlist startcapture
    pointlist loadfile :ptfilename
  pointlist endcapture
  
  // now convert to a series of dots..
  if :filltype != "none" [
    pointlist startcapture
    if :filltype = "dots" [ pointlist dotfill 12 ]
    elseif :filltype = "curve fit" [ pointlist curvefill ]
    pointlist endcapture
    ]
  set npts = pointlist size
  
  wait 30
  message "Displaypts..." "Stop"
  pu
  if :disptype = "dot move" [ 
    logo fillcolor = "red"
    logo linecolor = "blue"
    set ndots = calc :npts / :spacing
    dotmove   :ndots   :spacing   backcolor 8 5 
    ]
  elseif :disptype = "tracer" [ tracer 5 0 ]
  else [ logo linecolor = "green"; pointlist draw; ]

  set ans = buttonchoice "" "Go again|Quit"
  if :ans = "quit" [ break ]
  set ptfilename = ""
  ]
