gfx:draw-text

(gfx:draw-text time canvas string font-style bounds)


Description:

Draw string to canvas using font-style at bounds


Arguments:

         bounds -- a list of '(x y) or '(x y w h)

         canvas -- the canvas to draw to

     font-style -- the font-style to use

           time -- time in samples to draw string

         string -- the string to draw


Returns: boolean


Related: gfx:text2image gfx:add-text 


Examples:

(define canvas (gfx:make-canvas))


; 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" 250.0 (list 1.0 1.0 1.0 0.25)))


(define loop

   (lambda (time mtime)

      (let ((image (gfx:get-movie-frame movie mtime)))

         ;; to avoid slight flicker use the text2image line below instead of

         ; the draw-text line. It will composit the text and image before

         ; drawing to the screen.

         ; (gfx:text2image (number->string mtime) image font-style '(0 120))

         (gfx:draw-image time canvas image 1.0)

         (gfx:draw-text time canvas (number->string mtime) font-style '(0 120))

         (set! time (+ time frame-length))

         (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



Back to index