;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; FILTER EXAMPLE
;;
;; Download a medium sized quicktime trailer from apple
;; Load it into quicktime-pro and export it in a non-IFrame
;; format (gfx:get-movie-frame does not support iframes).
;; I would suggest using jpeg photo.
;;
;; This example shows how real time effects can be applied
;; to images using gfx:filter-image, even when these images are from a movie.
;;
;; A complete list of filters and filter parameters can
;; be found in apples "Core Image Programming Guide".
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define canvas (gfx:make-canvas))
(define movie (gfx:load-movie "/tmp/myfilm.mov"))
(define torus-params '(("inputIntensity" . 5)))
(define lgth (- (gfx:get-movie-duration movie) 1.0))
(define frame-length (* *second* 0.1))
(define loop
(lambda (time movie-time)
(let* ((image (gfx:convert-image (gfx:get-movie-frame movie movie-time)))
(filtered-image (gfx:filter-image image "CIEdges" torus-params)))
(gfx:draw-image time canvas filtered-image 1.0 '(75 150))
(set! time (+ time frame-length))
(if (> movie-time lgth)
(callback (- time 4000) 'loop time 0.0)
(callback (- time 4000) 'loop time (+ movie-time 0.1))))))
(loop (now) 0.0)