Previous:Vector Functions   Main Index   Next:Color Vectors

Specifying Colors

POV-Ray often requires you to specify a color. Colors consist of five values or color components. The first three are called `red`, `green`, and `blue`. They specify the intensity of the primary colors red, green and blue using an additive color system like the one used by the red, green and blue color phosphors on a color monitor.

The 4th component, called `filter`, specifies the amount of filtered transparency of a substance. Some real-world examples of filtered transparency are stained glass windows or tinted cellophane. The light passing through such objects is tinted by the appropriate color as the material selectively absorbs some frequencies of light while allowing others to pass through. The color of the object is subtracted from the light passing through so this is called subtractive transparency.

The 5th component, called `transmit`, specifies the amount of non-filtered light that is transmitted through a surface. Some real-world examples of non-filtered transparency are thin see-through cloth, fine mesh netting and dust on a surface. In these examples, all frequencies of light are allowed to pass through tiny holes in the surface. Although the amount of light passing through is diminished, the color of the light passing through is unchanged. The color of the object is added to the light passing through so this is called additive transparency.

Note that early versions of POV-Ray used the keyword `alpha` to specify filtered transparency. However that word is often used to describe non-filtered transparency. For this reason `alpha` is no longer used.

Each of the five components of a color are float values which are normally in the range between 0.0 and 1.0. However any values, even negatives may be used.

Under most circumstances the keyword `color` is optional and may be omitted. We also support the British or Canadian spelling `colour`. Colors may be specified using vectors, keywords with floats or identifiers. You may also create very complex color expressions from combinations of any of these using various familiar operators. The syntax for specifying a color has evolved since POV-Ray was first released. We have maintained the original keyword-based syntax and added a short-cut vector notation. Either the old or new syntax is acceptable however the vector syntax is easier to use when creating color expressions.

The syntax for combining color literals into color expressions is almost identical to the rules for vector and float expressions. In the syntax for vector expressions below, some of the syntax items are defined in the section for float expressions. See "Float Expressions" for those definitions. Detailed explanations of color-specific issues are given in the following sub-sections.

COLOR:
COLOR_BODY |
`color` COLOR_BODY | (this means the keyword `color` or `colour` may
`colour` COLOR_BODY optionally precede any color specification)
COLOR_BODY:
COLOR_VECTOR |
COLOR_KEYWORD_GROUP |
COLOR_IDENTIFIER
COLOR_VECTOR:
`rgb` <3_Term_Vector> |
`rgbf` <4_Term_Vector> |
`rgbt` <4_Term_Vector> |
[ `rgbft` ] <5_Term_Vector>
COLOR_KEYWORD_GROUP:
[ COLOR_KEYWORD_ITEM ]...
COLOR_KEYWORD_ITEM:
COLOR_IDENTIFIER |
`red` Red_Amount | `blue` Blue_Amount | `green` Green_Amount |
`filter` Filter_Amount | `transmit` Transmit_Amount

Note: COLOR_IDENTIFIERS are identifiers previously declared to have color values. The 3, 4, and 5 term vectors are usually vector literals but may be vector expressions or floats promoted to vectors. See "Operator Promotion" and the sections below.

Previous:Vector Functions   Main Index   Next:Color Vectors