summaryrefslogtreecommitdiff
path: root/src/transform.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/transform.cc')
-rw-r--r--src/transform.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/transform.cc b/src/transform.cc
index e841ef0..7b15a7e 100644
--- a/src/transform.cc
+++ b/src/transform.cc
@@ -91,7 +91,7 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti
argnames = QVector<QString>() << "m";
}
if (type == COLOR) {
- argnames = QVector<QString>() << "c";
+ argnames = QVector<QString>() << "c" << "alpha";
}
Context c(ctx);
@@ -227,6 +227,24 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti
if (v.type == Value::VECTOR) {
for (int i = 0; i < 4; i++)
node->m[16+i] = i < v.vec.size() ? v.vec[i]->num : 1.0;
+ } else if (v.type == Value::STRING) {
+ QString colorname = v.text;
+ QColor color;
+ color.setNamedColor(colorname);
+ if (color.isValid()) {
+ node->m[16+0] = color.redF();
+ node->m[16+1] = color.greenF();
+ node->m[16+2] = color.blueF();
+ } else {
+ PRINTF_NOCACHE("WARNING: Color name \"%s\" unknown. Please see",v.text.toUtf8().data());
+ PRINTF_NOCACHE("WARNING: http://en.wikipedia.org/wiki/Web_colors");
+ }
+ }
+ Value alpha = c.lookup_variable("alpha");
+ if (alpha.type == Value::NUMBER) {
+ node->m[16+3] = alpha.num;
+ } else {
+ node->m[16+3] = 1.0;
}
}
contact: Jan Huwald // Impressum