411 REFERENCE · Wikibooks
OpenSCAD User Manual/First Steps/Changing the color of an object
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
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.
changing the colors works only in Preview mode (F5); render mode (F6) does not currently support color
Usage example 1 - changing the color of an object:color([1,0,0])
cube([2,3,4]);
translate([3,0,0])
color([0,1,0])
cube([2,3,4]);
translate([6,0,0])
color([0,0,1])
cube([2,3,4]);thumb|150px|OpenSCAD changing the color of an object
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.
OpenSCAD_User_Manual/First_Steps/Positioning_an_object Positioning an object OpenSCAD User Manual/First Steps/Model views First Steps: Model views OpenSCAD User Manual/First Steps First Steps
ru:Руководство пользователя по OpenSCAD/Первые шаги/Изменение цвета объекта