(gfx:draw-image time canvas image alpha [dest-bounds] [src-bounds])


Draw image to canvas with an alpha transparency between 0 and 1.  Optional destination bounds and source bounds can be added (defaults to source size at destination coordinate 0,0).  Source and destination bounds will resize image if required.


          alpha -- the amount of transparency to apply between 0 and 1

     src-bounds -- optional bounds to take image data from.  of list form (x y w h) where w and h are optional

          image -- image to draw (can be either an nsimage or a ciimage)

         canvas -- canvas to draw to

           time -- time in samples to draw image to canvas

    dest-bounds -- optional bounds to draw image into. of list form (x y w h) where w and h are optional

Returns: boolean

Related: gfx:draw-path gfx:draw-group 


(define canvas (gfx:make-canvas))

; make sure you set the string to a movie location on your system

(define movie (gfx:load-movie "/tmp/"))

(define frame-length (* *second* 0.041))

(define mlgth (- (gfx:get-movie-duration movie) 1.0))

(define loop

   (lambda (time mtime)

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

         (gfx:draw-image time canvas image 0.5 (list (random -100 500) 

                                                     (random -100 500)

                                                     (random 0 500)

                                                     (random 0 500)))

         ; advance time by a 24th of a second

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

         (if (< mtime mlgth)

             (callback (- time 1500) 'loop time (+ mtime 0.041))))))

(loop (now) 0.0)

Back to index