;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;

;; THROBING TEXT

;;

;;  This example illustrates how to do text transformation

;;  by converting a text into a path. It also deomstrates

;;  some path transformations also.

;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(define canvas (gfx:make-canvas 800 600))

(define text-style (gfx:make-text-style "Times-Roman" 72.0 (list 1.0 1.0 1.0 0.25)))

(define text-path (gfx:make-path))

; make the text into a path

(gfx:set-start-point text-path 150 250)

(gfx:add-text text-path text-style "impromptu")


; start with a clean cavas

(gfx:clear-canvas (now) canvas '(0.1 0.1 0.27 1))


(define throb

   (lambda (time path val)

      ; wipe out a bit of the previous drawing

      (gfx:clear-canvas time canvas '(0.1 0.1 0.27 0.09))

      ; display the text-path

      (gfx:draw-path (+ time 1) canvas path

                 '(0.5 0.7 0.9 0.3)

                 '(0.0 0.9 0.2 0.1) 4)

      ; shift the text-path rotation one degree

      (gfx:rotate-path (now) path 1 300 253 *degrees*)

      ; change the size of the text-path

      (gfx:scale-path (+ time 2) path val val *gfx:centre-scale*)

      ; repeat the process with slightly changed values

      (callback (+ time 1000) 'throb (+ time 3000) path

                (if (> val 1.2) 0.8 (+ val 0.025)))))



(define stop

   (lambda ()

      (set! throb '())))


; start

(throb (now) text-path 0.8)