patch: named colors

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

patch: named colors

donbright
Dear OpenSCAD,

Here is a patch to allow the color() command to use names as well as numbers.

Examples

The command color([1,0,0]) can be written as color("red")
The command color([0,1,0,0.4]), which includes alpha, can be written
as color("green,0.4")

Color names come from the 'SVG colors' via QColor. Please see
http://en.wikipedia.org/wiki/Web_colors#X11_color_names or
http://www.w3.org/TR/SVG/types.html#ColorKeywords

Notes

This patch prints a warning in the OpenSCAD Console if an unknown
color name is used.

QT prints a warning to stdout if an invalid color name is used.  Please see
http://bugreports.qt.nokia.com/browse/QTBUG-8656

An example .scad file showing most (all?) of the named colors is attached

Thank you

-DB

named_colors.diff (1K) Download Attachment
testcolornames.scad (10K) Download Attachment