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


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

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


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

示例1: paintEvent

void Checkbox::paintEvent(QPaintEvent *e) {
	Painter p(this);

	float64 over = a_over.current(), checked = a_checked.current();
	bool cnone = (over == 0. && checked == 0.), cover = (over == 1. && checked == 0.), cchecked = (checked == 1.);
	bool cbad = !cnone && !cover && !cchecked;
	QColor color;
	if (cbad) {
		float64 onone = (1. - over) * (1. - checked), oover = over * (1. - checked), ochecked = checked;
		color.setRedF(_st.checkFg->c.redF() * onone + _st.checkFgOver->c.redF() * oover + _st.checkFgActive->c.redF() * ochecked);
		color.setGreenF(_st.checkFg->c.greenF() * onone + _st.checkFgOver->c.greenF() * oover + _st.checkFgActive->c.greenF() * ochecked);
		color.setBlueF(_st.checkFg->c.blueF() * onone + _st.checkFgOver->c.blueF() * oover + _st.checkFgActive->c.blueF() * ochecked);
	}

	QRect r(e->rect());
	p.setClipRect(r);
	p.fillRect(r, _st.textBg->b);
	if (_checkRect.intersects(r)) {
		p.setRenderHint(QPainter::HighQualityAntialiasing);

		QPen pen;
		if (cbad) {
			pen = QPen(color);
		} else {
			pen = (cnone ? _st.checkFg : (cover ? _st.checkFgOver : _st.checkFgActive))->p;
			color = (cnone ? _st.checkFg : (cover ? _st.checkFgOver : _st.checkFgActive))->c;
		}
		pen.setWidth(_st.thickness);
		p.setPen(pen);
		if (checked > 0) {
			color.setRedF(color.redF() * checked + st::white->c.redF() * (1. - checked));
			color.setGreenF(color.greenF() * checked + st::white->c.greenF() * (1. - checked));
			color.setBlueF(color.blueF() * checked + st::white->c.blueF() * (1. - checked));
			p.setBrush(color);
		} else {
			p.setBrush(st::white);
		}
		p.drawRoundedRect(QRectF(_checkRect).marginsRemoved(QMarginsF(_st.thickness / 2, _st.thickness / 2, _st.thickness / 2, _st.thickness / 2)), st::msgRadius, st::msgRadius);
		p.setRenderHint(QPainter::HighQualityAntialiasing, false);

		if (checked > 0) {
			p.drawSpriteCenter(_checkRect, _st.checkIcon);
		}
	}
	if (_checkRect.contains(r)) return;

	p.setPen(_st.textFg);
	p.setFont(_st.font);
	p.drawTextLeft(_st.textPosition.x(), _st.textPosition.y(), width(), _text, _textWidth);
}
开发者ID:0ps,项目名称:telegram,代码行数:50,代码来源:flatcheckbox.cpp

示例2: getTileFromScreen

QImage DwarfClipboardPng::getTileFromScreen(DFHack::t_screen screen)
{
    QColor foregroundColor = getForegroundColorFromScreen(screen);
    QColor backgroundColor = getBackgroundColorFromScreen(screen);
    QImage tile = tileSet->copy((screen.symbol % 16)*tileWidth,int(screen.symbol/16)*tileHeight,tileWidth,tileHeight);
    QImage resultImage(tileWidth,tileHeight,QImage::Format_ARGB32);
    for(int x = 0;x< tile.width();x++){
        for(int y =0;y<tile.height();y++){
            QColor color;
            color.setRgba(tile.pixel(x,y));
            if(color == QColor("#FF00FF")){ // FF00FF is magenta
                resultImage.setPixel(x,y,backgroundColor.rgb());
            }
            else{
                QColor newColor;
                qreal alpha = color.alphaF();
                qreal alpha_diff = 1-alpha;
                newColor.setRedF((alpha * (color.redF() * foregroundColor.redF() )) + (alpha_diff * backgroundColor.redF()));
                newColor.setGreenF((alpha * (color.greenF() * foregroundColor.greenF() )) + (alpha_diff * backgroundColor.greenF()));
                newColor.setBlueF((alpha * (color.blueF() * foregroundColor.blueF() )) + (alpha_diff * backgroundColor.blueF()));
                resultImage.setPixel(x,y,newColor.rgb());
            }
        }
    }
    return(resultImage);
}
开发者ID:jimhester,项目名称:Dwarf-Clipboard,代码行数:26,代码来源:DwarfClipboardPng.cpp

示例3: CalcColor

        OPENPSTD_SHARED_EXPORT QColor MultiColorGradient::CalcColor(float value)
        {
            auto begin = this->colors.begin();
            if (value <= begin->first)
            {
                return this->colors.begin()->second;
            }
            auto last = this->colors.end();
            last--;
            if (value >= last->first)
            {
                return last->second;
            }
            std::map<float, QColor>::iterator upperBound = this->colors.upper_bound(value);
            std::map<float, QColor>::iterator lowerBound = upperBound;
            lowerBound--;

            QColor result;
            result.setRedF(this->LinearInterpolation(lowerBound->first, lowerBound->second.redF(), upperBound->first,
                                                     upperBound->second.redF(), value));
            result.setGreenF(
                    this->LinearInterpolation(lowerBound->first, lowerBound->second.greenF(), upperBound->first,
                                              upperBound->second.greenF(), value));
            result.setBlueF(this->LinearInterpolation(lowerBound->first, lowerBound->second.blueF(), upperBound->first,
                                                      upperBound->second.blueF(), value));
            result.setAlphaF(
                    this->LinearInterpolation(lowerBound->first, lowerBound->second.alphaF(), upperBound->first,
                                              upperBound->second.alphaF(), value));

            return result;
        }
开发者ID:Louisvh,项目名称:openPSTD,代码行数:31,代码来源:Colors.cpp

示例4: paintEvent

void DColorPicker::paintEvent(QPaintEvent *e)
{
    QPainter pa(this);

    foreach (const Gradient &gradient, m_gradientList) {
        int row = gradient.end.x()-gradient.begin.x()+1;
        int column = gradient.end.y()-gradient.begin.y()+1;

        for(int i=0; i<row; ++i){
            for(int j=0; j<column; ++j){
                int top_margin = (height()-m_row*(m_cellSize+m_spacing)-m_spacing)/2;
                int left_margin = (width()-m_column*(m_cellSize+m_spacing)-m_spacing)/2;

                QRect rect(left_margin+(j+gradient.begin.y()-1)*(m_cellSize+m_spacing),
                           top_margin+(i+gradient.begin.x()-1)*(m_cellSize+m_spacing),
                           m_cellSize, m_cellSize);

                QColor c = gradient.startColor.toRgb();
                QColor c2 = gradient.endColor.toRgb();

                if(row>1&&column>1){
                    c.setRedF(c.redF()+(c2.redF()-c.redF())*i/(row-1));
                    c.setGreenF(c.greenF()+(c2.greenF()-c.greenF())*j/(column-1));
                    c.setBlueF(c.blueF()+(c2.blueF()-c.blueF())*i/(row-1));
                }else if(row>1){
                    c.setRedF(c.redF()+(c2.redF()-c.redF())*i/(row-1));
                    c.setGreenF(c.greenF()+(c2.greenF()-c.greenF())*i/(row-1));
                    c.setBlueF(c.blueF()+(c2.blueF()-c.blueF())*i/(row-1));
                }else if(column>1){
                    c.setRedF(c.redF()+(c2.redF()-c.redF())*j/(column-1));
                    c.setGreenF(c.greenF()+(c2.greenF()-c.greenF())*j/(column-1));
                    c.setBlueF(c.blueF()+(c2.blueF()-c.blueF())*j/(column-1));
                }

                pa.fillRect(rect, c);

                if(m_currentColor.isValid()&&c.name() == m_currentColor.name()){
                    pa.setPen(m_selectedBorderColor);
                    rect.setX(rect.x()-1);
                    rect.setY(rect.y()-1);
                    rect.setWidth(m_cellSize+1);
                    rect.setHeight(m_cellSize+1);
                    pa.drawRect(rect);
                }
            }
        }
    }
开发者ID:zccrs,项目名称:deepin-tool-kit,代码行数:47,代码来源:dcolorpicker.cpp

示例5: if

/* see PSColorDef in xkbprint */
bool
KeyboardLayoutWidget::parseXkbColorSpec (char* colorspec, QColor& color)
{
    long level;

    color.setAlphaF(1);
    if (strcasecmp (colorspec, "black") == 0) {
        color = Qt::black;
    } else if (strcasecmp (colorspec, "white") == 0) {
        color = Qt::white;
    } else if (strncasecmp (colorspec, "grey", 4) == 0 ||
           strncasecmp (colorspec, "gray", 4) == 0) {
        level = strtol (colorspec + 4, NULL, 10);

        color.setRedF(1.0 - level / 100.0);
        color.setGreenF(1.0 - level / 100.0);
        color.setBlueF(1.0 - level / 100.0);
    } else if (strcasecmp (colorspec, "red") == 0) {
        color = Qt::red;
    } else if (strcasecmp (colorspec, "green") == 0) {
        color = Qt::green;
    } else if (strcasecmp (colorspec, "blue") == 0) {
        color = Qt::blue;
    } else if (strncasecmp (colorspec, "red", 3) == 0) {
        level = strtol (colorspec + 3, NULL, 10);

        color.setRedF(level / 100.0);
        color.setGreenF(0);
        color.setBlueF(0);
    } else if (strncasecmp (colorspec, "green", 5) == 0) {
        level = strtol (colorspec + 5, NULL, 10);

        color.setRedF(0);
        color.setGreenF(level / 100.0);
        color.setBlueF(0);
    } else if (strncasecmp (colorspec, "blue", 4) == 0) {
        level = strtol (colorspec + 4, NULL, 10);

        color.setRedF(0);
        color.setGreenF(0);
        color.setBlueF(level / 100.0);
    } else
        return false;

    return true;
}
开发者ID:adaptee,项目名称:kcm-fcitx,代码行数:47,代码来源:keyboardlayoutwidget.cpp

示例6: ColorRGBToQColor

QColor ColorRGBToQColor(ColorRGB color)
{
    QColor ret;
    ret.setRedF(color.r);
    ret.setGreenF(color.g);
    ret.setBlueF(color.b);
    return ret;
}
开发者ID:gnleece,项目名称:Dogwood,代码行数:8,代码来源:EditorUtil.cpp

示例7: linearPos

QBrush linearPos(QBrush start, QBrush end, qreal pos)
{
    QColor c;
    c.setRedF(linearPos(start.color().redF(), end.color().redF(), pos));
    c.setGreenF(linearPos(start.color().greenF(), end.color().greenF(), pos));
    c.setBlueF(linearPos(start.color().blueF(), end.color().blueF(), pos));
    end.setColor(c);
    return end;
}
开发者ID:wangyun123,项目名称:Third,代码行数:9,代码来源:piesliceanimation.cpp

示例8: nameDateColor

QColor MediaView::nameDateColor(float64 over) {
	float64 mover = 1 - over;
	QColor result;
	result.setRedF(over * st::medviewNameOverColor->c.redF() + mover * st::medviewNameColor->c.redF());
	result.setGreenF(over * st::medviewNameOverColor->c.greenF() + mover * st::medviewNameColor->c.greenF());
	result.setBlueF(over * st::medviewNameOverColor->c.blueF() + mover * st::medviewNameColor->c.blueF());
	result.setAlphaF(over * st::medviewNameOverColor->c.alphaF() + mover * st::medviewNameColor->c.alphaF());
	return result;
}
开发者ID:CapnRat,项目名称:tdesktop,代码行数:9,代码来源:mediaview.cpp

示例9: getColorBottom

QColor SoRefXipLut::getColorBottom()
{
    if (!fldColorBottom) return QColor();
    QColor returnColor;
    returnColor.setRedF(fldColorBottom->getValue()[0]);
    returnColor.setGreenF(fldColorBottom->getValue()[1]);
    returnColor.setBlueF(fldColorBottom->getValue()[2]);
    return returnColor;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:9,代码来源:SoRefXipLut.cpp

示例10: makeColor

void ColorPickerForm::makeColor()
{
    QSize size = ui->label_color->size();
    QImage img = QImage(size, QImage::Format_ARGB32);

    int div = size.height() / 6;
    for (int i = 0; i < size.height(); i++)
    {
        QColor col = QColor(0, 0, 0);
        switch (i / div)
        {
            case 0:
                col.setRedF(1);
                col.setBlueF(1.0 - (float)(div - (i - div * 0)) / div);
                break;
            case 1:
                col.setBlueF(1);
                col.setRedF((float)(div - (i - div * 1)) / div);
                break;
            case 2:
                col.setBlueF(1);
                col.setGreenF(1.0 - (float)(div - (i - div * 2)) / div);
                break;
            case 3:
                col.setGreenF(1);
                col.setBlueF((float)(div - (i - div * 3)) / div);
                break;
            case 4:
                col.setGreenF(1);
                col.setRedF(1.0 - (float)(div - (i - div * 4)) / div);
                break;
            case 5:
                col.setRedF(1);
                col.setGreenF((float)(div - (i - div * 5)) / div);
                break;
        }
        for (int j = 0; j < size.width(); j++)
        {
            img.setPixel(j, i, col.rgba());
        }
    }
    ui->label_color->setPixmap(QPixmap::fromImage(img));
}
开发者ID:chocoball,项目名称:AnimationCreator,代码行数:43,代码来源:colorpickerform.cpp

示例11: elementToColor

QColor SimDomElement::elementToColor(QDomElement element)
{
	QColor color;
	
	color.setBlueF(element.attribute("Blue").toFloat());
	color.setGreenF(element.attribute("Green").toFloat());
	color.setRedF(element.attribute("Red").toFloat());
	color.setAlphaF(element.attribute("Alpha").toFloat());
	return color;
}
开发者ID:jsj2008,项目名称:roverSim,代码行数:10,代码来源:SimDomElement.cpp

示例12: ColorLerp

QColor ColorLerp(QColor &c1, QColor &c2, float t) {
  QColor out;
  out.setRedF(clamp<float>(c1.redF() * (1 - t) + c2.redF() * t, 0.0f, 1.0f));
  out.setGreenF(
      clamp<float>(c1.greenF() * (1 - t) + c2.greenF() * t, 0.0f, 1.0f));
  out.setBlueF(clamp<float>(c1.blueF() * (1 - t) + c2.blueF() * t, 0.0f, 1.0f));
  out.setAlphaF(
      clamp<float>(c1.alphaF() * (1 - t) + c2.alphaF() * t, 0.0f, 1.0f));
  return out;
}
开发者ID:RicardoBusta,项目名称:PixelBooster,代码行数:10,代码来源:pb_math.cpp

示例13: showSourceCode

void SourceCodeView::showSourceCode(const QString &absFileName, const int lineNum)
{
    QString fileText = fileHash.value(absFileName);

    if (fileText.isNull()) { // File not in hash
        m_currentFileName.clear();

        // Assume fileName is relative to directory
        QFile file(absFileName);

        if (!file.exists()) {
            clear();
            appendHtml(tr("<i>File %1 not available</i>").arg(absFileName));
            return;
        }
        if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
            clear();
            appendHtml(tr("<i>File %1 not readable</i>").arg(absFileName));
            return;
        }
        const QTextCodec *codec = QTextCodec::codecForName(m_codecName);
        const QByteArray contents = file.readAll();
        fileText = codec ? codec->toUnicode(contents) : QString::fromUtf8(contents);
        fileHash.insert(absFileName, fileText);
    }


    if (m_currentFileName != absFileName) {
        setPlainText(fileText);
        m_currentFileName = absFileName;
    }

    QTextCursor cursor = textCursor();
    cursor.setPosition(document()->findBlockByNumber(lineNum - 1).position());
    setTextCursor(cursor);
    centerCursor();
    cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
    cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);

    QTextEdit::ExtraSelection selectedLine;
    selectedLine.cursor = cursor;

    // Define custom color for line selection
    const QColor fg = palette().color(QPalette::Highlight);
    const QColor bg = palette().color(QPalette::Base);
    QColor col;
    const qreal ratio = 0.25;
    col.setRedF(fg.redF() * ratio + bg.redF() * (1 - ratio));
    col.setGreenF(fg.greenF() * ratio + bg.greenF() * (1 - ratio));
    col.setBlueF(fg.blueF() * ratio + bg.blueF() * (1 - ratio));

    selectedLine.format.setBackground(col);
    selectedLine.format.setProperty(QTextFormat::FullWidthSelection, true);
    setExtraSelections(QList<QTextEdit::ExtraSelection>() << selectedLine);
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:55,代码来源:sourcecodeview.cpp

示例14: spinBoxChanged

void CustomColorDialog::spinBoxChanged()
{
    if (m_blockUpdate)
        return;
    QColor newColor;
    newColor.setAlphaF(m_alphaSpinBox->value());
    newColor.setRedF(m_rSpinBox->value());
    newColor.setGreenF(m_gSpinBox->value());
    newColor.setBlueF(m_bSpinBox->value());
    setColor(newColor);
}
开发者ID:NoobSaibot,项目名称:qtcreator-minimap,代码行数:11,代码来源:customcolordialog.cpp

示例15: if

QColor SetMarkedObjectPropertyDlg::gray2PseudoColor(float grayValue)
{
    //将grayValue规范化到0~1之间
    if(grayValue < 0.0)
    {
        grayValue = 0.0;
    }
    if(grayValue > 1.0)
    {
        grayValue = 1.0;
    }

    QColor pseudoColor;

    if(grayValue < 0.25)
    {
        pseudoColor.setRedF(0.0);
        pseudoColor.setGreenF(grayValue * 4.0);
        pseudoColor.setBlueF(1.0);
    }
    else if(grayValue < 0.5)
    {
        pseudoColor.setRedF(0.0);
        pseudoColor.setGreenF(1.0);
        pseudoColor.setBlueF(1.0 - (grayValue - 0.25) * 4.0);
    }
    else if(grayValue < 0.75)
    {
        pseudoColor.setRedF((grayValue - 0.5) * 4.0);
        pseudoColor.setGreenF(1.0);
        pseudoColor.setBlueF(0.0);
    }
    else
    {
        pseudoColor.setRedF(1.0);
        pseudoColor.setGreenF(1.0 - (grayValue - 0.75) * 4.0);
        pseudoColor.setBlueF(0.0);
    }

    return pseudoColor;
}
开发者ID:JloveU,项目名称:IGITLandscapeViewer,代码行数:41,代码来源:SetMarkedObjectPropertyDlg.cpp


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