[Openmcl-devel] XFillPolygon

Ron Garret ron at flownet.com
Sun Mar 7 08:27:23 PST 2010


I don't see any reason to make this a macro instead of a function.

rg

On Mar 7, 2010, at 2:42 AM, Taoufik Dachraoui wrote:

> I found what is wrong in the code to fill a polygon, actually I had many errors in the code and I corrected it as follows:
> 
> (defmacro x/fillpolygon (points &key (shape #$Complex) (mode #$CoordModeOrigin))
> "points is a list of pairs, shape is one of Complex, Convex,  or Nonconvex, and
> mode is one of CoordModeOrigin or CoordModePrevious."
>     `(let ((i 0) (npoints (length ,points)))
>        (ccl::%stack-block ((xpoints (* (ccl::foreign-size :<XP>oint :bytes)
> 				       (1+ npoints))))
> 	 (dolist (p ,points)
> 	   (rlet ((xpoint :<XP>oint))
> 		 (setf (pref xpoint :<XP>oint.x) (car p))
> 		 (setf (pref xpoint :<XP>oint.y) (cadr p))
> 		 (setf (paref xpoints (:* :<XP>oint) i) xpoint)
> 		 (incf i)))
> 	 (#_XFillPolygon *display* 
> 			 (window *context*)
> 			 (graphics-context *context*)
> 			 xpoints
> 			 npoints
> 			 ,shape
> 			 ,mode
> 			 ))))
> 
> 
> Kind regards
> Taoufik
> 
> On Sun, Mar 7, 2010 at 9:50 AM, Taoufik Dachraoui <taoufik at mazeboard.com> wrote:
> Good Morning,
> 
> 
> I am trying to write x/fillpolygon macro (see below) to call XFillPolygon as defined below:
> 
> XFillPolygon(display, d, gc, points, npoints, shape, mode)
>       Display *display;
>       Drawable d;
>       GC gc;
>       XPoint *points;
>       int npoints;
>       int shape; 
>       int mode; 
> 
> 
> (defmacro x/fillpolygon (points &key (shape #$Complex) (mode #$CoordModeOrigin))
> "points is a list of pairs, shape is one of Complex, Convex,  or Nonconvex, and
> mode is one of CoordModeOrigin or CoordModePrevious."
>     `(rlet ((xpoints (:array :<XP>oint ,(length points))))
>        (let ((i 0))
> 	 (dolist (p ,points)
> 	   (rlet ((xpoint :<XP>oint))
> 		 (setf (pref xpoint :<XP>oint.x) (car p))
> 		 (setf (pref xpoint :<XP>oint.y) (cdr p))
> 		 (setf (paref xpoints (:array :<XP>oint ,(length points)) i) xpoint)
> 		 (incf i)))
> 	 (#_XFillPolygon *display* 
> 			 (window *context*)
> 			 (graphics-context *context*)
> 			 xpoints
> 			 ,(length points)
> 			 ,shape
> 			 ,mode
> 			 ))))
> 
> 
> I am not sure if I am correctly defining xpoints, what is the correct code to call #_XFillPolygon?
> 
> example of usage:
> 
> > (x/fillpolygon '((100 40) (140 50) (130 60)))
> 
> 
> Kind regards
> Taoufik
> 
> 
> 
> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20100307/9636eb38/attachment.htm>


More information about the Openmcl-devel mailing list