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

Re: [pygame] How does pygame.draw.rect border width work?



Yann's method is the way to go!

Virus-free. www.avast.com

On 3 November 2017 at 11:25, Zexx Moore <xxn2theredxx@xxxxxxxxx> wrote:
Thank you Luke, for your reply.  I find it funny I never thought about doing it like Yann suggested, but I've implemented it and it works as I thought it the original should have. 

On Thu, Nov 2, 2017 at 10:32 PM, Luke Paireepinart <rabidpoobear@xxxxxxxxx> wrote:
I think this happens because the border is drawn with line segments between discrete points so the corners never get filled in for widths above 1. I remember running into this in the past and I solved it the same way, using stacked rects.

On Nov 2, 2017 9:25 AM, "Zexx Moore" <xxn2theredxx@xxxxxxxxx> wrote:
Thanks for the reply Yann. 

I had figured my math was wrong, but it seemed pretty basic to me.  You did give me an alternative, which is going to be much easier then what I had been trying to do. 

My thinking now is that I can draw three solid rects, one that will be the border, another rect for the inside background color, and a third rect for the percent bar. 

This is going to be a much easier approach and one that I feel will not break like the previous one. 

Thanks for the idea Yann. 

On Thu, Nov 2, 2017 at 7:38 AM, Yann Thorimbert <Yann.Thorimbert@xxxxxxxx> wrote:

Hello,


When I need a true border, I simply draw two rects, the seconde one hiding the first one in such a way that the rest of the first one constitutes the border.

I don't know why the default behaviour of draw.rect() is this strange border for width bigger than 1.


Cheers,


Yann


De : owner-pygame-users@xxxxxxxx <owner-pygame-users@xxxxxxxx> de la part de N2TheRed <xxn2theredxx@xxxxxxxxx>
Envoyé : jeudi, 2 novembre 2017 13:25:51
À : pygame-users@xxxxxxxx
Objet : [pygame] How does pygame.draw.rect border width work?
 
I've been trying to make a percent bar class that I can use to represent
health or speed, but the border width is causing issues. 

The goal is to make an outer rectangle frame of a specified border width
while using a solid rect inside it to represent a percentage. 

<http://pygame-users.25799.x6.nabble.com/file/t429/Screenshot_%2812%29.png>

In the picture above, I pass in a border width of 1 for the outer rect frame
with a width of 300 and a height of 50.  At least in the picture above, it
seems to work out find.

<http://pygame-users.25799.x6.nabble.com/file/t429/Screenshot_%2813%29.png>

In that picture, I pass in all the same values except for a width of 10
instead of 1.  This time, it breaks and I've been unable to figure out why. 

<http://pygame-users.25799.x6.nabble.com/file/t429/Screenshot_%2814%29.png>



--
Sent from: http://pygame-users.25799.x6.nabble.com/





--
http://www.diliupg.com

**********************************************************************************************
This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.
**********************************************************************************************