YannThorimbert / Thorpy

A GUI library for Pygame
http://www.thorpy.org
Other
31 stars 5 forks source link

Cannot use transparency with image buttons #7

Closed madhan001 closed 3 years ago

madhan001 commented 3 years ago

Hi, Thank you for this library. I'm trying to use an image with rounded corners as a button using the make_image_button function and I'm unable to use them without having black colour in the areas that need to be transparent. I tried setting the alpha parameter to 0 and that doesn't seem to help it.

I'm using version 1.9 of Thorpy with Pygame 2.0 and python 3.6 on ubuntu 18.04.

Screenshot from 2021-04-10 21-18-29

This is what the transparent corner looks like

YannThorimbert commented 3 years ago

Hi,

The expected behaviour is that black is interpreted as transparent if you give the argument colorkey=(0,0,0) when instantiating the button. If this does not work, could you provide the bit of code that poses problem ? Thanks, Yann

madhan001 commented 3 years ago

Hi,

The expected behaviour is that black is interpreted as transparent if you give the argument colorkey=(0,0,0) when instantiating the button. If this does not work, could you provide the bit of code that poses problem ? Thanks, Yann

Thanks, setting colorkey=(255,255,255) worked. May I know what exactly does this parameter do ?

YannThorimbert commented 3 years ago

It has the same effect as calling set_colorkey(some_color) method on the button's image. See https://www.pygame.org/docs/ref/surface.html#pygame.Surface.set_colorkey for more details.

madhan001 commented 3 years ago

Thank you for assisting me. Closing this issue