// program to draw lines radiating out from where mouse
// was pressed.
// Written by Kim Bruce, 8/2014
dialect "rtobjectdraw"

def Spirograph: GraphicApplication = object {
   inherit graphicApplicationSize (400 @ 400)

   // remember where the mouse was pressed
   var nextLineStarts: Point

   // when the mouse is pressed remember where mouse was
   method onMousePress (point: Point) -> Done {
      nextLineStarts := point
   }

   // Draw a new line from where mouse was pressed to current
   // location when mouse is dragged.
   method onMouseDrag (point: Point) -> Done {
      lineFrom (nextLineStarts) to (point) on (canvas)
   }

   // required to pop up window and start graphics
   startGraphics

}