Creating Color Patterns

### 3.8.3 Creating Color Patterns

We can do more than assigning a solid color to an object. We can create complex patterns in the pigment block like in these examples:

      sphere {
        <0, 1, 2>, 2
        texture {
          pigment {
            wood
            color_map {
              [0.0 color DarkTan]
              [0.9 color DarkBrown]
              [1.0 color VeryDarkBrown]
            }
            turbulence 0.05
            scale <0.2, 0.3, 1>
          }
          finish { phong 1 }
        }
      }

      sphere {
        <0, 1, 2>, 2
        texture {
          pigment {
            wood
            color_map {
              [0.0 color Red]
              [0.5 color Red]
              [0.5 color Blue]
              [1.0 color Blue]
            }
            scale <0.2, 0.3, 1>
          }
          finish { phong 1 }
        }
      }

The keyword `wood` specifies a pigment pattern of concentric rings like rings in wood. For every position in POV-space, a pattern returns a float value in the range from zero to one. Values outside the zero to one range are ignored. The `color_map` specifies what color vector is assigned to that float value. In the first example the color of the wood blends from `DarkTan` to `DarkBrown` over the first 90% of the vein and from `DarkBrown` to `VeryDarkBrown` over the remaining 10%. In the second example the colors do not blend from one to an other, but change abrupt. The `turbulence` keyword slightly stirs up the pattern so the veins aren't perfect circles and the `scale` keyword adjusts the size of the pattern.

Most patterns are set up by default to give us one feature across a sphere of radius 1.0. A feature is very roughly defined as a color transition. For example, a wood texture would have one band on a sphere of radius 1.0. In this example we scale the pattern using the `scale` keyword followed by a vector. In this case we scaled 0.2 in the x direction, 0.3 in the y direction and the z direction is scaled by 1, which leaves it unchanged. Scale values larger than one will stretch an element. Scale values smaller than one will squish an element. A scale value of one will leave an element unchanged.