MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setVertexColor

Function setVertexColor

app/src/UI/Widgets/PlotCurve.cpp:42–57  ·  view source on GitHub ↗

* @brief Encodes a premultiplied vertex color for QSGVertexColorMaterial. */

Source from the content-addressed store, hash-verified

40 * @brief Encodes a premultiplied vertex color for QSGVertexColorMaterial.
41 */
42static void setVertexColor(QSGGeometry::ColoredPoint2D& vertex,
43 const float x,
44 const float y,
45 const QColor& color,
46 const double alpha)
47{
48 Q_ASSERT(alpha >= 0.0);
49 Q_ASSERT(alpha <= 1.0);
50
51 vertex.set(x,
52 y,
53 static_cast<unsigned char>(std::lround(color.redF() * alpha * 255.0)),
54 static_cast<unsigned char>(std::lround(color.greenF() * alpha * 255.0)),
55 static_cast<unsigned char>(std::lround(color.blueF() * alpha * 255.0)),
56 static_cast<unsigned char>(std::lround(alpha * 255.0)));
57}
58
59/**
60 * @brief Computes the unit direction between two pixel-space points; returns false for

Callers 2

emitCapSectionFunction · 0.70
emitFanFunction · 0.70

Calls 2

lroundFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected