(module world mzscheme
(require (lib "unit.ss")
(only (lib "htdp-beginner.ss" "lang")
image?)
(prefix world: (lib "world.ss" "htdp"))
(file "posn.scm"))
(define-signature teachpack^
[empty-scene place-image add-line
make-color color-red color-green color-blue color?
image-color?
rectangle circle text image-width image-height overlay overlay/xy
end-of-time
make-posn posn? weak-posn? posn-x posn-y
(define-syntaxes (on-tick-event on-key-event on-redraw on-mouse-event big-bang)
(values
(lambda (stx)
(syntax-case stx ()
[(_ cb-name) #'(begin (world:on-tick-event (lambda (w) (cb-name w))) 't)]))
(lambda (stx)
(syntax-case stx ()
[(_ cb-name) #'(begin (world:on-key-event (lambda (k w) (cb-name k w))) 't)]))
(lambda (stx)
(syntax-case stx ()
[(_ cb-name) #'(begin (world:on-redraw (lambda (w) (cb-name w))) 't)]))
(lambda (stx)
(syntax-case stx ()
[(_ cb-name) #'(begin (world:on-mouse-event
(lambda (w x y evt)
(cb-name w x y evt)))
't)]))
(lambda (stx)
(syntax-case stx ()
[(_ width height freq w0)
#'(begin (world:big-bang width height freq w0)
't)]
[_ (raise-syntax-error #f "big-bang is a procedure that expects 4 arguments" stx)]))))])
(provide teachpack^ teachpack@)
(define-unit teachpack@
(import)
(export teachpack^)
(define empty-scene world:empty-scene)
(define place-image world:place-image)
(define add-line world:add-line)
(define make-color world:make-color)
(define color-red world:color-red)
(define color-green world:color-green)
(define color-blue world:color-blue)
(define color? world:color?)
(define image-color? world:image-color?)
(define rectangle world:nw:rectangle)
(define circle world:circle)
(define text world:text)
(define image-width world:image-width)
(define image-height world:image-height)
(define overlay world:overlay)
(define overlay/xy world:overlay/xy)
(define end-of-time world:end-of-time)
(define (make-posn x y)
`(make-posn ,x ,y))
(define (posn? v)
(if (and (list? v)
(= (length v) 3)
(eq? (car v) 'make-posn)
(integer? (cadr v))
(integer? (caddr v)))
't
'()))
(define (weak-posn? v)
(if (and (list? v)
(= (length v) 3)
(eq? (car v) 'make-posn))
't
'()))
(define (posn-x p)
(cadr p))
(define (posn-y p)
(caddr p))
)
(define (acl2:big-bang width height freq w0)
(big-bang width height freq w0)
't)
)