MCPcopy Create free account
hub / github.com/baldurk/renderdoc / contrastingColor

Function contrastingColor

qrenderdoc/Code/QRDUtils.cpp:3481–3498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3479}
3480
3481QColor contrastingColor(const QColor &col, const QColor &defaultCol)
3482{
3483 float backLum = getLuminance(col);
3484 float textLum = getLuminance(defaultCol);
3485
3486 bool backDark = backLum < 0.2f;
3487 bool textDark = textLum < 0.2f;
3488
3489 // if they're contrasting, use the text colour desired
3490 if(backDark != textDark)
3491 return defaultCol;
3492
3493 // otherwise pick a contrasting colour
3494 if(backDark)
3495 return QColor(Qt::white);
3496 else
3497 return QColor(Qt::black);
3498}
3499
3500// we declare this partial class to get the accessors. THIS IS DANGEROUS as the ABI is unstable and
3501// this is a private class. The first few functions have been stable for a while so we hope that it

Callers 10

BufferFormatSpecifierMethod · 0.85
paintMarkersMethod · 0.85
dataMethod · 0.85
AddFilterSelectionsFunction · 0.85
dataMethod · 0.85
dataMethod · 0.85
highlightIABindMethod · 0.85
highlightIABindMethod · 0.85
highlightIABindMethod · 0.85
highlightIABindMethod · 0.85

Calls 2

getLuminanceFunction · 0.85
QColorFunction · 0.50

Tested by 1

BufferFormatSpecifierMethod · 0.68