12QSGDefaultRectangleNode::QSGDefaultRectangleNode()
13 : m_geometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), 4)
15 QSGGeometry::updateColoredRectGeometry(&m_geometry, QRectF());
16 setMaterial(&m_material);
17 setGeometry(&m_geometry);
18 setColor(QColor(255, 255, 255));
19#ifdef QSG_RUNTIME_DESCRIPTION
20 qsgnode_set_description(
this, QLatin1String(
"rectangle"));
39void QSGDefaultRectangleNode::setColor(
const QColor &color)
41 if (color != m_color) {
43 color.getRgbF(&r, &g, &b, &a);
44 QSGGeometry::ColoredPoint2D *pts = m_geometry.vertexDataAsColoredPoint2D();
45 for (
int i = 0; i < 4; ++i) {
46 pts[i].r = uchar(qRound(r * a * 255));
47 pts[i].g = uchar(qRound(g * a * 255));
48 pts[i].b = uchar(qRound(b * a * 255));
49 pts[i].a = uchar(qRound(a * 255));
51 markDirty(QSGNode::DirtyGeometry);