Pink polygons & multitouch

A new version of android fluxus, with pdata, multitouch capability, scene inspection and a very pink test script included (see code below) fluxus-0.0.2.apk & source. Press the trackball button to edit the scheme code.


(define twirl-shape 
   (build-polygons 40 triangle-strip)))

(define finger-shapes
   (list (build-polygons 30 triangle-strip)
         (build-polygons 30 triangle-strip))))

(define (spiral)
  (line-width 5)
  (pdata-map! (lambda (c) (vector 1 0.29 0.42)) "c")
   (lambda (i p)
     (let ((i (* i 0.8)))
       (vmul (vector (sin i) (cos i) 0) (* 0.02 i i))))
  (pdata-copy "p" "pref") ; only really needed for animation
   (lambda (p pref)
     (vadd pref (vmul (crndvec) 0.2)))
   "p" "pref"))

 (lambda (finger-shape)
   (with-primitive finger-shape (spiral)))

  (lambda (c)
    (vector 1 0.29 0.42))

; using with-primitive is really slow, so directly use grab
; returns the distance between the objects
(define (get-pinch)
  (grab (car finger-shapes))
  (let ((a (vtransform (vector 0 0 0) (get-transform))))
    (ungrab)(grab (cadr finger-shapes))
    (let ((b (vtransform (vector 0 0 0) (get-transform))))
      (vdist a b))))

; store pinch as it's slow to calculate
(define pinch 1)

   ; do the twirling
     (lambda (i p)
       (let ((i (* i 0.5)))
         (vmul (vector (sin i) (cos i) (* 2 (cos (* i 10.43)))) 
               (* 5 (sin (* pinch (+ i (* 0.1 (time))) 0.1))))))
   ; check for touch events
    (lambda (touch-id)
      (let ((finger-shape (list-ref finger-shapes touch-id)))
          (get-point-from-touch touch-id))
         (rotate (vector 0 0 (* (time) 10)))))
      (set! pinch (get-pinch)))

Leave a Reply

Your email address will not be published. Required fields are marked *