How to use Cesium Colors in html?

I have a Cesium Color defined in my js code . . .

const myColor = Cesium.Color.fromBytes(120, 149, 232, 180);

I would like to use that color in my background div . . .

document.getElementById("myDiv").style.backgroundColor = myColor;

That doesn’t work, so I have to do this . . .

document.getElementById("myDiv").style.backgroundColor = "rgba(120, 149, 232, 180)";

I would like a better way to do this.

Hi @tzgardner,

you can use the method toCssColorString

Here is a simple example Cesium Sandcastle

1 Like

That’s exactly the thing I was hoping for! Thanks!

1 Like