 USING: accessors arrays calendar circular colors
 colors.constants fry kernel locals math math.order math.vectors
-namespaces opengl processing.shapes sequences threads ui
+namespaces opengl processing.shapes sequences threads timers ui
 ui.gadgets ui.gestures ui.render ;
 
 IN: trails

    trails-gadget new
        300 point-list >>points
        t >>clipped?
    dup start-trails-thread ;

MAIN-WINDOW: trails-window
    { { title "Trails" } }


: dot ( pos percent -- ) percent->radius draw-circle ;

TUPLE: trails-gadget < gadget paused points timer ;

M: trails-gadget graft*
    [ timer>> start-timer yield ] [ call-next-method ] bi ;

M: trails-gadget ungraft*
    [ timer>> stop-timer ] [ t >>paused call-next-method ] bi ;

:: iterate-system ( GADGET -- )
    ! Add a valid point if the mouse is in the gadget
    ! Otherwise, add an "invisible" point
    hand-gadget get GADGET = [ mouse ] [ { -10 -10 } ] if
    GADGET points>> circular-push ;

M: trails-gadget pref-dim* drop { 500 500 } ;

