29.08.2013 Views

Grafik i Racket

Grafik i Racket

Grafik i Racket

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Grafik</strong>motorer VII<br />

(define (rotating-square x y)<br />

(let ((angle 0))<br />

(define (update)<br />

(set! angle (+ angle (/ 1 6.28))))<br />

(define (render canvas dc)<br />

(send dc translate x y)<br />

(send dc rotate angle)<br />

(send dc draw-rectangle -25 -25 50 50)<br />

(send dc rotate (- angle))<br />

(send dc translate (- x) (- y)))<br />

(define (dispatch cmd)<br />

(cond<br />

((eq? cmd 'update) update)<br />

((eq? cmd 'render) render)))<br />

dispatch))<br />

(set! *all-things* (cons (rotating-square 50 50)<br />

*all-things*))

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!