Hello,
New to the list.
I have a bug!  Nice 'n' easy repro steps below.

The bounding box returned by draw.line is the wrong size when width>1.

For single occurrence:
import pygame
pygame.init( )
print pygame.version.ver
s= pygame.Surface( ( 20, 20 ) )
rec= pygame.draw.line( s,
    ( 255,0,0 ),
    ( 10, 16 ),
    ( 7, 0 ),
    2 )
s.fill( ( 0, 0, 0 ), rec )
print s.get_at( ( 7, 0 ) )

Since the rectangle returned by 'draw' was filled with 0, 'get_at'
should return 0.  It doesn't.  It returns green.  I am using WinXP
with 1.9.1release-svn2575 and Python2.5.

Repro code with random coordinates below:

import random as ran
import numpy as num
s.fill( ( 0, 0, 0 ) )
while 1:
    x1= ran.randint( 0, 20 )
    x2= ran.randint( 0, 20 )
    y1= ran.randint( 0, 20 )
    y2= ran.randint( 0, 20 )
    wid= ran.randint( 1, 2 )
    rec= pygame.draw.line( s, ( 255,0,0 ), ( x1, y1 ), ( x2, y2 ),
wid )
    sorig= pygame.surfarray.array2d( s )
    s.fill( ( 0, 0, 0 ), rec )
    sa= pygame.surfarray.pixels2d( s )
    if num.any( sa ):
        assert wid> 1
        print x1, y1, x2, y2, wid
        for x, y in zip( *sa.nonzero( ) ):
            print x, y, s.get_at( ( x, y ) )
            sa[ x, y ]= 2
        print num.where( sorig, 1, 0 )
        s.fill( 1, rec )
        print sa
        print
    s.fill( ( 0, 0, 0 ) )

Observe that 'wid' is always>1, so the return is correct when wid=1.
When 'sa' is printed, it contains '1' throughout the area of the
bounding box that 'draw.line' returns.  It contains '2' where the
pixels of the draw command placed the line.

Reply via email to