m_clrRender calculation
Posted: Sat Jan 14, 2017 1:44 am
Hey guys,
I'm trying to set the color of an entity with its m_clrRender property.
The problem is, m_clrRender is not a Color type but int which needs to be calculated in order to get the right RGB color.
I found this old thread on eventscripts http://forums.eventscripts.com/viewtopic.php?t=17774 but the ES calculation does not work for me when I use it in SourcePython. When I compile the C version by GODJonez it works perfectly and gives me right values.
The values of the C version are mostly negative (all of those I tried yet) and the values I get through SP are all positve and always way to big and result in "OverflowError: Python int too large to convert to C long".
This is the calculation I use:
Edit: I want to change the color of an env_spritetrail. Using the already built in functions for setting colors did work but left a black border around the sprite of my trail. with m_clrRender this does not happen! Just to clarify why I want to use m_clrRender :)
I'm trying to set the color of an entity with its m_clrRender property.
The problem is, m_clrRender is not a Color type but int which needs to be calculated in order to get the right RGB color.
I found this old thread on eventscripts http://forums.eventscripts.com/viewtopic.php?t=17774 but the ES calculation does not work for me when I use it in SourcePython. When I compile the C version by GODJonez it works perfectly and gives me right values.
The values of the C version are mostly negative (all of those I tried yet) and the values I get through SP are all positve and always way to big and result in "OverflowError: Python int too large to convert to C long".
This is the calculation I use:
Code: Select all
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
a = 255
color = r + (g << 8) + (b << 16) + (a << 24)
Edit: I want to change the color of an env_spritetrail. Using the already built in functions for setting colors did work but left a black border around the sprite of my trail. with m_clrRender this does not happen! Just to clarify why I want to use m_clrRender :)