color operation

Syntax

  • color(hexValue)
  • color(red, green, blue)
  • color(red, green, blue, opacity)

Parameters

  1. hexValuestring
    Color to set, in the format "#rrggbb" or "#rrggbboo" (hex).
  2. redfloat (range[0.0, 1.0])
    Color to set in red components.
  3. greenfloat (range[0.0, 1.0])
    Color to set in green components.
  4. bluefloat (range[0.0, 1.0])
    Color to set in blue components.
  5. opacityfloat (range[0.0, 1.0])
    Color to set in opacity components.

Description

The color operation sets the color of the current shape's material. Input parameter values for red, green, blue, or opacity that are outside the range [0,1] are clamped to [0,1].

Note:

This command has the same effect as set(material.color.{ r | g | b }, val), it is a shortcut for convenience.

Related

Examples

Three ways to set a shape's color

Three ways to set a shape's color. The results are identical.

Lot-->
   extrude(20)
   split(x) { 2  : color("#ff0000") 
                   X
            | 2  : color(1, 0, 0) 
                   X 
            | 2  : set(material.color.r, 1.0) 
                   set(material.color.g, 0) 
                   set(material.color.b, 0) 
                   X }
Shape with color