本文整理汇总了C++中QColor::getHslF方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::getHslF方法的具体用法?C++ QColor::getHslF怎么用?C++ QColor::getHslF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::getHslF方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contains
bool ContinuousColorRange::contains(const QVariant &v, bool inclusive) const
{
QColor clr;
if( v.type() == QVariant::Double){
clr = ColorRangeBase::toColor(v.toULongLong(),defaultColorModel());
} else
clr = v.value<QColor>();
if ( !clr.isValid())
return false;
double component1a, component2a, component3a,component4a;
double component1b, component2b, component3b,component4b;
double component1c, component2c, component3c,component4c;
QColor limit1,limit2;
switch (defaultColorModel()) {
case ColorRangeBase::cmRGBA :
case ColorRangeBase::cmGREYSCALE:
clr.getRgbF(&component1a, &component2a, &component3a);
_limit1.getRgbF(&component1b, &component2b, &component3b);
_limit2.getRgbF(&component1c, &component2c, &component3c);
break;
case ColorRangeBase::cmHSLA :
clr.getHslF(&component1a, &component2a, &component3a);
_limit1.getHslF(&component1b, &component2b, &component3b);
_limit2.getHslF(&component1c, &component2c, &component3c);
break;
case ColorRangeBase::cmCYMKA:
clr.getCmykF(&component1a, &component2a, &component3a,&component4a);
limit1 = QColor(_limit1);
limit2 = QColor(_limit2);
limit1.getCmykF(&component1b, &component2b, &component3b, &component4b);
limit2.getCmykF(&component1c, &component2c, &component3c, &component4c);
break;
default:
break;
}
switch(defaultColorModel()){
case ColorRangeBase::cmGREYSCALE:{
bool isGrey = component1a == component2a && component1a == component3a;
if (!isGrey)
return false;
}
case ColorRangeBase::cmRGBA :
case ColorRangeBase::cmHSLA :
return component1a >= component1b && component1a <= component1c &&
component2a >= component2b && component2a <= component2c &&
component3a >= component3b && component3a <= component3c;
case ColorRangeBase::cmCYMKA:
return component1a >= component1b && component1a <= component1c &&
component2a >= component2b && component2a <= component2c &&
component3a >= component3b && component3a <= component3c &&
component4a >= component4b && component4a <= component4c;
default:
break;
}
return false;
}
示例2: tintColor
QColor tintColor( const QColor & color, qreal tintfactor )
{
QColor retColor;
const qreal nonTindedPart = 1.0 - tintfactor;
qreal luminance = 0.0;
qreal sat = 0.0;
qreal hue = 0.0;
color.getHslF( &hue, &sat, &luminance );
luminance = luminance * tintfactor + nonTindedPart;
retColor.setHslF( hue, sat, luminance );
// const int tintedColor = 255 * nonTindedPart;
// retColor.setRed( tintedColor + tintfactor * color.red() );
// retColor.setGreen( tintedColor + tintfactor * color.green() );
// retColor.setBlue( tintedColor + tintfactor * color.blue() );
return retColor;
}
示例3: GroupedLineEdit
TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NULL)
{
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(reparse()));
connect(this, SIGNAL(textChanged()), this, SLOT(reparse()));
QColor textColor = palette().color(QPalette::Text);
qreal h, s, l, a;
textColor.getHslF(&h, &s, &l, &a);
// I use dark themes
if (l <= 0.3) { // very dark text. get a brigth background
addColor(QColor(Qt::red).lighter(120));
addColor(QColor(Qt::green).lighter(120));
addColor(QColor(Qt::blue).lighter(120));
} else if (l <= 0.6) { // moderated dark text. get a somewhat brigth background
addColor(QColor(Qt::red).lighter(60));
addColor(QColor(Qt::green).lighter(60));
addColor(QColor(Qt::blue).lighter(60));
} else {
addColor(QColor(Qt::red).darker(120));
addColor(QColor(Qt::green).darker(120));
addColor(QColor(Qt::blue).darker(120));
} // light text. get a dark background.
setFocusPolicy(Qt::StrongFocus);
}
示例4: 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);
}
}
//.........这里部分代码省略.........