我想在一个场景上创建一个包含所有图像的场景。我了解如何使用一个图像创建场景。例如:
(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 :(得分: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)