本文整理汇总了C++中QColor::hslSaturation方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::hslSaturation方法的具体用法?C++ QColor::hslSaturation怎么用?C++ QColor::hslSaturation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::hslSaturation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendColour
bool LIFXLightClient::sendColour()
{
LIFXPacket *packet = new LIFXPacket(LIFX_SET_LIGHT_COLOR);
memcpy(packet->header.target_mac_address, m_addressraw, sizeof(packet->header.target_mac_address));
LIFXSetLightColorPayload *payload = (LIFXSetLightColorPayload*)packet->payloaddata;
if(payload != NULL)
{
QColor color = QColor::fromRgb(red, green, blue);
//color.getHsl( *payload->hue, *payload->saturation, *payload->brightness);
payload->stream = 0;
payload->hue = color.hslHue() *275;
payload->saturation = color.hslSaturation()*257;
payload->brightness = color.lightness()*655.35;
payload->kelvin = kelvin;
payload->fade_time = fadetime;
((LIFXGatewayClient*)gatewayclient)->SendPacket(packet);
return true;
}
return false;
}
示例2: setIcons
void FlatButton::setIcons(const QIcon& _icon, const QIcon& _checkedIcon, const QIcon& _hoverIcon)
{
m_icon = _icon;
ImageHelper::setIconColor(m_icon, ICON_SIZE, palette().text().color());
m_checkedIcon = _checkedIcon;
if (!m_checkedIcon.isNull()) {
m_checkedIconHighlight = false;
ImageHelper::setIconColor(m_checkedIcon, ICON_SIZE, palette().text().color());
} else {
m_checkedIconHighlight = true;
m_checkedIcon = _icon;
QColor highlightColor = palette().highlight().color();
#ifdef Q_OS_MAC
highlightColor.setHsl(highlightColor.hslHue(), highlightColor.hslSaturation(),
highlightColor.lightness() - 50);
#endif
ImageHelper::setIconColor(m_checkedIcon, ICON_SIZE, highlightColor);
}
m_hoverIcon = _hoverIcon;
aboutUpdateIcon();
}
示例3: setHsl
void tst_QColor::setHsl()
{
QColor color;
for (int A = 0; A <= USHRT_MAX; ++A) {
{
// 0-255
int a = A >> 8;
color.setHsl(0, 0, 0, a);
QCOMPARE(color.alpha(), a);
int h, s, l, a2;
color.getHsv(&h, &s, &l, &a2);
QCOMPARE(a2, a);
}
{
// 0.0-1.0
qreal a = A / qreal(USHRT_MAX);
color.setHslF(0.0, 0.0, 0.0, a);
QCOMPARE(color.alphaF(), a);
qreal h, s, l, a2;
color.getHslF(&h, &s, &l, &a2);
QCOMPARE(a2, a);
}
}
for (int H = 0; H < 36000; ++H) {
{
// 0-255
int h = H / 100;
color.setHsl(h, 0, 0, 0);
QCOMPARE(color.hslHue(), h);
int h2, s, l, a;
color.getHsl(&h2, &s, &l, &a);
QCOMPARE(h2, h);
}
{
// 0.0-1.0
qreal h = H / 36000.0;
color.setHslF(h, 0.0, 0.0, 0.0);
QCOMPARE(color.hslHueF(), h);
qreal h2, s, l, a;
color.getHslF(&h2, &s, &l, &a);
QCOMPARE(h2, h);
}
}
for (int S = 0; S <= USHRT_MAX; ++S) {
{
// 0-255
int s = S >> 8;
color.setHsl(0, s, 0, 0);
QCOMPARE(color.hslSaturation(), s);
int h, s2, l, a;
color.getHsl(&h, &s2, &l, &a);
QCOMPARE(s2, s);
}
{
// 0.0-1.0
qreal s = S / qreal(USHRT_MAX);
color.setHslF(0.0, s, 0.0, 0.0);
QCOMPARE(color.hslSaturationF(), s);
qreal h, s2, l, a;
color.getHslF(&h, &s2, &l, &a);
QCOMPARE(s2, s);
}
}
for (int L = 0; L <= USHRT_MAX; ++L) {
{
// 0-255
int l = L >> 8;
color.setHsl(0, 0, l, 0);
QCOMPARE(color.lightness(), l);
int h, s, l2, a;
color.getHsl(&h, &s, &l2, &a);
QCOMPARE(l2, l);
}
{
// 0.0-1.0
qreal l = L / qreal(USHRT_MAX);
color.setHslF(0.0, 0.0, l, 0.0);
QCOMPARE(color.lightnessF(), l);
qreal h, s, l2, a;
color.getHslF(&h, &s, &l2, &a);
QCOMPARE(l2, l);
}
}
//.........这里部分代码省略.........