Simple tool to convert Hexadecimal colors to BABYLON color code

Hi,

I created a simple tool to help to convert hexadecimal colors to the Babylon format, generating the code. As I use some color palletes like flatuicolors.com, it is very helpful for me.

I hope it can be helpful for you!

Thanks

9 Likes

Hi, nice work, but i’ll add that this is also supported directly in Babylon if you prefer hex :slight_smile:

BABYLON.Color3.FromHexString()

https://www.babylonjs-playground.com/#194GBT

7 Likes

@aWeirdo Wow, I did not know this one :smiley: Thanks man!!

in my case it didn’t work why???
did i something wrong??

  let pushButtonPulser = scene.getMaterialByName('Button');
  // pushButtonPulser.albedoColor = new BABYLON.Color3(211/255, 63/255, 5/255);
  pushButtonPulser.albedoColor = new BABYLON.Color3.FromHexString('#D33F05FF');

you need to remove the new cause BABYLON.Color3.FromHexString is a function

Incidentally, #D33F05FF - > #D33F05
is a 6-digit number, and when copying from the inspector, etc., it gets stuck with FF, so we need to remove that.

That’s because you are entering a Color4 value as Color3. Color3 has no alpha. So the last two digits (being the alpha) are set to opaque == FF.
And then, note that I found the inspector has some glitches (i.e. for the GUI) where eventually you cannot retrieve or enter a hex(a) value despite that it is supported (with code or through the editor).

2 Likes