Jump to content

babylonjs brickProceduralTexture Color3 vs color string


dhiru
 Share

Recommended Posts

Hi, 

I have created labels that shows my objects on the top of the screen; however unfortunately the objects use brickProceduralTexture which take brick color as Babylon.Color3

 woodTexture.brickColor = new BABYLON.Color3(rColor / 255, gColor / 255, bColor / 255);

however I want to match that with the background color of my BABYLON.GUI.Rectangle; which takes the background as a Color; to avoid confusion I wanted to match the colors.

  var label = new BABYLON.GUI.Rectangle("label for scorecard");
  label.background = "black";

I am sure there is something simple I am missing -- I tried reading the documentation and also passing different colors but could not get it to work.

 

Please advise.

Link to comment
Share on other sites

There is a static method on Color3 for 0-255 numbers.  ie: Color3.FromInts(255, 255, 102)

To answer your question, for background you can use HEX representation.  ie: label.background = "#FFAF00"; for orange.  So, 255 to 'FF' is just Number(255).toString(16) in javascript (16 is the base).  Then just concatenate the 3 together `#${redHex}${greenHex}${blueHex}`, if you use string interpolation. Maybe there is something easier built-in to do that already, but I'm not aware of anything.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...