如何将动画作为图像对象

时间:2017-02-24 12:54:33

标签: image animation scheme racket

我可以使用" universe.rkt"来显示动画图像。 (https://docs.racket-lang.org/teachpack/2htdpuniverse.html?q=universe.rkt)有动画功能或大爆炸。

但是,如何将这些动画作为我可以放置在画布上的图像对象%对象(可能是多次),如下所示?

(define frame (new frame%
                   [label "Example"]
                   [width  500]
                   [height 500]))
(new canvas% [parent frame]
     [paint-callback
      (lambda (canvas dc)
        (send dc draw-bitmap (image->bitmap flowerImg) 20 20)  ; place image
        (send dc draw-bitmap (image->bitmap flowerImg) 200 200); place image
        )])
(send frame show #t)

image->位图函数来自https://lists.racket-lang.org/users/archive/2014-December/065110.html

(define (image->bitmap image)   
  (let* ([width (image-width image)]
         [height (image-height image)]
         [bm (make-bitmap width height)]
         [dc (send bm make-dc)])
    (send dc clear)
    (send image draw dc 0 0 0 0 width height 0 0 #f)
    bm))

flowerImg来自:https://docs.racket-lang.org/teachpack/2htdpimage.html

(define flowerImg
  (let ([petal (put-pinhole     
                20 20
                (ellipse 100 40 "solid" "purple"))])
    (clear-pinhole
     (overlay/pinhole
      (circle 30 "solid" "yellow")
      (rotate (* 60 0) petal)
      (rotate (* 60 1) petal)
      (rotate (* 60 2) petal)
      (rotate (* 60 3) petal)
      (rotate (* 60 4) petal)
      (rotate (* 60 5) petal)))))

目前,我正在使用外部程序将这些动画捕获为来自屏幕的视频并将其转换为gif文件,我可能将其视为图像并放置在画布上。

0 个答案:

没有答案