shape: center node
This commit is contained in:
@@ -415,7 +415,7 @@ void TransformDistortNode::DrawGizmos(const NodeValueRow &row, const NodeGlobals
|
||||
|
||||
// Get the sequence resolution
|
||||
const QVector2D &sequence_res = globals.resolution();
|
||||
QVector2D sequence_half_res = sequence_res/2;
|
||||
QVector2D sequence_half_res = sequence_res * 0.5;
|
||||
QPointF sequence_half_res_pt = sequence_half_res.toPointF();
|
||||
|
||||
// GizmoTraverser just returns the sizes of the textures and no other data
|
||||
@@ -488,7 +488,7 @@ void TransformDistortNode::DrawGizmos(const NodeValueRow &row, const NodeGlobals
|
||||
|
||||
// Use offsets to make the appearance of values that start in the top left, even though we
|
||||
// really anchor around the center
|
||||
SetInputProperty(kPositionInput, QStringLiteral("offset"), sequence_res * 0.5);
|
||||
SetInputProperty(kPositionInput, QStringLiteral("offset"), sequence_half_res);
|
||||
SetInputProperty(kAnchorInput, QStringLiteral("offset"), tex_sz * 0.5);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,4 +79,11 @@ void ShapeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, Nod
|
||||
table->Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
|
||||
}
|
||||
|
||||
void ShapeNode::DrawGizmos(const NodeValueRow &row, const NodeGlobals &globals, QPainter *p)
|
||||
{
|
||||
// Use offsets to make the appearance of values that start in the top left, even though we
|
||||
// really anchor around the center
|
||||
SetInputProperty(kPositionInput, QStringLiteral("offset"), globals.resolution() * 0.5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,13 @@ public:
|
||||
virtual ShaderCode GetShaderCode(const QString& shader_id) const override;
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
|
||||
virtual bool HasGizmos() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void DrawGizmos(const NodeValueRow &row, const NodeGlobals &globals, QPainter *p) override;
|
||||
|
||||
static QString kTypeInput;
|
||||
|
||||
private:
|
||||
|
||||
@@ -32,7 +32,7 @@ QString ShapeNodeBase::kColorInput = QStringLiteral("color_in");
|
||||
|
||||
ShapeNodeBase::ShapeNodeBase()
|
||||
{
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(10, 10));
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
AddInput(kSizeInput, NodeValue::kVec2, QVector2D(100, 100));
|
||||
AddInput(kColorInput, NodeValue::kColor, QVariant::fromValue(Color(1.0, 0.0, 0.0, 1.0)));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ uniform vec2 resolution_in;
|
||||
uniform vec4 color_in;
|
||||
|
||||
void main() {
|
||||
vec2 real_position = pos_in/resolution_in;
|
||||
vec2 p = pos_in + resolution_in*0.5 - size_in*0.5;
|
||||
|
||||
vec2 real_position = p/resolution_in;
|
||||
vec2 real_size = size_in/resolution_in;
|
||||
|
||||
vec4 col = vec4(0.0);
|
||||
@@ -23,7 +25,7 @@ void main() {
|
||||
col = color_in;
|
||||
}
|
||||
} else if (type_in == SHAPE_ELLIPSE) {
|
||||
vec2 center = pos_in+size_in*0.5;
|
||||
vec2 center = p+size_in*0.5;
|
||||
float radius = size_in.y*0.5;
|
||||
float aspect_ratio = size_in.x/size_in.y;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user