This article explains the relationship between #00ff00, 0x00ff00, and rgb(0, 255, 0)

I've been learning three.js recently, and I'm a little confused about the color settings, so I decided to study it.

First let’s look at two methods of setting color:

  • To set a color for objects in webgl and three.js, usecolor: 0x00ff00
  • To set a color in css, you can use color: #00ff00orrgba(0, 255, 0, 1)

What is the difference between the above three methods?

  • rgba(0, 255, 0, 1)It is easy to understand, it is an RGB color value;
  • #00ff00rgba(0, 255, 0, 1): Frequently used in CSS, it is a relatively common hexadecimal representation of color. It can be converted to this representation in multiple tools such as browser debugging tools ;
  • What is more difficult to understand 0x00ff00is that it is also a hexadecimal representation of color, but the #00ff00difference is: replace #00ff00the previous one #with 0x(here is the key point, the key point!!!) .

So, do you understand? No need to worry about 0x00ff00the representation of this color anymore. Use tools to get the #00ff00representation of the color you want, then #change it 0xand use it in webgl and three.js.

Finally, regarding the color value conversion tool:

These two are enough. Happy learning everyone!

Guess you like

Origin blog.csdn.net/qq_29517595/article/details/130291484