improve colormix

This commit is contained in:
interfisch 2019-06-05 00:56:04 +02:00
parent bf26f6301c
commit 2417ae97ac
1 changed files with 12 additions and 2 deletions

View File

@ -295,7 +295,17 @@ void Wagon::updateGraphics()
uint16_t _tmpr=_pxr+_r; //add colors
uint16_t _tmpg=_pxg+_g;
uint16_t _tmpb=_pxb+_b;
if (_tmpr>255){ //clamp
double _brightnesscorrection = 0;
if ( (_tmpr+_tmpg+_tmpb) > 0){
_brightnesscorrection = max((double)_pxr+(double)_pxg+(double)_pxb, (double)_r+(double)_g+(double)_b)/(_tmpr+_tmpg+_tmpb);
}
_tmpr=(uint16_t)(min(255,_tmpr*_brightnesscorrection));
_tmpg=(uint16_t)(min(255,_tmpg*_brightnesscorrection));
_tmpb=(uint16_t)(min(255,_tmpb*_brightnesscorrection));
/*if (_tmpr>255){ //clamp
_tmpr=255;
}
if (_tmpg>255){
@ -303,7 +313,7 @@ void Wagon::updateGraphics()
}
if (_tmpb>255){
_tmpb=255;
}
}*/
_strip->setPixelColor(iCorrected,_tmpr,_tmpg,_tmpb); //draw pixel
}
}