[Fluxus] with-state and with-primitive stack commit

Dave Griffiths dave at pawfal.org
Mon Dec 3 14:59:37 PST 2007


I've unified the with-state and with-primitive stacks so you can build
new primitives while inside with-primitive for another primitive. 

This is because I noticed doing things like making new primitives
relative to existing ones was very difficult with the new syntax - for
example the following becomes possible now:

; make a sphere somewhere
(define my-sphere (with-state 
    (translate (vector 4 0 2))
    (build-sphere 10 10)))

; put a new wireframe sphere on top of my-sphere
(with-primitive my-sphere
    ; find the position using my-sphere's transform
    (let ((position (vtransform (vector 0 0 0) (get-transform))))
    (with-state
        (hint-none) ; these commands set the new state,
        (hint-wire) ; _not_ my-sphere's state
        (translate position) ; move to the position we found
        (scale (vector 2 2 2)) ; make it a bit bigger
        (build-sphere 5 5))))

cheers,

dave




More information about the Fluxus mailing list