Fix hue clamping in Context2D
It goes from 0..359, not 0..255. Task-number: QTBUG-47894 Change-Id: I0612a9d5e4999afae7703b5c49741b94fb0da07f Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
This commit is contained in:
parent
27bee8076f
commit
6067b74bb7
|
@ -189,7 +189,7 @@ QColor qt_color_from_string(const QV4::Value &name)
|
|||
if (isRgb)
|
||||
return QColor::fromRgba(qRgba(qClamp(rh, 0, 255), qClamp(gs, 0, 255), qClamp(bl, 0, 255), qClamp(alpha, 0, 255)));
|
||||
else if (isHsl)
|
||||
return QColor::fromHsl(qClamp(rh, 0, 255), qClamp(gs, 0, 255), qClamp(bl, 0, 255), qClamp(alpha, 0, 255));
|
||||
return QColor::fromHsl(qClamp(rh, 0, 359), qClamp(gs, 0, 255), qClamp(bl, 0, 255), qClamp(alpha, 0, 255));
|
||||
}
|
||||
return QColor();
|
||||
}
|
||||
|
|
|
@ -182,4 +182,22 @@ Canvas {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
TestCase {
|
||||
name: "Colors"
|
||||
when: canvas.available
|
||||
|
||||
function test_colors() {
|
||||
wait(100);
|
||||
compare(contextSpy.count, 1);
|
||||
|
||||
var ctx = canvas.getContext("2d");
|
||||
// QTBUG-47894
|
||||
ctx.strokeStyle = 'hsl(255, 100%, 50%)';
|
||||
var c1 = ctx.strokeStyle.toString();
|
||||
ctx.strokeStyle = 'hsl(320, 100%, 50%)';
|
||||
var c2 = ctx.strokeStyle.toString();
|
||||
verify(c1 !== c2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue