MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / currentLineColor

Method currentLineColor

Components/WaitingSpinnerWidget.cpp:256–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256QColor WaitingSpinnerWidget::currentLineColor(int countDistance, int totalNrOfLines,
257 qreal trailFadePerc, qreal minOpacity,
258 QColor color) {
259 if (countDistance == 0) {
260 return color;
261 }
262 const qreal minAlphaF = minOpacity / 100.0;
263 int distanceThreshold =
264 static_cast<int>(ceil((totalNrOfLines - 1) * trailFadePerc / 100.0));
265 if (countDistance > distanceThreshold) {
266 color.setAlphaF(minAlphaF);
267 } else {
268 qreal alphaDiff = color.alphaF() - minAlphaF;
269 qreal gradient = alphaDiff / static_cast<qreal>(distanceThreshold + 1);
270 qreal resultAlpha = color.alphaF() - gradient * countDistance;
271
272 // If alpha is out of bounds, clip it.
273 resultAlpha = std::min(1.0, std::max(0.0, resultAlpha));
274 color.setAlphaF(resultAlpha);
275 }
276 return color;
277}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected