Color4 properties

Is there a way to directly read and set individual properties of Color4 objects, other than just in the constructor?

I want to just tweak the alpha values of some colors, without touching the rgb values. Can I modify the values directly or do I need to do this by adding/subtracting/multiplying another color value to the original color?

Sorry if this is an obvious question but I’m relatively new to Babylon.js. So far I’m impressed.


edit: I tried just referencing them using dot notation but that doesn’t seem to work.

Hi @startledan and welcome to the forum

The answer is you can

color.r = 0.7; //from 0 to 1
color.g = 0.52 //from 0 to 1
color.b = 0.1 //from 0 to 1
color.a = 1.0 //from 0 to 1

OK, Thanks. I obviously tried that but it wasn’t working. I must have another error somewhere. Thanks for clarifying.

A playground ( is always helpful to help us help you :slight_smile: Maybe show how how you do it, and we can point out what the issue is.

1 Like