]> gitweb.factorcode.org Git - factor.git/blob - extra/processing/gallery/trails/trails.factor
Remove with-malloc, use destructors instead
[factor.git] / extra / processing / gallery / trails / trails.factor
1
2 USING: kernel arrays sequences math math.order qualified
3        sequences.lib circular processing ui newfx processing.shapes ;
4
5 IN: processing.gallery.trails
6
7 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8
9 ! Example 33-15 from the Processing book
10
11 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12
13 : point-list ( n -- seq ) [ drop 0 0 2array ] map <circular> ;
14
15 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
17 : dot ( pos percent -- ) 1 swap - 25 * 5 max circle ;
18
19 : step ( seq -- )
20
21   no-stroke
22   { 1 0.4 } fill
23
24   0 background
25
26   mouse push-circular
27     [ dot ]
28   each-percent ;
29
30 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31
32 : go* ( -- )
33
34   500 500 size*
35
36   [
37     100 point-list
38       [ step ]
39     curry
40       draw
41   ] setup
42
43   run ;
44
45 : go ( -- ) [ go* ] with-ui ;
46
47 MAIN: go