Ensure key highlighting color is bright enough to not blend too much with black keys

This commit is contained in:
Martchus 2023-10-23 20:09:45 +02:00
parent 73c7b0502d
commit d3e01264b9
2 changed files with 17 additions and 3 deletions

View File

@ -29,6 +29,8 @@
#ifndef __CFG_H__
#define __CFG_H__
#include <algorithm>
#define OPTION_BENCHMARK_TEST 0
#if OPTION_BENCHMARK_TEST
#define BENCHMARK_INIT() benchMarkInit()
@ -71,6 +73,15 @@ public:
return red == color.red && green == color.green && blue == color.blue;
}
constexpr void ensureBrightness(float v)
{
if (red < v && green < v && blue < v) {
red = std::max(red, v);
green = std::max(green, v);
blue = std::max(blue, v);
}
}
float red, green, blue;
};

View File

@ -168,9 +168,12 @@ void CScore::drawPianoKeyboard(){
glScalef(1.0f, 1.4f, 1.0f);
glTranslatef(Cfg::staveStartX() + xPlaceSize * static_cast<float>(i++), yStart, 0.0f);
CDraw::drColor (CColor(1.0, 1.0, 1.0));
if(state[k]==1) CDraw::drColor(stopped ? Cfg::colorTheme().playedStoppedColor : Cfg::colorTheme().noteColor);
if(state[k]==2) CDraw::drColor(Cfg::colorTheme().playedBadColor);
const auto &theme = Cfg::colorTheme();
auto color = CColor(1.0, 1.0, 1.0);
if(state[k]==1) color = stopped ? theme.playedStoppedColor : theme.noteColor;
else if(state[k]==2) color = theme.playedBadColor;
color.ensureBrightness(0.4f); // ensure the color is bright enough to not blend too much with black keys
CDraw::drColor(color);
glBegin(GL_QUADS);
glVertex2f(0, ySize);
glVertex2f(xKeySize, ySize);