User Tools

Site Tools


en:tutorials:color:web_color_literals

Web Color Literals

Color literals have been added for all HTML web colors. The list can be modified/expanded directly inside the Color config section. These colors can be used for Object, Graphic and FX Color values (StartValue/EndValue when the Curve = color) as well as Viewport BackgroundColor.

The list of web colors can be found at: https://en.wikipedia.org/wiki/Web_colors#Extended_colors

All the colors are stored inside a config section named [Color], they can also be retrieved by the user or even modified/extended like this:

[Color]
MyShadeOfGrey = (100, 100, 100)

This would allow usage on an object, for example:

[MyObject]
Color = MyShadeOfGrey

All the official web colors have been added. Therefore you could use a color on an object like this:

[Object]
Color = PowderBlue

This is opposed to using an RGB color vector:

[Object]
Color = (176, 224, 230)

All the colors under section [Color], which can be extended/modified at will. And there also are vectors in the code source as well that match all the web colors. For example: orxVECTOR_POWDER_BLUE. You can find all these in:

orx\code\include\display\orxColorList.inc

Lower case and Pascal Case variants both work, with or without spaces. Therefore you can use combinations like:

  • LimeGreen
  • lime green
  • Lime Green

This won't work:

  • limeGreen
  • lime Green

Worth noting that this feature does not extend to shaders.

The issue being that in the case of Object, Graphic and FX, using a color literal is unambiguous.

But in the case of a shader, someone could be using a texture named “Black” or “White”, and instead of a texture with this name would become a vector instead. The safest approach in the case of shaders is to leave it explicit:

[ObjectMoon]
MoonColor   = @Color.blue
 
[Shader]
ParamList   = LightColor
LightColor  = @ObjectMoon.MoonColor

en/tutorials/color/web_color_literals.txt · Last modified: 2021/08/31 19:36 (3 years ago) by iarwain