[plt-scheme] Help: Drawing polygons within world

From: Chris Stephenson (cs at cs.bilgi.edu.tr)
Date: Sat Dec 2 15:39:20 EST 2006

Sertac

The plt-scheme list is not the place for homework questions! Not from my
course.

I will post a reply to you on our comp-111-discuss which is where you
should really have posted your query.

Sorry folks.

CS

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.