(module world mzscheme
(require (lib "unit.ss")
(rename (lib "htdp-beginner.ss" "lang") world:image? image?)
(prefix world: (lib "world.ss" "htdp"))
(prefix posn: (lib "posn.ss" "lang"))
(file "posn.scm"))
(require-for-syntax "../modular/expansion/proof-syntax.scm")
(define (acl2? f) (lambda args (if (apply f args) 't '())))
(define-signature teachpack^
[empty-scene place-image add-line
make-color color-red color-green color-blue color?
image-color? mode?
image?
rectangle circle text triangle line
image-width image-height overlay overlay/xy
put-pinhole move-pinhole pinhole-x pinhole-y
end-of-time
bytep
image-inside? find-image image->color-list color-list->image
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)
(make-event
stx
#'(begin (world:on-tick-event (lambda (w) (cb-name w))) 't))]))
(lambda (stx)
(syntax-case stx ()
[(_ cb-name)
(make-event
stx
#'(begin (world:on-key-event (lambda (k w) (cb-name k w))) 't))]))
(lambda (stx)
(syntax-case stx ()
[(_ cb-name)
(make-event
stx
#'(begin (world:on-redraw (lambda (w) (cb-name w))) 't))]))
(lambda (stx)
(syntax-case stx ()
[(_ cb-name)
(make-event
stx
#'(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)
(make-event
stx
#'(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 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 color-list->image world:color-list->image)
(define image->color-list world:image->color-list)
(define triangle world:triangle)
(define line world:line)
(define put-pinhole world:put-pinhole)
(define move-pinhole world:move-pinhole)
(define pinhole-x world:pinhole-x)
(define pinhole-y world:pinhole-y)
(define image-inside? (acl2? world:image-inside?))
(define bytep (acl2? byte?))
(define color? (acl2? world:color?))
(define image-color? (acl2? world:image-color?))
(define mode? (acl2? (lambda (x) (or (eq? x 'solid) (eq? x 'outline)))))
(define image? (acl2? (lambda (x) (world:image? x))))
(define (make-posn x y)
`(make-posn ,x ,y))
(define (find-image a b)
(let* ([p (world:find-image a b)])
(make-posn (posn:posn-x p) (posn:posn-y p))))
(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)
)