summaryrefslogtreecommitdiff
path: root/src/color.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-09-03 04:10:36 (GMT)
committerMarius Kintel <marius@kintel.net>2011-09-03 04:10:36 (GMT)
commit6f632190a05417d44193e3b16a7b3000b2cc1145 (patch)
tree9ddccef57c10361a7019274f79f1d86edb7630d3 /src/color.cc
parent3129189342f3da7322efa0b860ff3ff676ba7b77 (diff)
Ported a bunch of stuff from Qt to STL
Diffstat (limited to 'src/color.cc')
-rw-r--r--src/color.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/color.cc b/src/color.cc
index 7340612..c64745c 100644
--- a/src/color.cc
+++ b/src/color.cc
@@ -33,6 +33,8 @@
#include <sstream>
#include <assert.h>
#include <QColor>
+#include <boost/assign/std/vector.hpp>
+using namespace boost::assign; // bring 'operator+=()' into scope
class ColorModule : public AbstractModule
{
@@ -50,28 +52,28 @@ AbstractNode *ColorModule::evaluate(const Context *ctx, const ModuleInstantiatio
node->color[0] = node->color[1] = node->color[2] = -1.0;
node->color[3] = 1.0;
- QVector<QString> argnames;
- QVector<Expression*> argexpr;
+ std::vector<std::string> argnames;
+ std::vector<Expression*> argexpr;
- argnames = QVector<QString>() << "c" << "alpha";
+ argnames += "c", "alpha";
Context c(ctx);
c.args(argnames, argexpr, inst->argnames, inst->argvalues);
Value v = c.lookup_variable("c");
if (v.type == Value::VECTOR) {
- for (int i = 0; i < 4; i++)
+ for (size_t i = 0; i < 4; i++)
node->color[i] = i < v.vec.size() ? v.vec[i]->num : 1.0;
} else if (v.type == Value::STRING) {
- QString colorname = QString::fromStdString(v.text);
+ std::string colorname = v.text;
QColor color;
- color.setNamedColor(colorname);
+ color.setNamedColor(QString::fromStdString(colorname));
if (color.isValid()) {
node->color[0] = color.redF();
node->color[1] = color.greenF();
node->color[2] = color.blueF();
} else {
- PRINTA_NOCACHE("WARNING: Color name \"%1\" unknown. Please see", colorname);
+ PRINTF_NOCACHE("WARNING: Color name \"%s\" unknown. Please see", colorname.c_str());
PRINTF_NOCACHE("WARNING: http://en.wikipedia.org/wiki/Web_colors");
}
}
contact: Jan Huwald // Impressum