[Fluxus] delay

RPD ilostmyfiles at yahoo.com
Tue Jul 12 01:19:28 PDT 2011


--- On Mon, 7/11/11, Damaru <gef at ponnuki.net> wrote:
> My idea is the gemeration of the
> shape, to gradually slow down in it's creation. The
> recursion loop 300 times, during these 300 loop 300 sphere
> gets drawn on a random translate. I would like the first
> loop of the recursion to happen right away, the second loop
> after 0.01, the third loop after 0.03, the fourth loop at
> 0.6 etc. exponentially so that the complete drawing of the
> 300 sphere start fast and slowly ease out.

Hi, Damaru... It can be done with a few minor tweaks to Gabor's example.
The trick is to vary the number of spheres you draw every frame, and the
delay between new objects is rather the varying amount of time before
incrementing that number. It only appears to be delayed creation-- it's
still drawing between 0 and 300 in every frame, which is necessary when
you're using (draw-foo) as opposed to (build-foo). Here, I marked my
changes with comments:

(define s (time))
(define ds 0.001)
(define seed (random 9001))                            ;new for each run
(define count 0)                                       ;where to begin
(define max 300)                                       ;target number

(define (cloud num)
    (cond
        ((not (zero? num))
            (draw-sphere)
            (translate (vector 0 (* 2 (grndf)) (* 2 (grndf))))
            (colour (vector (* (sin (time))  (/ num 100)) (/ num 100) num))
            (cloud (- num 1)))))

(define (rotate-cloud)
    (when (> (- (time) s) ds)
        (set! s (time))
        (set! ds (* 1.1 ds))
                                                       ;no more (set! seed
        (when (> max count) (set! count (+ count 1)))) ;one more loop
    (random-seed seed)

    (with-state
        (rotate (vector 0 (* 10 (time)) 0 ))
        (cloud count)))                                ;not the constant

(every-frame
    (rotate-cloud))

Of course then within the (colour) line, the num would be only the number
that had already been shown, unless you replace each 'num' with 'max'.

Another way is to generate the random numbers once, as you build persistent
primitives using (build-sphere), then operate on their colour with a line
in (every-frame) such as (with-primitive foo (colour (vector n n n)))),
and it can be (colour) or (pdata-map!) or my favorite, (pdata-index-map!).

You can then build new ones in your (every-frame) code, still testing
against (time) to decide whether to spawn another, i.e. add it to the
scenegraph. But then, with all of this, you need to build up your own
vector or list of them to keep track for grabbing each in (with-primitive)
and for (destroy)ing them if you don't want to wipe the whole scene with
(clear). Your way with (draw-sphere) is much simpler in that sense. 

As usual, I am ever standing on the shoulders of geniuses... and as usual,
I hope this helps.

--Rob




More information about the Fluxus mailing list