[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] draw.line bounding box bug when width>1
I finally got an Ubuntu - compiling is easy now :-)
Last patch didn't work, there where syntax/logic problems with { and }.
I have got a new patch for you that compiled and works as expected (try
my demo of the bug: http://python.pastebin.com/f2292e1d9)
I accidentally pastebined the diff, so I might just post a link:
http://python.pastebin.com/f2228be1c
Because I don't know how to do that, there is no unit test.
my diff is also attached to this email
Rolf Sievers
Lenard Lindstrom schrieb:
Thanks Rolf,
There is definitely a problem with pygame.draw.line and I will give
your patch a try. What is missing is a good unit test to define the
expected behavior. I will write one up.
Lenard Lindstrom
Rolf Sievers wrote:
I just realized that won't work - I didn't exchange the line ends
properly
try this patch
Rolf Sievers schrieb:
meh...
I guess I can make a patch even if I can't compile. Some work for my
little Tortoise.
Could someone with a compiler tell me if it works?
I used a temp variable here and fixed a line that was broken in my
last mail.
Index: draw.c
===================================================================
--- draw.c (Revision 2687)
+++ draw.c (Arbeitskopie)
-678,14 +678,29 @@
{
int loop;
int xinc=0, yinc=0;
+ int temp;
int newpts[4];
int range[4];
int anydrawn = 0;
if(abs(pts[0]-pts[2]) > abs(pts[1]-pts[3]))
+ {
yinc = 1;
+ if(pts[1]>pts[3])
+ {
+ temp = pts[0]; pts[0] = pts[2]; pts[2] = temp;
+ temp = pts[1]; pts[1] = pts[3]; pts[3] = temp;
+ }
+ }
else
+ {
xinc = 1;
+ if(pts[0]>pts[2])
+ {
+ temp = pts[0]; pts[0] = pts[2]; pts[2] = temp;
+ temp = pts[1]; pts[1] = pts[3]; pts[3] = temp;
+ }
+ }
memcpy(newpts, pts, sizeof(int)*4);
if(clip_and_draw_line(surf, rect, color, newpts))