MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / color

Method color

3rdparty/qcustomplot/qcustomplot.cpp:16838–16869  ·  view source on GitHub ↗

! \internal This method is used to colorize a single data value given in \a position, to colors. The data range that shall be used for mapping the data value to the gradient is passed in \a range. \a logarithmic indicates whether the data value shall be mapped to a color logarithmically. If an entire array of data values shall be converted, rather use \ref colorize, for better performa

Source from the content-addressed store, hash-verified

16836 QImage::Format_ARGB32_Premultiplied).
16837*/
16838QRgb QCPColorGradient::color(double position, const QCPRange &range, bool logarithmic)
16839{
16840 // If you change something here, make sure to also adapt ::colorize()
16841 if (mColorBufferInvalidated)
16842 updateColorBuffer();
16843
16844 const bool skipNanCheck = mNanHandling == nhNone;
16845 if (!skipNanCheck && std::isnan(position))
16846 {
16847 switch(mNanHandling)
16848 {
16849 case nhLowestColor: return mColorBuffer.first();
16850 case nhHighestColor: return mColorBuffer.last();
16851 case nhTransparent: return qRgba(0, 0, 0, 0);
16852 case nhNanColor: return mNanColor.rgba();
16853 case nhNone: return qRgba(0, 0, 0, 0); // shouldn't happen
16854 }
16855 }
16856
16857 const double posToIndexFactor = !logarithmic ? (mLevelCount-1)/range.size() : (mLevelCount-1)/qLn(range.upper/range.lower);
16858 int index = int((!logarithmic ? position-range.lower : qLn(position/range.lower)) * posToIndexFactor);
16859 if (!mPeriodic)
16860 {
16861 index = qBound(0, index, mLevelCount-1);
16862 } else
16863 {
16864 index %= mLevelCount;
16865 if (index < 0)
16866 index += mLevelCount;
16867 }
16868 return mColorBuffer.at(index);
16869}
16870
16871/*!
16872 Clears the current color stops and loads the specified \a preset. A preset consists of predefined

Callers 15

drawMethod · 0.45
drawShapeMethod · 0.45
savePdfMethod · 0.45
toPixmapMethod · 0.45
updateGradientImageMethod · 0.45
drawFillMethod · 0.45
drawLinePlotMethod · 0.45
drawImpulsePlotMethod · 0.45
drawCurveLineMethod · 0.45
selectTestMethod · 0.45
MainWindowMethod · 0.45
paintEventMethod · 0.45

Calls 2

sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected