本文整理汇总了C++中QColor::setHsv方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setHsv方法的具体用法?C++ QColor::setHsv怎么用?C++ QColor::setHsv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setHsv方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: borderColor
QColor StyleHelper::borderColor(bool lightColored)
{
QColor result = baseColor(lightColored);
result.setHsv(result.hue(),
result.saturation(),
result.value() / 2);
return result;
}
示例2: buttonColor
QColor buttonColor(const QPalette& pal) const
{
QColor buttonColor = pal.button().color();
const int val = qGray(buttonColor.rgb());
buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
return buttonColor;
}
示例3: shadowColor
QColor StyleHelper::shadowColor()
{
QColor result = baseColor();
result.setHsv(result.hue(),
clamp(result.saturation() * 1.1),
clamp(result.value() * 0.70));
return result;
}
示例4: 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);
}
}
}
}
示例5: removeHighlighting
void Edge::removeHighlighting(){
QColor temp;
temp.setHsv(210,220,250);
if (edgeColor_==temp){
fixedColor_=false;
edgeColor_=Qt::black;
update();
}
}
示例6: getGradientPixmap
QPixmap ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight, int _iColorMode ) {
#ifdef DEBUG_CLSBASEQSTATEARRAYVIEW
cout << "ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight)" << endl;
#endif
// int iColorMode = ClsBaseQStateArrayView::GRAY;
// int iColorMode = ClsBaseQStateArrayView::BLUE2RED;
// int iColorMode = ClsBaseQStateArrayView::HSV;
QPixmap pmGradient;
QPainter* paintGradient = new QPainter();
QWMatrix mxRot;
int iDiag = (int)(sqrt(double(iImgWidth * iImgWidth + iImgHeight * iImgHeight))/2.);
pmGradient.resize(2 * iDiag, 2 * iDiag);
paintGradient->begin(&pmGradient);
paintGradient->setWindow( 0, 0, 2 * iDiag, 2 * iDiag );
int iNrSices = 50;
for ( int i=0; i<iNrSices; i++ ) {
paintGradient->setWorldMatrix( mxRot );
QColor c;
if(_iColorMode == ClsBaseQStateArrayView::GRAY){
c.setRgb( i* 255 / iNrSices, i* 255 / iNrSices, i* 255 / iNrSices );
}
else if(_iColorMode == ClsBaseQStateArrayView::BLUE2RED){
if(i<iNrSices/2){
/* BLUE */
c.setRgb(0, 0, 255 - i * 510/iNrSices);
}
else {
/* RED */
c.setRgb( (i - iNrSices/2) * 255/(iNrSices/2), 0,0);
}
}
else {
c.setHsv( i* 360 / iNrSices, 255, 255 );
}
paintGradient->setBrush( c );
paintGradient->setPen( c );
//zzz QPointArray a;
QPolygon a;
a.setPoints( 4,
0, 0,
iDiag * 2 / iNrSices, 0,
iDiag * 2 / iNrSices, iDiag * 2,
0, iDiag * 2 );
paintGradient->drawPolygon( a );
mxRot.translate( (double)iDiag * 2.0 / (double)iNrSices, 0.0 );
}
paintGradient->end();
return pmGradient;
}
示例7: selectingColor
QColor ZPunctum::selectingColor(const QColor &color) const
{
QColor select;
select.setHsv((color.hue() + 60) % 360,
/*color.saturation()*/255, 255/*color.value()*/);
return select;
}
示例8: paint
void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->save();
AbstractCardItem::paint(painter, option, widget);
int i = 0;
QMapIterator<int, int> counterIterator(counters);
while (counterIterator.hasNext()) {
counterIterator.next();
QColor color;
color.setHsv(counterIterator.key() * 60, 150, 255);
paintNumberEllipse(counterIterator.value(), 14, color, i, counters.size(), painter);
++i;
}
QSizeF translatedSize = getTranslatedSize(painter);
qreal scaleFactor = translatedSize.width() / boundingRect().width();
if (!pt.isEmpty()) {
painter->save();
transformPainter(painter, translatedSize, tapAngle);
if(info)
{
QStringList ptSplit = pt.split("/");
QStringList ptDbSplit = info->getPowTough().split("/");
if (getFaceDown() || ptDbSplit.at(0) != ptSplit.at(0) || ptDbSplit.at(1) != ptSplit.at(1))
painter->setPen(QColor(255, 150, 0));
else
painter->setPen(Qt::white);
} else {
painter->setPen(Qt::white);
}
painter->setBackground(Qt::black);
painter->setBackgroundMode(Qt::OpaqueMode);
painter->drawText(QRectF(4 * scaleFactor, 4 * scaleFactor, translatedSize.width() - 10 * scaleFactor, translatedSize.height() - 8 * scaleFactor), Qt::AlignRight | Qt::AlignBottom, pt);
painter->restore();
}
if (!annotation.isEmpty()) {
painter->save();
transformPainter(painter, translatedSize, tapAngle);
painter->setBackground(Qt::black);
painter->setBackgroundMode(Qt::OpaqueMode);
painter->setPen(Qt::white);
painter->drawText(QRectF(4 * scaleFactor, 4 * scaleFactor, translatedSize.width() - 8 * scaleFactor, translatedSize.height() - 8 * scaleFactor), Qt::AlignCenter | Qt::TextWrapAnywhere, annotation);
painter->restore();
}
if (getBeingPointedAt())
painter->fillRect(boundingRect(), QBrush(QColor(255, 0, 0, 100)));
painter->restore();
}
示例9: listenToMouse
void editor::listenToMouse()
{
if (levelLoaded)
{
if (pressedL)
{
int x = floor((xMouseReal-xCorner)/double(tilesize));
int y = level.h - floor((yMouseReal-yCorner)/double(tilesize)) - 1;
switch (mode)
{
case 0:
case 1:
case 2:
try {
setTile(x, y, mode,
mode?selectedColor:(char *)"#ffffff",
selectedDurability);
} catch (...) {}
updateTile(x, y);
break;
case 3:
if (x>=0 && y>=0 && x<level.w && y<level.h && tileType(x, y))
{
int h=0, s=0, v=0;
int c = 0;
for (int i=-1; i<2; i++)
for (int j=-1; j<2; j++, c++)
{
try {
QColor tmp(tileColor(x+i, y+j));
h += tmp.hue();
s += tmp.saturation();
v += tmp.value();
} catch (...) {
QColor tmp(tileColor(x+(-1*i), y+(-1*j)));
h += tmp.hue();
s += tmp.saturation();
v += tmp.value();
}
}
h /= c;
s /= c;
v /= c;
QColor q;
q.setHsv(h, s, v);
char m[8];
for (int i=0; i<8; i++)
m[i] = (q.name().constData()+i)->toAscii();
qstrcpy(tileColor(x, y), m);
updateTile(x, y);
break;
}
}
}
}
}
示例10: getPressureColor
QColor getPressureColor(double density)
{
QColor color;
int h = ((int) (180.0 - 180.0 * density / 8.0));
while (h < 0)
h += 360;
color.setHsv(h , 255, 255);
return color;
}
示例11: setCurrent
void ColorBox::setCurrent(int x, int y)
{
QColor newColor;
x = clamp(x, 0, 120);
y = clamp(y, 0, 120);
int oldAlpha = m_color.alpha();
newColor.setHsv(hue(), (x*255) / 120, 255 - (y*255) / 120);
newColor.setAlpha(oldAlpha);
setColor(newColor);
}
示例12: visualizeCondition
void NetworkInstance::visualizeCondition(std::vector<QString> &condition)
{
for (QString& item : condition){
QString name = item.split(" ")[0];
QColor queryColor;
queryColor.setHsv(20,30,250);
nv_->getNode(nc_.getNetwork().getNode(name.toStdString()).getID())->originalState();
nv_->getNode(nc_.getNetwork().getNode(name.toStdString()).getID())->setColor(queryColor);
}
}
示例13: changeColorMin
void CalibrationWindow::changeColorMin()
{
QColor colorMin;
colorMin.setHsv(ui->horizontalSliderH_Min->value(),
ui->horizontalSliderS_Min->value(),
ui->horizontalSliderV_Min->value(),
ui->horizontalSliderAMin->value());
QPalette pMin;
pMin.setColor(QPalette::Base, colorMin);
ui->textEditColorMin->setPalette(pMin);
}
示例14: zoneColor
// generate a zone color with a specific number of zones
QColor zoneColor(int z, int num_zones) {
assert ((z >= 0) && (z < num_zones));
if (num_zones == 1)
return QColor(128, 128, 128);
QColor color;
// pick a color from violet (z=0) to red (z=num_zones)
color.setHsv(int(300 * (num_zones - z - 1) / (num_zones - 1)), 255, 255);
return color;
}
示例15: COLOR
void
Style::drawHeaderSection(const QStyleOption *option, QPainter *painter, const QWidget*) const
{
OPT_SUNKEN OPT_HOVER
const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option);
const bool sorting = header && (header->sortIndicator != QStyleOptionHeader::None);
Qt::Orientation o = Qt::Vertical; int s = RECT.height();
if (header && header->orientation == Qt::Vertical)
{
o = Qt::Horizontal;
s = RECT.width();
}
QColor c = sorting ? COLOR(config.view.sortingHeader_role[Bg]) : COLOR(config.view.header_role[Bg]);
if (Colors::value(c) < 50)
{ int h,s,v,a; c.getHsv(&h, &s, &v, &a); c.setHsv(h, s, 50, a); }
if (appType == GTK)
sunken = option->state & State_HasFocus;
if (sunken)
{
const QPixmap &sunk = Gradients::pix(c, s, o, Gradients::Sunken);
painter->drawTiledPixmap(RECT, sunk);
return;
}
const Gradients::Type gt = sorting ? config.view.sortingHeaderGradient : config.view.headerGradient;
if (hover)
c = Colors::mid(c, sorting ? CCOLOR(view.sortingHeader, Fg) : CCOLOR(view.header, Fg),8,1);
if (gt == Gradients::None)
painter->fillRect(RECT, c);
else
painter->drawTiledPixmap(RECT, Gradients::pix(c, s, o, gt));
if (o == Qt::Vertical)
{
if (!header || header->section < QStyleOptionHeader::End)
{
QRect r = RECT; r.setLeft(r.right() - F(1));
painter->drawTiledPixmap(r, Gradients::pix(CCOLOR(view.header, Bg), s, o, Gradients::Sunken));
}
if (Colors::value(CCOLOR(view.header, Bg)) > 90) // not on dark elements - looks just stupid...
{
SAVE_PEN
painter->setPen(Colors::mid(FCOLOR(Base), Qt::black, 6, 1));
painter->drawLine(RECT.bottomLeft(), RECT.bottomRight());
RESTORE_PEN
}
}