[Image-SIG] Regarding Wide lines in PIL

rzed rzantow at ntelos.net
Wed May 25 03:16:16 CEST 2005


If I have the correct version of the PIL code, specifying the new width 
parameter to ImageDraw's line() function results in a line of twice the 
specified thickness. It appears to be because, in ImagingDrawWideLine 
(Draw.c), the width is both added to and subtracted from the line 
positions. If dx and dy were halved, the  specification should work 
correctly (within rounding limits, anyway).

     dx = (int) (d * (y1-y0) + 0.5);
     dy = (int) (d * (x1-x0) + 0.5);

     add_edge(e+0, x0 - dx,  y0 + dy, x1 - dx,  y1 + dy);
     add_edge(e+1, x1 - dx,  y1 + dy, x1 + dx,  y1 - dy);
     add_edge(e+2, x1 + dx,  y1 - dy, x0 + dx,  y0 - dy);
     add_edge(e+3, x0 + dx,  y0 - dy, x0 - dx,  y0 + dy);

To an extent, it can be worked around by halving the width 
specification, of course.

-- 
rzed


More information about the Image-SIG mailing list