question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

return string on color.getHex()?

See original GitHub issue

Hello, First of all I’m absolutely loving Three.js, so thank you ! So I think getHex() doesn’t quite do what I was expecting as it returns a decimal value.

For instance after using setHex(0xFFFFFF) getHex returns “16777215” which you have to process with toString(16) to get “FFFFFF” I’d suggest adding it in the prototype it would probably be more intuitive.

Cheers

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mrdoobcommented, Oct 17, 2012

In the editor we’re using '#' + color.getHex().toString(16) and seems to work fine.

1reaction
jbogpcommented, Oct 17, 2012

Yes, but then isn’t it weird to name the function getHex() when it doesn’t actually return an hexadecimal value ? In case anybody is wondering the good solution to get the hexadecimal value should be : ('000000'+color.getHex().toString(16)).slice(-6) to make sure eventual starting 0s are included.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using a HEX value from a color picker for three.js as a string
You can use the Color class (reference) from three.js. For example: var color = new THREE.Color("#FFA6A6"); // "FFA6A6" won't work! color.
Read more >
Color – three.js docs
Sets this color's components from the attribute. # .getHex ( colorSpace : string = SRGBColorSpace ) : Integer. Returns the hexadecimal value of...
Read more >
hex() / Reference / Processing.org
Converts an int, byte, char, or color to a String containing the equivalent hexadecimal notation. For example, the color value produced by color(0,...
Read more >
How to get hex code from color dialog always - MSDN
If you then want it as hex then use ToString("x8") to convert to a hex string of size 8. var colorString = colorDlg.Color.ToArgb()....
Read more >
RGB to HEX
Convert RGB color codes to HEX HTML format for use in web design and CSS. Also converts RGBA to HEX.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found