I'm using Pygame and I'm trying to make the background transparent instead of black,
something like wx.EVT_ERASE_BACKGROUND in wxpython, I did remove the borders (pygame.NOFRAME), so any clues?
Unfortunately, this is not possible. Pygame uses SDL, which does not allow seeing through windows to the desktop.
However if you use Linux, this answer may help you to create the illusion of transparency.
Related
For my pygame project, I must detect collision betweeen various .png image that move on the screen.
I have put the image inside sprite, and the sprite inside group, then I use this :
pygame.sprite.spritecollide(perso, zombie_group, False)
However, sometime, my image don't touch, but pygame detect a collision...
This is due to the fact that my images are png with transparent borders.
The transparent border collide, and pygame detect this :(
Any idea to stop the transparent border from colliding ?
Ok the sprite will take the image he can't detect if it was on a trasnparent BG or a color bg, he basically is just seeing a rectangle right now.
If you are using irregular shapes and a rectangle approximation is not enough I would recommend using collide_mask also check masks it is probably what you want
update
Regarding performance from the tutorial :
There are other ways to do this, with ANDing sprite masks and so on,
but any way you do it in pygame, it’s probably going to be too slow.
For most games, it’s probably better just to do ‘sub-rect collision’ –
create a rect for each sprite that’s a little smaller than the actual
image, and use that for collisions instead. It will be much faster,
and in most cases the player won’t notice the inprecision.
I am trying to test things out lately with Sikuli and the use of an Image with a Transparant background.
For example with the Sikuli IDE we define:
Image_FireFox = ("FireFox.png")
Now I took that "FireFox.png" and I have adjusted it with Paint.NET to make the background transparant. And then I save it again to "FireFox.png", and I put the new .png in the map of where Sikuli orginaly placed it.
When I open the IDE again, that image appears to have a black background (and not transparant). And also the image is not recognized anymore by my Sikuli Script. If I open the image in Windows Viewer, the background is still transparant.
The idea behind it is to make the image better recognized, and then my script would not care if the background of the FireFox icon is white, red or whatever colour.
Does anyone know if there is a way that Sikuli can deal with images with a transparant background? So that finding an icon on the desktop goes better, and the background wouldn't matter anymore.
Sikuli (or should I say OpenCV core that's being used by it), does not care about the background of the image itself. What it does is just to scan the whole screen as it is, exactly as it appears to you. It is not aware of types of images or anything else, just pure visual appearance. Saying that, if your image remains unchanged since when you first created the pattern and you can uniquely detect it on the screen, that will work.
As far as I understand, this quite the opposite of what you're trying to do. Do not try to change the image background because if you do, everything that will become visible behind this image (due to transparency) will prevent Sikuli from detecting it rather than helping it. Keep in mind that Sikuli only deals with rectangular patterns, so anything which is other than rectangular image won't work.
In regards to the way it looks in IDE, I'm not sure. That might be as a result of not supporting images with transparent alpha channel. You can try and ask this question on Sikuli official forum here.
its time to add an updated answer.
as of the current state sikuli has been replaced with sikulix. and sikulix can now deal with transparent or even masked images quiet well.
see here link
Is it possible to get gradient color in frame which created in ttk in tcl.
You can only get a gradient color if you:
Use a gradient color on OSX Aqua, which has a more sophisticated coloring scheme that Tk plugs into partially, or
Use a style that paints the background using a photo image that has a gradient in it, or
Write a custom style engine that does everything itself.
The first is very platform specific (and I don't know the details), the second is taking you into the complex world of custom image styles, and the third involves deep voodoo that is definitely beyond what I know!
I am working on a dutch site and i am having a problem with the logo of it.
I saved the logo as PNG24 sothat the characters "hvb" in the logo will be transparent.
for some odd reason, it shows the characters in plain old white.
Could somebody please tell me how this is possible.
By the way: it is not caused by the h1 tag it is wrapped around.
http://www.luukratief-design.nl/wp/
Help would be appreciated
EDIT:
I have never seen this befor, but you guys where right! The image HAS indeed have white letters!
The odd part about it is that the layers were hidden, so they look transparent in photoshop. Once i used save for web and exported it to png, all of a sudden they are white. Take a look at the screeny:
The solution:
As stupid as it sounds, i deleted the white layers (which werent even visible), and exported it again. As you can see it works now.
I can only choose 1 right answer, so i will choose the first guy who pointed this out. Thanks guys. Still strange, but thanks!
The letters are white in the image file.
The logo appears to have transparency for me. I am using Chrome.
Also transparency with PNGs does not work in IE6 or older without some javascript fiddling.
See: http://code.google.com/p/ie7-js/
I made the simple change for you and made the letters transparent. You can use it all you like. No charge! ;)
EDIT: Obviously you can do a much better job if you take a bit of time, but editing in image editing software is the only way for them to be transparent.
Seeing as the "h" of hvb has a nice flick at the end, surely its not meant to be transparent?!
When I change background to black, letters are white. There is no problem with implementation to site, I think problem is in image file.
I had difficulty with comprehension questions, second option:
Also if you using IE, and you have problems with transparent image corners and edges, use js code to fix it.
And if you want that letters be transparent, u need to edit image file with Adobe Ilustrator, or Photoshop or with somethnig else, what you using.
Link: IE Transparency
I have a div, and I would like to create a background for it in the in the following manner. The top half must be a solid colour, and the bottom half a semi transparent colour?
How do I go about creating this? making it work in all the major browsers? without splitting up the div into two separate ones.
I am being told this cannot be done but there must be some kind of dirty, hackerish way to do it.
Can someone please point me in the correct direction? or suggest some alternatives? all help is greatly appreciated. Thanks.
Use a transparent PNG as the background image. Make it very large but thin so you can tile it.
I am being told this cannot be done but there must be some kind of dirty, hackerish way to do it.
Three words: IE6.
If you can get it to work there, you can get it to work anywhere!
I would suggest writing an on-the-fly image creator that creates just the right transparent image for the page and renders it in such a way that IE6 supports the transparency of the image. You could certainly use almost any language that supports image manipulation or command-line callout to do that, it just won't be fast. Then you could use that generated image to achieve your goals.
That would be a dirty hackerish way to do it.
I also would shower twice with bleach after writing such an abomination. But that's just me.