2016-01-23 86 views
1

我想創建一個場景,並在該場景中顯示所有圖像。我瞭解如何用一個圖像創建場景。例如:需要關於DrRacket中的場景的一些幫助

(define HEIGHT 800) 

(define WIDTH 500) 

(define (sceneblank x) 

(place-image blank 400 400 (empty-scene WIDTH HEIGHT "black")) 

;blank being the image 

(animate sceneblank) 

但我怎麼能連續使用的地方圖像功能來對一個場景放置圖片?

回答

0

您可以使用嵌套函數在一個場景中放置多個圖像,像這樣:

(require 2htdp/image) 
(require 2htdp/universe) 

(define HEIGHT 800) 
(define WIDTH 500) 
(define BLANK-SCENE 
    (empty-scene WIDTH HEIGHT "black")) 

;; This function shows just the circle 
(define (add-circle x scene) 
    (place-image (circle 50 "solid" "red") x 400 scene)) 

;; This function shows just the square 
(define (add-square x scene) 
    (place-image (square 50 "solid" "blue") x 500 scene)) 

;; This shows both of them 
(define (circle+square x) 
    (add-circle x (add-square x BLANK-SCENE))) 

(animate circle+square)