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


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

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


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

示例1: setRgbEdit

// show but don't set into selColor, nor emit colorSelected
void KColorDialog::KColorDialogPrivate::showColor(const QColor &color, const QString &name)
{
    bRecursion = true;

    if (name.isEmpty())
        colorName->setText(tr("-unnamed-"));
    else
        colorName->setText(name);

    patch->setColor(color);

    setRgbEdit(color);
    setHsvEdit(color);
    setHtmlEdit(color);


    switch (chooserMode()) {
    case ChooserSaturation:
        hsSelector->setValues(color.hue(), color.value());
        valuePal->setValue(color.saturation());
        break;
    case ChooserValue:
        hsSelector->setValues(color.hue(), color.saturation());
        valuePal->setValue(color.value());
        break;
    case ChooserRed:
        hsSelector->setValues(color.green(), color.blue());
        valuePal->setValue(color.red());
        break;
    case ChooserGreen:
        hsSelector->setValues(color.red(), color.blue());
        valuePal->setValue(color.green());
        break;
    case ChooserBlue:
        hsSelector->setValues(color.green(), color.red());
        valuePal->setValue(color.blue());
        break;
    case ChooserHue:
    default:
        hsSelector->setValues(color.saturation(), color.value());
        valuePal->setValue(color.hue());
        break;

    }

    bool blocked = valuePal->blockSignals(true);

    valuePal->setHue(color.hue());
    valuePal->setSaturation(color.saturation());
    valuePal->setColorValue(color.value());
    valuePal->updateContents();
    valuePal->blockSignals(blocked);
    valuePal->repaint();

    blocked = hsSelector->blockSignals(true);

    hsSelector->setHue(color.hue());
    hsSelector->setSaturation(color.saturation());
    hsSelector->setColorValue(color.value());
    hsSelector->updateContents();
    hsSelector->blockSignals(blocked);
    hsSelector->repaint();

    bRecursion = false;
}
开发者ID:Geekking,项目名称:lima,代码行数:66,代码来源:kcolordialog.cpp

示例2: backgroundBase

SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent, bool _static )
          : QSlider( q, _parent ), b_classic( _static )
{
    isSliding = false;
    f_buffering = 1.0;
    mHandleOpacity = 1.0;
    chapters = NULL;
    mHandleLength = -1;
    b_seekable = true;
    alternativeStyle = NULL;

    // prepare some static colors
    QPalette p = palette();
    QColor background = p.color( QPalette::Active, QPalette::Window );
    tickpointForeground = p.color( QPalette::Active, QPalette::WindowText );
    tickpointForeground.setHsv( tickpointForeground.hue(),
            ( background.saturation() + tickpointForeground.saturation() ) / 2,
            ( background.value() + tickpointForeground.value() ) / 2 );

    // set the background color and gradient
    QColor backgroundBase( p.window().color() );
    backgroundGradient.setColorAt( 0.0, backgroundBase.darker( 140 ) );
    backgroundGradient.setColorAt( 1.0, backgroundBase );

    // set the foreground color and gradient
    QColor foregroundBase( 50, 156, 255 );
    foregroundGradient.setColorAt( 0.0,  foregroundBase );
    foregroundGradient.setColorAt( 1.0,  foregroundBase.darker( 140 ) );

    // prepare the handle's gradient
    handleGradient.setColorAt( 0.0, p.window().color().lighter( 120 ) );
    handleGradient.setColorAt( 0.9, p.window().color().darker( 120 ) );

    // prepare the handle's shadow gradient
    QColor shadowBase = p.shadow().color();
    if( shadowBase.lightness() > 100 )
        shadowBase = QColor( 60, 60, 60 ); // Palette's shadow is too bright
    shadowDark = shadowBase.darker( 150 );
    shadowLight = shadowBase.lighter( 180 );
    shadowLight.setAlpha( 50 );

    /* Timer used to fire intermediate updatePos() when sliding */
    seekLimitTimer = new QTimer( this );
    seekLimitTimer->setSingleShot( true );

    /* Tooltip bubble */
    mTimeTooltip = new TimeTooltip( this );
    mTimeTooltip->setMouseTracking( true );

    /* Properties */
    setRange( MINIMUM, MAXIMUM );
    setSingleStep( 2 );
    setPageStep( 10 );
    setMouseTracking( true );
    setTracking( true );
    setFocusPolicy( Qt::NoFocus );

    /* Use the new/classic style */
    if( !b_classic )
    {
        alternativeStyle = new SeekStyle;
        setStyle( alternativeStyle );
    }

    /* Init to 0 */
    setPosition( -1.0, 0, 0 );
    secstotimestr( psz_length, 0 );

    animHandle = new QPropertyAnimation( this, "handleOpacity", this );
    animHandle->setDuration( FADEDURATION );
    animHandle->setStartValue( 0.0 );
    animHandle->setEndValue( 1.0 );

    hideHandleTimer = new QTimer( this );
    hideHandleTimer->setSingleShot( true );
    hideHandleTimer->setInterval( FADEOUTDELAY );

    CONNECT( this, sliderMoved( int ), this, startSeekTimer() );
    CONNECT( seekLimitTimer, timeout(), this, updatePos() );
    CONNECT( hideHandleTimer, timeout(), this, hideHandle() );
    mTimeTooltip->installEventFilter( this );
}
开发者ID:AsamQi,项目名称:vlc,代码行数:82,代码来源:input_slider.cpp

示例3: setCol

void ColorLuminancePicker::setCol(const QColor& c) {
    setCol(c.hue(), c.saturation(), c.value());
}
开发者ID:emmaai,项目名称:fractalM,代码行数:3,代码来源:colorluminancepicker.cpp

示例4: apply

		State Transformation::apply(const State& s, ColorPool* colorPool) const {
			State s2(s);
			s2.matrix = s.matrix*matrix; 

			if (absoluteColor) {
				// if the absolute hue is larger than 360, we will choose a random color.
				if (deltaH > 360) {

					QColor c = colorPool->drawColor();
					s2.hsv = Vector3f(c.hue(), c.saturation()/255.0, c.value()/255.0);
					s2.alpha = 1.0;
				} else {
					s2.hsv = Vector3f(deltaH,scaleS,scaleV);
					s2.alpha = scaleAlpha;
				}
			} else {
				float h = s2.hsv[0] + deltaH;
				float sat = s2.hsv[1]*scaleS;
				float v = s2.hsv[2]*scaleV;
				float a = s2.alpha * scaleAlpha;
				if (sat<0) sat=0;
				if (v<0) v=0;
				if (a<0) a=0;
				if (sat>1) sat=1;
				if (v>1) v=1;
				if (a>1) a=1;
				while (h>360) h-=360;
				while (h<0) h+=360;
				s2.hsv = Vector3f(h,sat,v);
				s2.alpha = a;

			}

			if (strength) {
				/*
				// We will blend the two colors (in RGB space)
				QColor original = QColor::fromHsv((int)(s2.hsv[0]),(int)(s2.hsv[1]*255.0),(int)(s2.hsv[2]*255.0));
				double r = original.red() + strength*blendColor.red();
				double g = original.green() + strength*blendColor.green();
				double b = original.blue() + strength*blendColor.blue();
				if (r<0) r=0;
				if (g<0) g=0;
				if (b<0) b=0;
				double max = r;
				if (g>max) max = g;
				if (b>max) max = b;
				if (max > 255) {
					r = r * 255 / max;
					g = g * 255 / max;
					b = b * 255 / max;
				}

				QColor mixed(r,g,b);
				
				
				s2.hsv = Vector3f(mixed.hue(), mixed.saturation()/255.0,mixed.value()/255.0);
				*/

				// We will blend the two colors (in HSV space)
				Vector3f bl = Vector3f(blendColor.hue(), blendColor.saturation()/255.0,blendColor.value()/255.0);
				Vector3f b(s2.hsv[0]+strength*bl[0], s2.hsv[1]+strength*bl[1], s2.hsv[2]+strength*bl[2]);
				b = b/(1+strength);
				while (b[0] < 0) b[0]+= 360;
				while (b[0] > 360) b[0]-= 360;
				if (b[1]>1) b[1]=1;
				if (b[2]>1) b[2]=1;
				if (b[1]<0) b[1]=0;
				if (b[2]<0) b[2]=0;
				s2.hsv = b;
				
				
				
			}

			return s2;
		}
开发者ID:34985086,项目名称:meshlab,代码行数:76,代码来源:Transformation.cpp

示例5: drawPrimitive


//.........这里部分代码省略.........

            if (option->state & State_Enabled)
                StyleHelper::drawCornerImage(d->lineeditImage, painter, option->rect, 5, 5, 5, 5);
            else
                StyleHelper::drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 5, 5, 5, 5);

            if (option->state & State_HasFocus || option->state & State_MouseOver) {
                QColor hover = StyleHelper::baseColor();
                if (state & State_HasFocus)
                    hover.setAlpha(100);
                else
                    hover.setAlpha(50);

                painter->setPen(QPen(hover, 1));
                painter->drawRect(QRectF(option->rect).adjusted(1.5, 1.5, -1.5, -1.5));
            }
            painter->restore();
        }
        break;

    case PE_FrameStatusBarItem:
        break;

    case PE_PanelButtonTool: {
            Animation *anim = d->animator.widgetAnimation(widget);
            if (!animating && anim) {
                anim->paint(painter, option);
            } else {
                bool pressed = option->state & State_Sunken || option->state & State_On;
                QColor shadow(0, 0, 0, 30);
                painter->setPen(shadow);
                if (pressed) {
                    QColor shade = option->palette.base().color();
                    shade.setHsv(shade.hue(), shade.saturation(), 255 - shade.value(), 40);
                    painter->fillRect(rect, shade);
                    painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight() - QPoint(1, 0));
                    painter->drawLine(rect.topLeft(), rect.bottomLeft());
                    painter->drawLine(rect.topRight(), rect.bottomRight());
                } else if (option->state & State_Enabled && option->state & State_MouseOver) {
                    painter->fillRect(rect, creatorTheme()->color(Theme::PanelButtonToolBackgroundColorHover));
                } else if (widget && widget->property("highlightWidget").toBool()) {
                    QColor shade(0, 0, 0, 128);
                    painter->fillRect(rect, shade);
                }
                if (option->state & State_HasFocus && (option->state & State_KeyboardFocusChange)) {
                    QColor highlight = option->palette.highlight().color();
                    highlight.setAlphaF(0.4);
                    painter->setPen(QPen(highlight.lighter(), 1));
                    highlight.setAlphaF(0.3);
                    painter->setBrush(highlight);
                    painter->setRenderHint(QPainter::Antialiasing);
                    const QRectF rect = option->rect;
                    painter->drawRoundedRect(rect.adjusted(2.5, 2.5, -2.5, -2.5), 2, 2);
                }
           }
        }
        break;

    case PE_PanelStatusBar:
        {
            if (creatorTheme()->widgetStyle() == Theme::StyleDefault) {
                painter->save();
                QLinearGradient grad = StyleHelper::statusBarGradient(rect);
                painter->fillRect(rect, grad);
                painter->setPen(QColor(255, 255, 255, 60));
                painter->drawLine(rect.topLeft() + QPoint(0,1),
开发者ID:AgnosticPope,项目名称:qt-creator,代码行数:67,代码来源:manhattanstyle.cpp

示例6: QColor

void 
BaseLayer( QImage* img, QImage* canvas, int radius, double strength)
///
/// Covers the canvas in large points. Hues are taken from the palette
///  but no color distortion is added at this point.
///
/// @param img
///  The reference image.
///
/// @param canvas
///  The canvas to store the filtered image.
///
/// @param radius
///  The radius of the points being used for the pointillism algorithm 
///  (actual point radius used will be larger for this stage of the algorithm).
///
/// @param strength
///  The strength of the pointillistic filter, where 1.0 is very strong and 0.0 is very weak.
///
/// @return
///  Nothing.
///
{
	// Adjust the point radius based on the strength of the filter
	if(strength < 0.5) {
		int new_radius = (int)radius*strength*2;
		if(1.0*new_radius < radius*strength*2) new_radius++;
		radius = new_radius;
		if(radius < 3) radius = 3;
	}

	// Clear the depth buffer ready for drawing
	uchar* depth_buffer = new uchar[img->width()*img->height()];
	for( int i = 0; i < img->width()*img->height(); i++ )
	{
		depth_buffer[i] = 0;
	}

	// Get a poisson disk sampling of the area, and repaint the sampled areas with a brush of small radius
	int spacing = radius*2;
	std::vector<QPoint> poisson = ImageProcessing::GetPoissonDisks(canvas->width(), canvas->height(), spacing);

	while(!poisson.empty()) {
		QPoint pos = poisson.back();
		poisson.pop_back();

		// Get the hue at this point and find the closest hue in the color palette
		QColor hsv = QColor(img->pixel(pos)).toHsv();
		int hue = hsv.hue();
		int sat = hsv.saturation();
		int val = hsv.value();

		hue = chevreul[ GetPaletteHuePosition( hue ) ];

		// Paint a point of the chosen hue at a random depth value
		hsv.setHsv(hue, sat, val);
		int z = rand()%256;
		DrawRandomCircle(canvas, pos, hsv.toRgb(), radius, z, depth_buffer);
	}
	poisson.clear();
	delete [] depth_buffer;
}
开发者ID:captaingarbonza,项目名称:image-filter-mixtures,代码行数:62,代码来源:PointillismFilter.cpp

示例7: filterImage


//.........这里部分代码省略.........

                    result.setPixel(x, y, qRgba(r, g, b, qAlpha(pixel)));
                }
            }
        }
    } else if (filter == tr("Làm ấm")) {
        // Nếu filter là "Làm ấm" thì bật QInputDialog lên cho người dùng
        // nhập vào giá trị, giá trị này trong khoảng 1 đến 255
        bool ok;  // Kiểm tra giá trị nhập
        int delta = QInputDialog::getInt(parent, tr("Lầm ấm"),
                                         tr("Nhập mức độ ấm:"),
                                         10, 1, 255, 1, &ok);
        // Hình sẽ trong ấm hơn nếu ta tăng độ vàng của ảnh, và màu vàng được
        // tổng hợp từ màu đỏ và xanh lục trong kênh màu RGB
        if (ok) {
            int r, g, b;

            for (int x = 0; x < original.width(); x++) {
                for (int y = 0; y < original.height(); y++) {

                    int pixel = original.pixel(x, y);

                    r = qRed(pixel) + delta;
                    g = qGreen(pixel) + delta;
                    b = qBlue(pixel);

                    //Ta kiểm tra các giá trị mới trong khoảng cho phép.
                    r = qBound(0, r, 255);
                    g = qBound(0, g, 255);

                    result.setPixel(x, y, qRgba(r, g, b, qAlpha(pixel)));
                }
            }
        }
    } else if (filter == tr("Làm mát...")) {
        // Nếu filter là "Làm mát" thì bật QInputDialog lên cho người dùng
        // nhập vào giá trị, giá trị này trong khoảng 1 đến 255
        bool ok;  // Kiểm tra giá trị nhập
        int delta = QInputDialog::getInt(parent, tr("Lầm mát"),
                                         tr("Nhập mức độ mát:"),
                                         10, 1, 256, 1, &ok);
        // Hình sẽ có cảm giác mát hơn khi ta tăng giá trị kênh màu xanh lam
        if (ok) {
            int r, g, b;

            for (int x = 0; x < original.width(); x++) {
                for (int y = 0; y < original.height(); y++) {

                    int pixel = original.pixel(x, y);

                    r = qRed(pixel);
                    g = qGreen(pixel);
                    b = qBlue(pixel) + delta;

                    //Ta kiểm tra giá trị mới trong khoảng cho phép.
                    b = qBound(0, b, 255);

                    result.setPixel(x, y, qRgba(r, g, b, qAlpha(pixel)));
                }
            }
        }
    } else if (filter == tr("Độ bão hòa")) {
        // Nếu filter là "Độ bão hòa" thì bật QInputDialog lên cho người dùng
        // nhập vào giá trị, giá trị này trong khoảng -255 đến 255
        bool ok; // Kiểm tra giá trị nhập vào
        int delta = QInputDialog::getInt(parent, tr("Độ bão hòa"),
                                         tr("Nhập độ bão hòa:"),
                                         10, -255, 255, 1, &ok);
        QColor newClolor;
        QColor oldColor;
        int h, s, l;

        // Ta chuyển hình về kênh màu HSL rồi sau đó tăng hoặc giảm kênh
        // saturation để tăng hoặc giảm độ bão hòa sau đó lại chuyển ảnh về RGB
        if (ok) {
            for (int y = 0; y < original.height(); ++y) {
                for (int x = 0; x < original.width(); ++x) {

                    oldColor = QColor(original.pixel(x, y));
                    newClolor = oldColor.toHsl();

                    h = newClolor.hue();
                    s = newClolor.saturation() + delta;
                    l = newClolor.lightness();

                    // Ta kiểm tra giá trị mới trong khoảng cho phép
                    s = qBound(0, s, 255);

                    newClolor.setHsl(h, s, l);

                    result.setPixel(x, y, qRgba(newClolor.red(),
                                                newClolor.green(),
                                                newClolor.blue(),
                                                newClolor.alpha()));
                }
            }
        }
    }
    return result;
}
开发者ID:manhtukhang,项目名称:mini-paint,代码行数:101,代码来源:extrafiltersplugin.cpp

示例8: initDefaults

void Manager::initDefaults()
{
    QPalette appPlt( QApplication::palette() );

    beginGroup("IDE");

    setDefault("startWithSession", "last");

    beginGroup("interpreter");
    setDefault("autoStart", true);
    endGroup();

    setDefault("postWindow/scrollback", 1000);

    beginGroup("editor");

    setDefault("spaceIndent", false);
    setDefault("indentWidth", 4);
    setDefault("stepForwardEvaluation", false);
    setDefault("lineWrap", true);
    setDefault("disableBlinkingCursor", false);
    setDefault("highlightBracketContents", true);
    setDefault("inactiveEditorFadeAlpha", 64);
    setDefault("insertMatchingTokens", false);

    setDefault("blinkDuration", 600);

    setDefault("font/family", "monospace");
    setDefault("font/antialias", true);

    beginGroup("colors");

    QTextCharFormat matchingBracketsFormat;
    matchingBracketsFormat.setForeground(Qt::red);
    matchingBracketsFormat.setBackground(QColor("#ffff7f"));
    matchingBracketsFormat.setFontWeight(QFont::Bold);
    setDefault("matchingBrackets", QVariant::fromValue(matchingBracketsFormat));

    QTextCharFormat bracketMismatchFormat;
    bracketMismatchFormat.setBackground(QColor(150,0,0));
    bracketMismatchFormat.setForeground(Qt::white);
    setDefault("mismatchedBrackets", QVariant::fromValue(bracketMismatchFormat));

    QTextCharFormat evaluatedCodeFormat;
    evaluatedCodeFormat.setBackground(QColor("#F8A200"));
    evaluatedCodeFormat.setForeground(Qt::black);
    setDefault("evaluatedCode", QVariant::fromValue(evaluatedCodeFormat));

    QTextCharFormat currentLineFormat;
    {
        QColor bkg = appPlt.color(QPalette::Base);
        int value = bkg.value();
        if (value > 40)
            bkg.setHsv( bkg.hue(), bkg.saturation(), value - 11);
        else
            bkg.setHsv( bkg.hue(), bkg.saturation(), value + 20 );
        currentLineFormat.setBackground(bkg.toRgb());
    }
    setDefault("currentLine", QVariant::fromValue(currentLineFormat));

    QTextCharFormat searchResultFormat;
    searchResultFormat.setBackground(appPlt.color(QPalette::Highlight).darker(200));
    searchResultFormat.setForeground(appPlt.color(QPalette::HighlightedText).darker(200));
    setDefault("searchResult", QVariant::fromValue(searchResultFormat));

    endGroup(); // colors

    beginGroup("highlighting");
    initHighlightingDefaults();
    endGroup(); // highlighting

    endGroup(); // editor

    endGroup(); // IDE
}
开发者ID:Maurorddr,项目名称:supercollider,代码行数:75,代码来源:manager.cpp

示例9: drawDial

static
void drawDial ( const QStyleOptionSlider *option, QPainter *painter )
{
	QPalette pal = option->palette;
	QColor buttonColor = pal.button().color();
	const int width = option->rect.width();
	const int height = option->rect.height();
	const bool enabled = option->state & QStyle::State_Enabled;
	qreal r = qMin(width, height) / 2;
	r -= r/50;
	const qreal penSize = r/20.0;

	painter->save();
	painter->setRenderHint(QPainter::Antialiasing);

	// Draw notches
	if (option->subControls & QStyle::SC_DialTickmarks) {
		painter->setPen(option->palette.dark().color().darker(120));
		painter->drawLines(calcLines(option));
	}

	// Cache dial background
	QString a = QString::fromLatin1("qdial");
	QRect rect = option->rect;
	QPixmap internalPixmapCache;
	QImage imageCache;
	QPainter *p = painter;
	QString unique = uniqueName((a), option, option->rect.size());
	int txType = painter->deviceTransform().type() | painter->worldTransform().type();
	bool doPixmapCache = txType <= QTransform::TxTranslate;
	if (doPixmapCache && QPixmapCache::find(unique, internalPixmapCache)) {
		painter->drawPixmap(option->rect.topLeft(), internalPixmapCache);
	} else {
		if (doPixmapCache) {
			rect.setRect(0, 0, option->rect.width(), option->rect.height());
			imageCache = QImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
			imageCache.fill(0);
			p = new QPainter(&imageCache);
		}
	//--BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("qdial"));

		p->setRenderHint(QPainter::Antialiasing);

		const qreal d_ = r / 6;
		const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
		const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;

		QRectF br = QRectF(dx + 0.5, dy + 0.5,
						   int(r * 2 - 2 * d_ - 2),
						   int(r * 2 - 2 * d_ - 2));
		buttonColor.setHsv(buttonColor .hue(),
						   qMin(140, buttonColor .saturation()),
						   qMax(180, buttonColor.value()));
		QColor shadowColor(0, 0, 0, 20);

		if (enabled) {
			// Drop shadow
			qreal shadowSize = qMax(1.0, penSize/2.0);
			QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize,
										   2*shadowSize, 2*shadowSize);
			QRadialGradient shadowGradient(shadowRect.center().x(),
										   shadowRect.center().y(), shadowRect.width()/2.0,
										   shadowRect.center().x(), shadowRect.center().y());
			shadowGradient.setColorAt(qreal(0.91), QColor(0, 0, 0, 40));
			shadowGradient.setColorAt(qreal(1.0), Qt::transparent);
			p->setBrush(shadowGradient);
			p->setPen(Qt::NoPen);
			p->translate(shadowSize, shadowSize);
			p->drawEllipse(shadowRect);
			p->translate(-shadowSize, -shadowSize);

			// Main gradient
			QRadialGradient gradient(br.center().x() - br.width()/3, dy,
									 br.width()*1.3, br.center().x(),
									 br.center().y() - br.height()/2);
			gradient.setColorAt(0, buttonColor.lighter(110));
			gradient.setColorAt(qreal(0.5), buttonColor);
			gradient.setColorAt(qreal(0.501), buttonColor.darker(102));
			gradient.setColorAt(1, buttonColor.darker(115));
			p->setBrush(gradient);
		} else {
			p->setBrush(Qt::NoBrush);
		}

		p->setPen(QPen(buttonColor.darker(280)));
		p->drawEllipse(br);
		p->setBrush(Qt::NoBrush);
		p->setPen(buttonColor.lighter(110));
		p->drawEllipse(br.adjusted(1, 1, -1, -1));

		if (option->state & QStyle::State_HasFocus) {
			QColor highlight = pal.highlight().color();
			highlight.setHsv(highlight.hue(),
							 qMin(160, highlight.saturation()),
							 qMax(230, highlight.value()));
			highlight.setAlpha(127);
			p->setPen(QPen(highlight, 2.0));
			p->setBrush(Qt::NoBrush);
			p->drawEllipse(br.adjusted(-1, -1, 1, 1));
		}
//.........这里部分代码省略.........
开发者ID:rncbc,项目名称:qmidictl,代码行数:101,代码来源:qmidictlDialStyle.cpp

示例10: invertColor

static inline QColor invertColor(const QColor color)
{
    QColor c = color.toHsv();
    c.setHsv(c.hue(), c.saturation(), 255 - c.value());
    return c;
}
开发者ID:anchowee,项目名称:QtCreator,代码行数:6,代码来源:gradientline.cpp

示例11: writeCollectionBlock

// Write CollectionBlock keywords
bool UChromaSession::writeCollectionBlock(LineParser& parser, Collection* collection, Collection::CollectionType type, int indentLevel)
{
	// Construct indent string
	char* indent = new char[indentLevel*2+1];
	for (int n=0; n<indentLevel*2; ++n) indent[n] = ' ';
	indent[indentLevel*2] = '\0';

	if (type == Collection::MasterCollection) parser.writeLineF("%s%s '%s'\n", indent, UChromaSession::inputBlock(UChromaSession::CollectionBlock), qPrintable(collection->name()));
	else if (type == Collection::FitCollection) parser.writeLineF("%s%s '%s'\n", indent, UChromaSession::collectionKeyword(UChromaSession::FitBlockKeyword), qPrintable(collection->name()));
	else if (type == Collection::ExtractedCollection) parser.writeLineF("%s%s '%s'\n", indent, UChromaSession::collectionKeyword(UChromaSession::SliceBlockKeyword), qPrintable(collection->name()));
	parser.writeLineF("%s  %s \"%s\"\n", indent, UChromaSession::collectionKeyword(UChromaSession::DataDirectoryKeyword), qPrintable(collection->dataFileDirectory().absolutePath()));

	// -- Transforms
	parser.writeLineF("%s  %s %s %s\n", indent, UChromaSession::collectionKeyword(UChromaSession::TransformXKeyword), stringBool(collection->transformEnabled(0)), qPrintable(collection->transformEquation(0)));
	parser.writeLineF("%s  %s %s %s\n", indent, UChromaSession::collectionKeyword(UChromaSession::TransformYKeyword), stringBool(collection->transformEnabled(1)), qPrintable(collection->transformEquation(1)));
	parser.writeLineF("%s  %s %s %s\n", indent, UChromaSession::collectionKeyword(UChromaSession::TransformZKeyword), stringBool(collection->transformEnabled(2)), qPrintable(collection->transformEquation(2)));

	// -- Interpolation
	parser.writeLineF("%s  %s %s %s\n", indent, UChromaSession::collectionKeyword(UChromaSession::InterpolateKeyword), stringBool(collection->interpolate(0)), stringBool(collection->interpolate(2)));
	parser.writeLineF("%s  %s %s %s\n", indent, UChromaSession::collectionKeyword(UChromaSession::InterpolateConstrainKeyword), stringBool(collection->interpolateConstrained(0)), stringBool(collection->interpolateConstrained(2)));
	parser.writeLineF("%s  %s %f %f\n", indent, UChromaSession::collectionKeyword(UChromaSession::InterpolateStepKeyword), collection->interpolationStep(0), collection->interpolationStep(2));

	// Colour Setup
	parser.writeLineF("%s  %s '%s'\n", indent, UChromaSession::collectionKeyword(UChromaSession::ColourSourceKeyword), Collection::colourSource(collection->colourSource()));
	ColourScalePoint* csp;
	QColor colour;
	double value;
	// -- Single Colour
	colour = collection->colourScalePointColour(Collection::SingleColourSource);
	parser.writeLineF("%s  %s %i %i %i %i\n", indent, UChromaSession::collectionKeyword(UChromaSession::ColourSingleKeyword), colour.red(), colour.green(), colour.blue(), colour.alpha());
	// -- RGB Gradient
	colour = collection->colourScalePointColour(Collection::RGBGradientSource, 0);
	value = collection->colourScalePointValue(Collection::RGBGradientSource, 0);
	parser.writeLineF("%s  %s %f %i %i %i %i\n", indent, UChromaSession::collectionKeyword(UChromaSession::ColourRGBGradientAKeyword), value, colour.red(), colour.green(), colour.blue(), colour.alpha());
	colour = collection->colourScalePointColour(Collection::RGBGradientSource, 1);
	value = collection->colourScalePointValue(Collection::RGBGradientSource, 1);
	parser.writeLineF("%s  %s %f %i %i %i %i\n", indent, UChromaSession::collectionKeyword(UChromaSession::ColourRGBGradientBKeyword), value, colour.red(), colour.green(), colour.blue(), colour.alpha());
	// -- HSV Gradient
	colour = collection->colourScalePointColour(Collection::HSVGradientSource, 0);
	value = collection->colourScalePointValue(Collection::HSVGradientSource, 0);
	parser.writeLineF("%s  %s %f %i %i %i %i\n", indent, UChromaSession::collectionKeyword(UChromaSession::ColourHSVGradientAKeyword), value, colour.hue(), colour.saturation(), colour.value(), colour.alpha());
	colour = collection->colourScalePointColour(Collection::HSVGradientSource, 1);
	value = collection->colourScalePointValue(Collection::HSVGradientSource, 1);
	parser.writeLineF("%s  %s %f %i %i %i %i\n", indent, UChromaSession::collectionKeyword(UChromaSession::ColourHSVGradientBKeyword), value, colour.hue(), colour.saturation(), colour.value(), colour.alpha());
	// -- Custom Gradient
	for (csp = collection->customColourScalePoints(); csp != NULL; csp = csp->next)
	{
		parser.writeLineF("%s  %s %f %i %i %i %i\n", indent, UChromaSession::collectionKeyword(UChromaSession::ColourCustomGradientKeyword), csp->value(), csp->colour().red(), csp->colour().green(), csp->colour().blue(), csp->colour().alpha());
	}
	// -- Alpha control
	parser.writeLineF("%s  %s '%s'\n", indent, UChromaSession::collectionKeyword(UChromaSession::ColourAlphaControlKeyword), Collection::alphaControl(collection->alphaControl()));
	parser.writeLineF("%s  %s %f\n", indent, UChromaSession::collectionKeyword(UChromaSession::ColourAlphaFixedKeyword), collection->fixedAlpha());

	// Display
	parser.writeLineF("%s  %s %f '%s'\n", indent, UChromaSession::collectionKeyword(UChromaSession::LineStyleKeyword), collection->displayLineStyle().width(), LineStipple::stipple[collection->displayLineStyle().stipple()].name);
	parser.writeLineF("%s  %s %f\n", indent, UChromaSession::collectionKeyword(UChromaSession::ShininessKeyword), collection->displaySurfaceShininess());
	parser.writeLineF("%s  %s %s\n", indent, UChromaSession::collectionKeyword(UChromaSession::StyleKeyword), Collection::displayStyle(collection->displayStyle()));
	parser.writeLineF("%s  %s %s\n", indent, UChromaSession::collectionKeyword(UChromaSession::VisibleCollectionKeyword), stringBool(collection->visible()));

	// Loop over datasets
	for (DataSet* dataSet = collection->dataSets(); dataSet != NULL; dataSet = dataSet->next) writeDataSetBlock(parser, dataSet, indentLevel);

	// Write FitKernel data if present
	if (collection->fitKernel()) writeFitParametersBlock(parser, collection->fitKernel(), indentLevel);

	// Additional data
	// -- Fits
	for (Collection* fit = collection->fits(); fit != NULL; fit = fit->next) writeCollectionBlock(parser, fit, Collection::FitCollection, indentLevel+1);
	// -- Extracted Data
	for (Collection* extract = collection->slices(); extract != NULL; extract = extract->next) writeCollectionBlock(parser, extract, Collection::ExtractedCollection, indentLevel+1);

	parser.writeLineF("%s%s\n", indent, UChromaSession::collectionKeyword(UChromaSession::EndCollectionKeyword));

	return true;
}
开发者ID:trisyoungs,项目名称:uchroma,代码行数:76,代码来源:save.cpp

示例12: paintEvent

void SectionViewWidget::paintEvent(QPaintEvent *event)
{
	QPainter painter(this);
	painter.save();

	MainFrame* pMainFrame = (MainFrame*)s_pMainFrame;

	QPen LinePen;
	LinePen.setColor(QColor(255,0,0));
	LinePen.setWidth(2);
	painter.setPen(LinePen);
	painter.fillRect(rect(), pMainFrame->m_BackgroundColor);

	painter.setFont(pMainFrame->m_TextFont);

	if(m_bZoomIn&& !m_ZoomRect.isEmpty())
	{
		QRect ZRect = m_ZoomRect.normalized();
		QPen ZoomPen(QColor(100,100,100));
		ZoomPen.setStyle(Qt::DashLine);
		painter.setPen(ZoomPen);
		painter.drawRect(ZRect);
	}

	if(m_bNeutralLine)
	{
		QPen NPen(m_NeutralColor);
		NPen.setStyle(GetStyle(m_NeutralStyle));
		NPen.setWidth(m_NeutralWidth);
		painter.setPen(NPen);

		painter.drawLine(rect().right(), m_ptOffset.y(), rect().left(), m_ptOffset.y());
		painter.drawLine(m_ptOffset.x(), rect().bottom(), m_ptOffset.x(), rect().top());
	}

	if(!s_bCurrentOnly && m_pSail /* && m_pSail->IsSailcutSail()*/)
	{
		QColor clr = m_pSailSection->m_SCSpline.m_SplineColor;
		clr.setHsv(clr.hue(), (int)(clr.saturation()), (int)(clr.value()*.29));
		QPen OtherPen(clr);
		OtherPen.setStyle(Qt::DashLine);
		OtherPen.setWidth(1.0);
		painter.setPen(OtherPen);

		for(int is=0; is<m_pSail->m_oaSection.size(); is++)
		{
			SailSection *pSection = (SailSection*)m_pSail->m_oaSection.at(is);
			if(pSection != m_pSailSection)
			{
				if(m_pSail->IsSailcutSail()) pSection->DrawSpline(painter, m_Scale,m_Scale*m_ScaleY, m_ptOffset, false);
				else
				{
					NURBSSail *pNSail = (NURBSSail*)m_pSail;
					int index = m_pSail->m_oaSection.indexOf(m_pSailSection);
					if(is!=index) pNSail->DrawFrame(is, painter, m_Scale, m_Scale*m_ScaleY, m_ptOffset);

				}
			}
		}
	}

	if(m_pSailSection)
	{
		if(m_pSail->IsNURBSSail())
		{
			NURBSSail *pNSail = (NURBSSail*)m_pSail;
			int index = m_pSail->m_oaSection.indexOf(m_pSailSection);
			QPen SplinePen;
			SplinePen.setStyle(GetStyle(m_pSailSection->m_SCSpline.m_Style));
			SplinePen.setWidth(m_pSailSection->m_SCSpline.m_Width);
			SplinePen.setColor(m_pSailSection->m_SCSpline.m_SplineColor);
			painter.setPen(SplinePen);

//			if(index==0 || index==m_pSail->m_oaSection.size()-1)
			{
				pNSail->DrawFrame(index, painter, m_Scale, m_Scale*m_ScaleY, m_ptOffset);
			}

			m_pSailSection->DrawCtrlPoints(painter, m_Scale, m_Scale*m_ScaleY, m_ptOffset);
		}
		else
		{
			m_pSailSection->DrawSpline(painter, m_Scale, m_Scale*m_ScaleY, m_ptOffset);
		}
	}


	QPen TextPen(pMainFrame->m_TextColor);
	painter.setPen(TextPen);
	PaintLegend(painter);

	QString str;

	str = QString("X-Scale = %1").arg(m_Scale/m_RefScale,4,'f',1);
	painter.drawText(5,10, str);
	str = QString("Y-Scale = %1").arg(m_ScaleY*m_Scale/m_RefScale,4,'f',1);
	painter.drawText(5,22, str);
	str = QString("x  = %1").arg(m_MousePos.x,7,'f',4);
	painter.drawText(5,34, str);
	str = QString("y  = %1").arg(m_MousePos.y,7,'f',4);
//.........这里部分代码省略.........
开发者ID:kolzar,项目名称:sail7,代码行数:101,代码来源:SectionViewWidget.cpp

示例13: borderColor

QColor StyleHelper::borderColor(bool lightColored) {
  QColor result = baseColor(lightColored);
  result.setHsv(result.hue(), result.saturation(), result.value() / 2);
  return result;
}
开发者ID:Aceler,项目名称:Clementine,代码行数:5,代码来源:stylehelper.cpp

示例14: shadowColor

QColor StyleHelper::shadowColor(bool lightColored) {
  QColor result = baseColor(lightColored);
  result.setHsv(result.hue(), clamp(result.saturation() * 1.1),
                clamp(result.value() * 0.70));
  return result;
}
开发者ID:Aceler,项目名称:Clementine,代码行数:6,代码来源:stylehelper.cpp

示例15: QPoint


//.........这里部分代码省略.........
	// Adjust the point radius based on the strength of the filter
	if(strength < 0.5) 
	{
		int new_radius = (int)radius*strength*2;
		if(1.0*new_radius < radius*strength*2) new_radius++;
		radius = new_radius;
		if(radius < 1) radius = 1;
	}

	// Get gray scale of original image
	uchar* gray = new uchar[img->width()*img->height()];
	ImageProcessing::ConvertToOneChannel( img->bits(), gray, img->width(), img->height() );

	// Blur the grayscale image
	uchar* smoothed_gray = new uchar[img->width()*img->height()];
	int kernel = radius;
	if(kernel%2 == 0) kernel++;
	if(kernel < 3) kernel = 3;
	ImageProcessing::GaussianBlur( gray, smoothed_gray, img->width(), img->height(), 1, kernel );
	delete [] gray;

	// Clear the depth buffer ready for painting
	uchar* depth_buffer = new uchar[img->width()*img->height()];
	for( int i = 0; i < img->width()*img->height(); i++ )
	{
		depth_buffer[i] = 0;
	}

	// At each grid point, find maximum error based on difference
	// between intensity at canvas and intensity of blurred image
	// Paint stroke at this location
	for( int y = (int)radius/2; y < img->height(); y += radius ) 
	{
		for( int x = (int)radius/2; x < img->width(); x += radius ) 
		{
			int total_error = 0;
			int max_error = 0;
			QPoint max_error_at = QPoint(0, 0);

			// Get error of each pixel in the neighbourhood
			int min_x = x - radius/2;
			int min_y = y - radius/2;
			int max_x = x + radius/2;
			int max_y = y + radius/2;

			if(min_x < 0) min_x = 0;
			if(min_y < 0) min_y = 0;
			if(max_x >= img->width()) max_x = img->width() - 1;
			if(max_y >= img->height()) max_y = img->height() - 1;

			for( int j = min_y; j <= max_y; j++ ) 
			{
				for( int i = min_x; i <= max_x; i++ ) 
				{
					
					// Get error at this pixel
					int intensity = QColor(canvas->pixel( i, j )).toHsv().value();
					int error = abs(intensity - smoothed_gray[j*img->width() + i]);

					// Update error stats
					total_error += error;
					if( error > max_error ) 
					{
						max_error = error;
						max_error_at = QPoint( i, j );
					}
				}
			}

			// If the total error is above a threshold
			// Paint a stroke at the area of max error
			if( total_error > 10*strength ) 
			{
				QColor hsv = QColor(img->pixel( x, y )).toHsv();
				int hue = hsv.hue();
				int sat = hsv.saturation();
				int v = hsv.value();

				// Find closest hue in palette, make a method that does this
				int new_pos = GetPaletteHuePosition( hsv.hue() );
				if( (rand()%100)/100.0 < strength ) 
				{
					hue = GetRandomNeighbour(new_pos);
				} 
				else 
				{
					hue = chevreul[new_pos];
				}
				
				sat = ChangeSaturation(sat, v, 0.35*strength, strength);
				hsv.setHsv( hue, sat, v );

				int z = rand()%256;
				DrawRandomCircle(canvas, max_error_at, hsv.toRgb(), radius, z, depth_buffer);
			}
		}
	}
	delete [] smoothed_gray;
	delete [] depth_buffer;
}
开发者ID:captaingarbonza,项目名称:image-filter-mixtures,代码行数:101,代码来源:PointillismFilter.cpp


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