Fading a textcolor into another [SOLVED]

Hi all,

I’m a bit stuck when I try to fade the color of an object (in this case a onscreentext), into another colour.

I’m trying to make use of the following function, but couldn’t find anything about it to make it work for me, does anyone know how to use this function, or got a better solution ?

colorchange = LerpColorInterval(self.text.setColor,  color = (1,1,1,1), startColor = (0,0,0,0), bakeInStart=1, blendType = 'noBlend', name=None, float=None, duration = 4)
colorchange.start()

Using this code it will complain about a NodePath one time, and the other time about the duration, or float. I’m lost, I hope someone can help me. Many thanks in advance.

PS. It would be nice if it’s possible to get the starting colours with r,g,b,a or so, but I think that can be done with .getRedValue or something like that.

from pandac.PandaModules import VBase4
text = OnscreenText(text = "Panda3D", pos = (0.0, 0.0), scale = 0.1)
colorchange = LerpColorInterval(
	text,
	duration = 5.0,
	startColor = VBase4(0.0, 1.0, 0.0, 1.0), # green
	color = VBase4(1.0, 0.0, 0.0, 1.0), # red
)
colorchange.start()

or

colorchange = LerpColorInterval(
	text,
	duration = 5.0,
	startColor = VBase4(0.0, 0.0, 1.0, 1.0), # blue visible
	color = VBase4(0.0, 0.0, 1.0, 0.0), # blue invisible
)

Hope that helps, Azraiyl

Sorry for the late reply, but this works perfectly ! Exactly what I was looking for, and then some :slight_smile:. Thank you for much !