;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; DRAWS A STRING OVER AN IMAGE
;;
;; This example show a few possabilities.
;; 1. A movie frame can be be distorted (useing set-image-size)
;; 2. Text can be drawn to a canvas (using draw-text)
;; 3. Compositing of text and images can be done (using gfx:text2image)
;;
;; NOTE that we need to convert the image from a ciimage to a bitmap before
;; we can use text2image.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define canvas (gfx:make-canvas 600 600))
; change the path to the movie file to suit your computer
(define movie (gfx:load-movie "/tmp/myfilm.mov"))
(define mlgth (- (gfx:get-movie-duration movie) 1.0))
(define frame-length (* *second* 0.1))
(define font-style (gfx:make-text-style "Times-Roman" 120.0 (list 1.0 1.0 1.0 0.25)))
(define loop
(lambda (time mtime)
(let ((frame (gfx:get-movie-frame movie mtime))
(image (gfx:convert-image frame)))
(gfx:text2image (number->string mtime) image font-style '(10 0))
(gfx:draw-image time canvas image 1.0 '(0 0 600 600))
(set! time (+ time frame-length))
(objc:release time image frame)
(if (< mtime mlgth)
(callback (- time 4000) 'loop time (+ mtime 0.1))))))
(loop (now) 0.0)
; the loop will stop when the end of the movie is reached
(help gfx:get-movie-frame)