From 14a54bb97a7a5182073be0d3fbe34e79d8b8fc8e Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 8 Dec 2008 21:30:10 -0600 Subject: [PATCH 1/2] trails: Un-processify trails --- extra/trails/trails.factor | 96 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 extra/trails/trails.factor diff --git a/extra/trails/trails.factor b/extra/trails/trails.factor new file mode 100644 index 0000000000..cea5ece9f7 --- /dev/null +++ b/extra/trails/trails.factor @@ -0,0 +1,96 @@ + +USING: kernel accessors locals namespaces sequences sequences.lib threads + math math.order math.vectors + calendar + colors opengl ui ui.gadgets ui.gestures ui.render + circular + processing.shapes ; + +IN: trails + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +! Example 33-15 from the Processing book + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +! Return the mouse location relative to the current gadget + +: mouse ( -- point ) hand-loc get hand-gadget get screen-loc v- ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: point-list ( n -- seq ) [ drop { 0 0 } ] map ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: percent->radius ( percent -- radius ) neg 1 + 25 * 5 max ; + +: dot ( pos percent -- ) percent->radius circle ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +TUPLE: < gadget paused points ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: iterate-system ( GADGET -- ) + + ! Add a valid point if the mouse is in the gadget + ! Otherwise, add an "invisible" point + + hand-gadget get GADGET = + [ mouse GADGET points>> push-circular ] + [ { -10 -10 } GADGET points>> push-circular ] + if ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: start-trails-thread ( GADGET -- ) + GADGET f >>paused drop + [ + [ + GADGET paused>> + [ f ] + [ GADGET iterate-system GADGET relayout-1 1 milliseconds sleep t ] + if + ] + loop + ] + in-thread ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +M: pref-dim* ( -- dim ) drop { 500 500 } ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +M:: draw-gadget* ( GADGET -- ) + origin get + [ + T{ rgba f 1 1 1 0.4 } \ fill-color set ! White, with some transparency + T{ rgba f 0 0 0 0 } \ stroke-color set ! no stroke + + black gl-clear + + GADGET points>> [ dot ] each-percent + ] + with-translation ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: trails-gadget ( -- ) + + new-gadget + + 300 point-list >>points + + t >>clipped? + + dup start-trails-thread ; + +: trails-window ( -- ) [ trails-gadget "Trails" open-window ] with-ui ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +MAIN: trails-window \ No newline at end of file From 29bd77d04061158090b50ae9215298d4b3f903a6 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 8 Dec 2008 21:32:09 -0600 Subject: [PATCH 2/2] Remove old trails --- extra/processing/gallery/trails/trails.factor | 47 ------------------- 1 file changed, 47 deletions(-) delete mode 100644 extra/processing/gallery/trails/trails.factor diff --git a/extra/processing/gallery/trails/trails.factor b/extra/processing/gallery/trails/trails.factor deleted file mode 100644 index a5b2b7b02a..0000000000 --- a/extra/processing/gallery/trails/trails.factor +++ /dev/null @@ -1,47 +0,0 @@ - -USING: kernel arrays sequences math math.order qualified - sequences.lib circular processing ui newfx processing.shapes ; - -IN: processing.gallery.trails - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! Example 33-15 from the Processing book - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: point-list ( n -- seq ) [ drop 0 0 2array ] map ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: dot ( pos percent -- ) 1 swap - 25 * 5 max circle ; - -: step ( seq -- ) - - no-stroke - { 1 0.4 } fill - - 0 background - - mouse push-circular - [ dot ] - each-percent ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: go* ( -- ) - - 500 500 size* - - [ - 100 point-list - [ step ] - curry - draw - ] setup - - run ; - -: go ( -- ) [ go* ] with-ui ; - -MAIN: go