diff --git a/src/ColorScheme.h b/src/ColorScheme.h --- a/src/ColorScheme.h +++ b/src/ColorScheme.h @@ -220,6 +220,8 @@ // it does not already exist void setRandomizationRange(int index, quint16 hue, quint8 saturation, quint8 value); + bool hasBlackBackground(); + QString _description; QString _name; diff --git a/src/ColorScheme.cpp b/src/ColorScheme.cpp --- a/src/ColorScheme.cpp +++ b/src/ColorScheme.cpp @@ -301,15 +301,32 @@ // adjusted as much as possible. // // the value and saturation are left alone to maintain read-ability + // except for black background schemes which allow a small change in + // the colour value if (randomize) { - setRandomizationRange(BGCOLOR_INDEX, MAX_HUE, 255, 0); + int maxValue = 0; + + if (hasBlackBackground()) { + maxValue = 48; + } + + setRandomizationRange(BGCOLOR_INDEX, MAX_HUE, 255, maxValue); } else { if (_randomTable != nullptr) { setRandomizationRange(BGCOLOR_INDEX, 0, 0, 0); } } } +bool ColorScheme::hasBlackBackground() +{ + ColorEntry background = colorTable()[BGCOLOR_INDEX]; + + return background.red() == 0 && + background.green() == 0 && + background.blue() == 0; +} + void ColorScheme::setRandomizationRange(int index, quint16 hue, quint8 saturation, quint8 value) { Q_ASSERT(hue <= MAX_HUE);