本文整理汇总了C++中QColor::hsvSaturationF方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::hsvSaturationF方法的具体用法?C++ QColor::hsvSaturationF怎么用?C++ QColor::hsvSaturationF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::hsvSaturationF方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setColor
void ColorSpinBoxGroup::setColor(const QColor &c)
{
if(c == color_) return;
noColorUpdate = true;
if(isRgbColors){
ui->RedspinBox->setValue(c.red());
ui->GreenspinBox->setValue(c.green());
ui->BluespinBox->setValue(c.blue());
}else{
ui->RedspinBox->setValue(
qBound(0.0, c.hsvHueF()*359, 359.0)
);
ui->GreenspinBox->setValue(
qBound(0.0, c.hsvSaturationF()*100, 100.0)
);
ui->BluespinBox->setValue(
qBound(0.0, c.valueF()*100, 100.0)
);
}
color_ = c;
QPalette p = ui->label->palette();
p.setColor(QPalette::Background, color_);
ui->label->setPalette(p);
noColorUpdate = false;
}
示例2: getSaturation
float Theme::getSaturation(QString color) {
QColor c;
c.setNamedColor(color);
QColor converted = c.toHsv();
return converted.hsvSaturationF();
}
示例3: setColor
void ColorInspector::setColor(const QColor &newColor)
{
if (newColor == m_color)
{
return;
}
noColorUpdate = true;
if(isRgbColors)
{
ui->RedspinBox->setValue(newColor.red());
ui->GreenspinBox->setValue(newColor.green());
ui->BluespinBox->setValue(newColor.blue());
ui->AlphaspinBox->setValue(newColor.alpha());
}
else
{
ui->RedspinBox->setValue( qBound(0.0, newColor.hsvHueF() * 359, 359.0) );
ui->GreenspinBox->setValue( qBound(0.0, newColor.hsvSaturationF() * 100, 100.0) );
ui->BluespinBox->setValue( qBound(0.0, newColor.valueF() * 100, 100.0) );
ui->AlphaspinBox->setValue( qBound(0.0, newColor.alphaF() * 100, 100.0) );
}
m_color = newColor;
QPalette p = ui->color->palette();
p.setColor(QPalette::Background, m_color);
ui->color->setPalette(p);
//ui->color->setFixedSize(30,30);
noColorUpdate = false;
}
示例4: drawPicker
void ColorWheel::drawPicker(const QColor& color)
{
QPainter painter(&mWheelPixmap);
painter.setRenderHint(QPainter::Antialiasing);
int ellipseSize = 9;
QPoint squareTopLeft = mSquareRect.topLeft();
QSize squareSize = mSquareRect.size();
qreal S = color.hsvSaturationF() * (squareSize.width()-1);
qreal V = (squareSize.height() - (color.valueF() * squareSize.height()-1));
QPen pen;
pen.setWidth(1);
if (color.hsvSaturation() > 30 || color.value() < 50)
{
pen.setColor(Qt::white);
}
painter.setPen(pen);
QTransform transform;
transform.translate(-ellipseSize/2,-ellipseSize/2);
transform.translate(squareTopLeft.x(),squareTopLeft.y()-1);
painter.setTransform(transform);
painter.drawEllipse(static_cast<int>(S), static_cast<int>(V), ellipseSize, ellipseSize);
}
示例5: adjustColorToContrastWithWhite
QColor TreeItemModel::adjustColorToContrastWithWhite(QColor color) const
{
// use some tricks in HSV space to get contrasting colors while
// keeping the original color as much as possible.
//
// for colors: strengthen the saturation: s' = s+(1-s)/2
// for for grayscale: lower value, or give up for whites:
// if s<0.1: v = max(0.7, v)
double h = color.hueF();
double s = color.hsvSaturationF();
double v = color.valueF();
double isChromatic = s > 0.1; // our definition
if (isChromatic)
{
s = s+(1.0-s)/2;
}
else
{
v = std::min(0.6, v);
}
return QColor::fromHsvF(h,s,v);
}
示例6: setColor
void KisColorSelectorSimple::setColor(const QColor &c)
{
switch (m_parameter) {
case KisColorSelector::SL:
m_lastClickPos.setX(c.hslSaturationF());
m_lastClickPos.setY(1.-c.lightnessF());
emit paramChanged(-1, -1, -1, c.hslSaturationF(), c.lightnessF());
break;
case KisColorSelector::LH:
m_lastClickPos.setX(qBound<qreal>(0., c.hueF(), 1.));
m_lastClickPos.setY(1.-c.lightnessF());
emit paramChanged(c.hueF(), -1, -1, -1, c.lightnessF());
break;
case KisColorSelector::SV:
m_lastClickPos.setX(c.saturationF());
m_lastClickPos.setY(1-c.valueF());
emit paramChanged(-1, c.saturationF(), c.valueF(), -1, -1);
break;
case KisColorSelector::SV2: {
qreal xRel = c.hsvSaturationF();
qreal yRel = 0.5;
if(xRel != 1.0)
yRel = 1.0 - qBound<qreal>(0.0, (c.valueF() - xRel) / (1.0 - xRel), 1.0);
m_lastClickPos.setX(xRel);
m_lastClickPos.setY(yRel);
emit paramChanged(-1, -1, -1, xRel, yRel);
break;
}
case KisColorSelector::VH:
m_lastClickPos.setX(qBound<qreal>(0., c.hueF(), 1.));
m_lastClickPos.setY(c.valueF());
emit paramChanged(c.hueF(), -1, c.valueF(), -1, -1);
break;
case KisColorSelector::hsvSH:
m_lastClickPos.setX(qBound<qreal>(0., c.hueF(), 1.));
m_lastClickPos.setY(1-c.saturationF());
emit paramChanged(c.hueF(), c.saturationF(), -1, -1, -1);
break;
case KisColorSelector::hslSH:
m_lastClickPos.setX(qBound<qreal>(0., c.hueF(), 1.));
m_lastClickPos.setY(1-c.hslSaturationF());
emit paramChanged(c.hueF(), -1, -1, c.hslSaturationF(), -1);
break;
case KisColorSelector::L:
m_lastClickPos.setX(c.lightnessF());
emit paramChanged(-1, -1, -1, -1, c.lightnessF());
break;
case KisColorSelector::V:
m_lastClickPos.setX(c.valueF());
emit paramChanged(-1, -1, c.valueF(), -1, -1);
break;
case KisColorSelector::hsvS:
m_lastClickPos.setX(c.saturationF());
emit paramChanged(-1, c.saturationF(), -1, -1, -1);
break;
case KisColorSelector::hslS:
m_lastClickPos.setX(c.hslSaturationF());
emit paramChanged(-1, -1, -1, c.hslSaturationF(), -1);
break;
case KisColorSelector::H:
m_lastClickPos.setX(qBound<qreal>(0., c.hueF(), 1.));
emit paramChanged(c.hueF(), -1, -1, -1, -1);
break;
default:
Q_ASSERT(false);
break;
}
emit update();
}