MarcelLendi-0d9
4 months agoCommunity Member
Help needed: Changing the color of an object with javascript
I like to create an object (e.g., a rectangle) and change its color using 3 sliders (RGB). I read the slider values into Javascript and calculate the Hexadecimal value. I found this calculation on https://learnersbucket.com/examples/interview/convert-rgb-to-hex-color-in-javascript/. )
var player = GetPlayer();
var RedValue = player.GetVar("SliderRed");
var GreenValue = player.GetVar("SliderGreen");
var BlueValue = player.GetVar("SliderBlue");
var HexValue = "#" + ((1 << 24) + (RedValue << 16) + (GreenValue << 8) + BlueValue).toString(16).slice(1);
Now I want to change my object to this HexValue. I don't know how to do the last step. Must be something like object.style.backgoundColor = HexValue
How do I assign a color to an object?