当前位置: 首页>>代码示例>>C++>>正文


C++ QColor::valueF方法代码示例

本文整理汇总了C++中QColor::valueF方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::valueF方法的具体用法?C++ QColor::valueF怎么用?C++ QColor::valueF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QColor的用法示例。


在下文中一共展示了QColor::valueF方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleMouseEvent

void ColorPicker::handleMouseEvent(QMouseEvent *event) {
    QRect geometry = mColorWheel->geometry();
    if (eventIsOverWheel(event)) {
        QPixmap pixmap = QWidget::grab(mColorWheel->geometry());
        // some mobile and other environments save pixmaps without pixel density taken into account. For example, breaks on iPhone 6 without this.
        if (pixmap.size() != mColorWheel->geometry().size()) {
            pixmap = pixmap.scaled(mColorWheel->geometry().size().width(),
                                   mColorWheel->geometry().size().height());
        }
        QColor color = pixmap.toImage().pixel(event->pos().x() - geometry.x(),
                                              event->pos().y() - geometry.y());
        if (checkIfColorIsValid(color)){
            if (mCurrentLayoutColorPicker == ELayoutColorPicker::multiColorLayout) {
                if (mWheelIsEnabled) {
                    mCustomColorPicker->updateSelected(color);
                    emit multiColorUpdate();
                }
            } else if (mCurrentLayoutColorPicker == ELayoutColorPicker::ambientLayout) {
                // use the poorly named "value" of the HSV range to calculate the brightness
                auto brightness = uint32_t(color.valueF() * 100.0);
                // adjust the color so that it has a maxed out value in the HSV colorspace
                color.setHsv(color.hue(),
                             color.saturation(),
                             255);
                // then calculate then use the resulting QColor to convert to color temperature.
                int ct = cor::rgbToColorTemperature(color);
                chooseAmbient(ct, brightness, true);
                mTempBrightSliders->changeTemperatureAndBrightness(ct, brightness);
            } else if (mCurrentLayoutColorPicker == ELayoutColorPicker::brightnessLayout) {
                // use the poorly named "value" of the HSV range to calculate the brightness
                auto brightness = uint32_t(color.valueF() * 100.0);
                chooseBrightness(brightness);
                mBrightnessSlider->changeBrightness(brightness);
            } else if (mCurrentLayoutColorPicker == ELayoutColorPicker::standardLayout) {
                chooseColor(color);
                mRGBSliders->changeColor(color);
            } else if (mCurrentLayoutColorPicker == ELayoutColorPicker::colorSchemeLayout) {
                if (mCircleIndex == -1) {
                    mColorSchemeCircles->moveCenterCircle(event->pos(), true);
                    mCircleIndex = 10;
                } else if (mCircleIndex == 10) {
                    mColorSchemeCircles->moveCenterCircle(event->pos(), false);
                } else {
                    mColorSchemeCircles->moveStandardCircle(uint32_t(mCircleIndex), event->pos());
                }

                // turn into vector of colors
                std::vector<QColor> colors;
                for (const auto& circle : mColorSchemeCircles->circles()) {
                    colors.push_back(circle.color);
                }
                emit colorsUpdate(colors);

               // mColorSchemeGrid->setColor(2, color);
            }
        }
    }
}
开发者ID:timsee,项目名称:Corluma,代码行数:58,代码来源:colorpicker.cpp

示例2: 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);
}
开发者ID:chchwy,项目名称:pencil2d,代码行数:26,代码来源:colorwheel.cpp

示例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;
}
开发者ID:Forkhere,项目名称:pencil,代码行数:30,代码来源:colorinspector.cpp

示例4: setColor

void HueSlider::setColor(const QColor& color)
{
    p->saturation = color.saturationF();
    p->value = color.valueF();
    p->updateGradient();
    setColorHue(color.hueF());
}
开发者ID:Rambo2015,项目名称:Drawpile,代码行数:7,代码来源:hue_slider.cpp

示例5: drawPicker

void NQColorWheel::drawPicker(const QColor &color)
{
    QPainter painter(&pixmapWheel_);
    painter.setRenderHint(QPainter::Antialiasing);
    QPen pen;

    // region of the widget
    int w = qMin(width(), height());
    // radius of outer circle
    qreal r = w/2-margin_;
    // radius of inner circle
    qreal ir = r-wheelWidth_;
    // left corner of square
    qreal m = w/2.0-ir/qSqrt(2);
    painter.translate(m-5, m-5);
    qreal SquareWidth = 2*ir/qSqrt(2);
    qreal S = (color.saturationF()-minimumS_)/(1.0-minimumS_)*SquareWidth;
    qreal V = color.valueF()*SquareWidth;

    if (color.saturation() > 30 || color.value() < 50){
        //pen.setColor(Qt::white);
    }

    pen.setWidth(2);
    painter.setPen(pen);
    painter.drawEllipse(S, V, 8, 8);
}
开发者ID:Negusbuk,项目名称:MatDB,代码行数:27,代码来源:nqcolorwheel.cpp

示例6: 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;
}
开发者ID:pm19960106,项目名称:painttyWidget,代码行数:25,代码来源:colorspinboxgroup.cpp

示例7: getLightness

float Theme::getLightness(QString color) {

    QColor c;
    c.setNamedColor(color);
    QColor converted = c.toHsv();
    return converted.valueF();
}
开发者ID:Stankim,项目名称:dukto,代码行数:7,代码来源:theme.cpp

示例8: slotChangeHue

void QtGradientStopsControllerPrivate::slotChangeHue(int color)
{
    QColor c = m_ui->hueColorLine->color();
    if (m_ui->hsvRadioButton->isChecked())
        c.setHsvF((qreal)color / 360.0, c.saturationF(), c.valueF(), c.alphaF());
    else
        c.setRed(color);
    slotChangeHue(c);
}
开发者ID:fluxer,项目名称:katie,代码行数:9,代码来源:qtgradientstopscontroller.cpp

示例9: colorChanged

void Color2DSlider::setColor(const QColor& c)
{
    p->hue = c.hsvHueF();
    p->sat = c.saturationF();
    p->val = c.valueF();
    p->renderSquare(size());
    update();
    emit colorChanged(color());
}
开发者ID:pramod493,项目名称:Qt-Color-Widgets,代码行数:9,代码来源:color_2d_slider.cpp

示例10: slotChangeAlpha

void QtGradientStopsControllerPrivate::slotChangeAlpha(int color)
{
    QColor c = m_ui->alphaColorLine->color();
    if (m_ui->hsvRadioButton->isChecked())
        c.setHsvF(c.hueF(), c.saturationF(), c.valueF(), (qreal)color / 255);
    else
        c.setAlpha(color);
    slotChangeAlpha(c);
}
开发者ID:fluxer,项目名称:katie,代码行数:9,代码来源:qtgradientstopscontroller.cpp

示例11: setColor

void ColorPickerItem::setColor(const QColor & color)
{
    m_hue = color.hueF();
    m_sat = color.saturationF();
    m_val = color.valueF();
    if (m_hue < 0.0)
        m_hue = 0.0;
    regenHueSatPixmap();
    regenValPixmap();
    update();
}
开发者ID:arntanguy,项目名称:fotowall,代码行数:11,代码来源:ColorPickerItem.cpp

示例12: setColor

void Color_Wheel::setColor(QColor c)
{
    qreal oldh = huem;
    huem = c.hueF();
    if ( huem < 0 )
        huem = 0;
    sat = c.saturationF();
    val = c.valueF();
    if ( !qFuzzyCompare(oldh+1,huem+1) )
        render_rectangle();
    update();
    emit colorChanged(c);
}
开发者ID:smurphmeister,项目名称:Qt-Color-Picker,代码行数:13,代码来源:color_wheel.cpp

示例13: distSep

float Tracer::distSep(Point const & p) const
{
	if (m_populationMapImage.isNull())
	{
		return distSep();
	}

	QPoint pxp = m_populationMapImage.toImageCoords(p.pos()).toPoint();
	QRgb rgb = m_populationMapImage.pixel(pxp);
	QColor c = QColor::fromRgb(rgb);
	float  k = c.valueF();

	return distSep() * (1.5f - k);
}
开发者ID:bjandras,项目名称:Newtown,代码行数:14,代码来源:tracer_params.cpp

示例14: getColorPosition

QPointF ColorVolumeWidget::getColorPosition(const QColor &color) const
{
	qreal size = (this->direction == Horizontal) ? imageRect.width() : imageRect.height();
	qreal pos;

	if (this->mode == DarkOnly)
	{
		pos = color.valueF() * size;
	}
	else
	{
		if (color.value() < 255)
		{
			pos = (color.valueF()) * (size / 2);
		}
		else
		{
			pos = (255.0 - color.saturation()) / 255 * (size / 2) + size / 2;
		}
	}

	return (this->direction == Horizontal) ? QPointF(pos, 0) : QPointF(0, pos);
}
开发者ID:ildus,项目名称:moodbox_aka_risovaska,代码行数:23,代码来源:colorvolumewidget.cpp

示例15:

void
Scene_c3t3_item::compute_color_map(const QColor& c)
{
  typedef Indices::size_type size_type;

  size_type nb_domains = indices_.size();
  size_type i = 0;
  for (Indices::iterator it = indices_.begin(), end = indices_.end();
    it != end; ++it, ++i)
  {
    double hue = c.hueF() + 1. / nb_domains * i;
    if (hue > 1) { hue -= 1.; }
    d->colors[*it] = QColor::fromHsvF(hue, c.saturationF(), c.valueF());
  }
}
开发者ID:logtcn,项目名称:cgal,代码行数:15,代码来源:Scene_c3t3_item.cpp


注:本文中的QColor::valueF方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。