CppUtils.hsluv(): prevent out of bounds sat/luv

This commit is contained in:
miruka 2020-10-01 20:06:42 -04:00
parent 0e3821a592
commit 12cfbd2a96

View File

@ -41,7 +41,13 @@ public slots:
QColor hsluv(qreal hue, qreal sat, qreal luv, qreal alpha = 1.0) const { QColor hsluv(qreal hue, qreal sat, qreal luv, qreal alpha = 1.0) const {
double red, green, blue; double red, green, blue;
hsluv2rgb(hue, sat, luv, &red, &green, &blue);
hsluv2rgb(
hue,
qMax(0.0, qMin(100.0, sat)),
qMax(0.0, qMin(100.0, luv)),
&red, &green, &blue
);
return QColor::fromRgbF( return QColor::fromRgbF(
qMax(0.0, qMin(1.0, red)), qMax(0.0, qMin(1.0, red)),