[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Rect Behavior



Check if n == 1. If so, use line. =P

-Thiago

2010/5/17 ææåçää : linjunhalida <linjunhalida@xxxxxxxxx>:
> maybe Ian want to draw random rect, and n*1 is randomized and failed to
> show...
> so I suggest skip n*1 and use n*2 or n*3..
>
> On Mon, May 17, 2010 at 4:39 AM, Kris Schnee <kschnee@xxxxxxxxxx> wrote:
>>
>> On 2010.5.16 3:25 PM, Ian Mallett wrote:
>>>
>>> Hi,
>>>
>>> So, I've noticed that, when trying to draw a n*1 or 1*n rectangle (yes I
>>> know a line does the job too) with pygame.draw.rect(...), the behavior
>>> is different for different fills. ÂWhen the fill is 0, nothing draws!
>>> When the fill is 1, the desired rectangle is drawn. ÂIs this the
>>> expected behavior of pygame.draw.rect(...)?
>>>
>>> Thanks,
>>> Ian
>>
>> Probably because the rect function assumes a variable-width border. (
>> http://www.pygame.org/docs/ref/draw.html#pygame.draw.rect ) There's no
>> "fill" argument, only a "border width" argument. So if that's 0, Pygame
>> probably gets confused and draws 0 pixels of border, 0 of interior.
>>
>> Why not use pygame.draw.line if you only want one pixel width anyway?
>
>