// SINE demo

set dispx = 0      // horizonal location for display purposes
set yofs = 400     // controls vertical location
set smoothval = 10 // smaller = smoother curve
set periodval = 10 // smaller = lower wave frequency

message "These are called 'sine waves'" "Stop"
include 0grid    // do a gray grid..
pu
set x = 0   set y = 0   
moveto 0 :yofs
pd
repeat untilbreak [
  if keypress = 1 [ break ] 
  set y = sine :x           
  moveto :dispx (calc :y + :yofs)
  incr x by :periodval
  incr dispx by :smoothval
  if :dispx > winwide [ 
    set dispx = 0 
    decr yofs by 1     
    pu   
    moveto :dispx (calc :y + :yofs)   
    pd
    if :yofs <= 100 [ break ]   
    ]
  wait 3  
  ]

