mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 19:58:15 +02:00
Canvas commands very nearly working, build broken
This commit is contained in:
parent
d502a292b7
commit
9701dce201
3 changed files with 25 additions and 7 deletions
|
@ -134,8 +134,9 @@ void CanvasEntityItem::paintCommands(const QVector<CanvasCommand>& queue) {
|
|||
|
||||
case V::SetColor: {
|
||||
auto props = cmd._setColor;
|
||||
pen.setColor(props.color);
|
||||
brush.setColor(props.color);
|
||||
auto color = QColor(props.color[0], props.color[1], props.color[2], 255);
|
||||
pen.setColor(color);
|
||||
brush.setColor(color);
|
||||
p.setPen(pen);
|
||||
p.setBrush(brush);
|
||||
break;
|
||||
|
|
|
@ -52,7 +52,7 @@ ScriptValue canvasCommandToScriptValue(ScriptEngine* engine, const CanvasCommand
|
|||
|
||||
case Variant::SetColor: {
|
||||
auto props = cmd._setColor;
|
||||
obj.setProperty("color", u8vec3ColorToScriptValue(engine, glm::u8vec3(props.color.red(), props.color.green(), props.color.blue())));
|
||||
obj.setProperty("color", u8vec3ColorToScriptValue(engine, props.color));
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ bool canvasCommandFromScriptValue(const ScriptValue& object, CanvasCommand& cmd)
|
|||
if (!u8vec3FromScriptValue(object.property("color"), c)) { return false; }
|
||||
|
||||
// FIXME: we have a script RGB color type but not an RGBA one
|
||||
cmd.set(CanvasCommand::SetColor { QColor(c[0], c[1], c[2], 255) });
|
||||
cmd.set(CanvasCommand::SetColor { c });
|
||||
} else if (type == static_cast<uint>(Variant::SetHints)) {
|
||||
cmd.set(CanvasCommand::SetHints {
|
||||
static_cast<CanvasCommand::RenderHint>(object.property("hints").toVariant().toUInt())
|
||||
|
@ -368,8 +368,7 @@ ScriptValue canvasImageToScriptValue(ScriptEngine* engine, const CanvasImage& im
|
|||
bool canvasImageFromScriptValue(const ScriptValue& object, CanvasImage& img) {
|
||||
img.width = object.property(IMG_WIDTH_PROP_NAME).toVariant().toUInt();
|
||||
img.height = object.property(IMG_HEIGHT_PROP_NAME).toVariant().toUInt();
|
||||
img.buffer = object.property(IMG_BUFFER_PROP_NAME).toVariant().toByteArray();
|
||||
return true;
|
||||
return qBytearrayFromScriptValue(object.property(IMG_BUFFER_PROP_NAME), img.buffer);
|
||||
}
|
||||
|
||||
CanvasImage canvasImageFromScriptValue(const ScriptValue& object) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define hifi_CanvasCommand_h
|
||||
|
||||
#include "ScriptValue.h"
|
||||
#include "ScriptValueUtils.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
|
@ -63,7 +64,7 @@ public:
|
|||
|
||||
struct Invalid {};
|
||||
struct SetStrokeWidth { qreal width; };
|
||||
struct SetColor { QColor color; };
|
||||
struct SetColor { glm::u8vec3 color; };
|
||||
struct SetHints { RenderHint hints; };
|
||||
struct SetBlendMode { QPainter::CompositionMode mode; };
|
||||
struct SetFont { QString family; int size; int weight; bool italic; };
|
||||
|
@ -242,6 +243,23 @@ private:
|
|||
Variant _tag;
|
||||
};
|
||||
|
||||
class CanvasCommandFactory : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static CanvasCommand setStrokeWidth(qreal width) {
|
||||
return CanvasCommand(CanvasCommand::SetStrokeWidth { width });
|
||||
}
|
||||
|
||||
static CanvasCommand setColor(glm::u8vec3 color) {
|
||||
return CanvasCommand(CanvasCommand::SetColor { color });
|
||||
}
|
||||
|
||||
static CanvasCommand setHints(uint hints) {
|
||||
return CanvasCommand(CanvasCommand::SetHints { static_cast<CanvasCommand::RenderHint>(hints) });
|
||||
}
|
||||
};
|
||||
|
||||
void registerCanvasMetaTypes(ScriptEngine *engine);
|
||||
|
||||
Q_DECLARE_METATYPE(CanvasCommand)
|
||||
|
|
Loading…
Reference in a new issue