[plt-scheme] Help: Drawing polygons within world

From: sertac gürtan (s.gurtan at gmail.com)
Date: Sat Dec 2 15:23:47 EST 2006


I'm trying to write a program that draws a polygon from a list of posns by
using world.ss.  Here is my code so far:

(define scene (empty-scene 100 100))

;;example lop
(define a (cons (make-posn 10 10) (cons (make-posn 60 60) (cons (make-posn
10 60) empty))))

;;data definition world
;;lop: list of posns
(define-struct world (scene lop))

(define connect-dots
 (lambda (w)
     [(null? (cdr (world-lop w))) w]
      (and (place-image (add-line scene (posn-x (car (world-lop w))) (posn-y
(car (world-lop w))) (posn-x (second (world-lop w))) (posn-y (second
(world-lop w)))'black) 0 0 scene) (make-world (world-scene w) (cdr
(world-lop w))))])))

(big-bang 100 100 0.1 (make-world scene a))
(on-tick-event connect-dots)

This doesnt give me any errors but it doesnt appear to be doing anything
else either. It's supposed to draw lines by taking two posn values and then
repeating itself untill there is only one pair of posns. The result should
have been a triangle (since there are only 3 posn values) but instead the
canvas is blank. Hopefully you can help point out where I'm wrong, thanks in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20061202/beaf6337/attachment.html>

Posted on the users mailing list.