OpenSCAD User Manual/First Steps/Changing the color of an object
Appearance
Any object, or a group of them, may be colored by preceding the object module call with the color() operator module.
There are two ways to specify the color to set:
- RGB vector
- three floats in the range [0.0:1.0] in a three element vector [<redval>,<greenval>,<blueval>]
- "<colorname>"
- a string containing a color name from the list of Web Colors.
A color() operator may be included, the same as any other operator, like translate(), in a stack of operators that precede call to an object module.
Using braces ("{}") to define a level of scope will apply color, or any other operator module, to all of the objects included in the scope
color([0,0,1]) {
translate([6,0,0])
cube([2,3,4]);
translate([-6,0,0])
cube([2,3,4]);
}
In a stack of operators the first call to color() overrides all others that come later.
