transparent image

how do I make an image become transparent? not the background but the image itself, there is a property or function for the onscreenimage? May I change the class?

I am using:

setTransparency(TransparencyAttrib.MAlpha)
setTransparency(True, 50)

doesn’t that work?

This makes not much sense:
setTransparency(TransparencyAttrib.MAlpha)
setTransparency(True, 50)

First you’re setting it to MAlpha (which maps to 1), then you’re setting it again with to True (which maps to 1 too, the same thing as MAlpha) but with override.

i think some thing like
setTransparency(True)
setColor(1,1,1,.5)
should work better

Keep in mind that passing “True” as value only works because there happens to be an MAlpha with the same value as True. There are many other transparency modes.

I think it was almost done on purpose this way :slight_smile:

It’s setAlphaScale().

Well, kind of, but not really. Originally the method did take a boolean, but then we extended it to take an enum instead. It’s been many many years since it took an enum (this change was before 1.0). I’d really prefer it if everyone switched to using an enum, including all example code, so we don’t have to be aware of always keeping the enum value MAlpha = 1.

setAlphaScale(0.5) is a shorthand for setColorScale(1, 1, 1, 0.5). Either will work fine. As will setColor(1, 1, 1, 0.5), though the latter will lose any per-vertex color on your model if you have it (most models don’t).

David

setTransparency(True) 
setColor(1,1,1,.5) 

that code worked, thank you guys!

pro-rsof would you explain a little bit that many other transparency modes that you mentioned? if possible

I wouldn’t be able to explain it better than this manual page:
panda3d.org/manual/index.php/T … d_Blending