Merge pull request #190 from openscad/colorwarn

color>1.0 warning (color([255,0,0]) per Joel Bodenmann rept to mail list
felipesanches-svg
Marius Kintel 2012-08-27 20:29:15 -07:00
commit 0e9d66f532
1 changed files with 4 additions and 1 deletions

View File

@ -64,8 +64,11 @@ AbstractNode *ColorModule::evaluate(const Context *ctx, const ModuleInstantiatio
Value v = c.lookup_variable("c");
if (v.type() == Value::VECTOR) {
for (size_t i = 0; i < 4; i++)
for (size_t i = 0; i < 4; i++) {
node->color[i] = i < v.toVector().size() ? v.toVector()[i].toDouble() : 1.0;
if (node->color[i] > 1)
PRINTB_NOCACHE("WARNING: color() expects numbers between 0.0 and 1.0. Value of %.1f is too large.", node->color[i]);
}
} else if (v.type() == Value::STRING) {
std::string colorname = v.toString();
boost::algorithm::to_lower(colorname);