本文整理汇总了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);
}
}
}
}
示例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);
}
示例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: setColor
void HueSlider::setColor(const QColor& color)
{
p->saturation = color.saturationF();
p->value = color.valueF();
p->updateGradient();
setColorHue(color.hueF());
}
示例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);
}
示例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;
}
示例7: getLightness
float Theme::getLightness(QString color) {
QColor c;
c.setNamedColor(color);
QColor converted = c.toHsv();
return converted.valueF();
}
示例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);
}
示例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());
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
}