From 8f7f1228d35a1131d18d7f437424a5739a42d187 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 6 Apr 2008 20:31:40 -0500 Subject: [PATCH] Add processing.gallery.trails --- extra/processing/gallery/trails/trails.factor | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 extra/processing/gallery/trails/trails.factor diff --git a/extra/processing/gallery/trails/trails.factor b/extra/processing/gallery/trails/trails.factor new file mode 100644 index 0000000000..f0a8889fbf --- /dev/null +++ b/extra/processing/gallery/trails/trails.factor @@ -0,0 +1,62 @@ + +USING: kernel arrays sequences math qualified circular processing ui ; + +IN: processing.gallery.trails + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +! Example 33-15 from the Processing book + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +QUALIFIED: circular + +: push-circular ( seq elt -- seq ) over circular:push-circular ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: each-percent ( seq quot -- ) + >r + dup length + dup [ / ] curry + [ 1+ ] swap compose + r> compose + 2each ; inline + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: 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 \ No newline at end of file