[plt-scheme] Help: Drawing polygons within world

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Dec 3 19:08:11 EST 2006

Use the force, Sertac, I mean the design recipe from chapter 6, and  
you'll be happy! Greetings to Dr Stephenson -- Matthias :-)


On Dec 2, 2006, at 3:23 PM, sertac gürtan wrote:

> Hi,
>
> 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
> ;;scene
> ;;lop: list of posns
> (define-struct world (scene lop))
>
> (define connect-dots
>  (lambda (w)
>    (cond
>      [(null? (cdr (world-lop w))) w]
>      [else
>       (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 advance!
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.