本文整理汇总了C++中QRadialGradient::setColorAt方法的典型用法代码示例。如果您正苦于以下问题:C++ QRadialGradient::setColorAt方法的具体用法?C++ QRadialGradient::setColorAt怎么用?C++ QRadialGradient::setColorAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRadialGradient
的用法示例。
在下文中一共展示了QRadialGradient::setColorAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rect
WaitingDialog::WaitingDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::WaitingDialog)
{
ui->setupUi(this);
m_rot = 0;
QGraphicsScene* scene = new QGraphicsScene();
ui->graphicsView->setScene(scene);
QRect rect(0,0,50,50);
m_startPoint = QPoint(0,ui->graphicsView->rect().size().height()/2);
m_endPoint = QPoint(ui->graphicsView->rect().size().width(),ui->graphicsView->rect().size().height()/2);
QRadialGradient rg = QRadialGradient(10,10,45.0);
QColor mcol(Qt::blue);
mcol.setAlpha(255);
rg.setColorAt(0.0,Qt::white);
mcol.setBlue(mcol.blue()-15);
rg.setColorAt(0.5,mcol);
mcol.setBlue(mcol.blue()+15);
rg.setColorAt(1.0,mcol);
QPen pen(mcol);
QPixmap pm(rect.size()+QSize(1,1));
pm.fill(Qt::transparent);
QPainter p(&pm);
p.setBackgroundMode(Qt::TransparentMode);
p.setBrush(rg);
p.setPen(pen);
p.drawEllipse(rect);
m_ellipse = new MyItem(pm);
m_ellipse->setPos(m_startPoint);
ui->graphicsView->scene()->addItem(m_ellipse);
m_anim = new QPropertyAnimation(m_ellipse,"pos");
connect(m_anim,SIGNAL(finished()),this,SLOT(animFinished()));
m_anim->setEasingCurve(QEasingCurve::OutBounce);
m_anim->setStartValue(m_startPoint);
m_anim->setEndValue(m_endPoint);
m_anim->setDuration(2000);
m_anim->setLoopCount(1);
m_anim->start();
m_timer = new QTimer(this);
connect(m_timer,SIGNAL(timeout()),this,SLOT(timeout()));
m_timer->setInterval(100);
#if defined(Q_OS_SYMBIAN)
this->showMaximized();
#else
this->show();
#endif
m_timer->start();
}
示例2: updateMask
void EditorMagnifierItem::updateMask()
{
QRectF current = getRect();
QSize box = QSize( current.width(), current.width() );
// reupdate our mask
if (m_imgMask.size() != box)
{
int radius = box.width() / 2;
int ring = radius - 10;
m_imgMask = QPixmap(box);
m_imgMask.fill(Qt::transparent);
QRadialGradient g;
g.setCenter(radius, radius);
g.setFocalPoint(radius, radius);
g.setRadius(radius);
g.setColorAt( 1.0, QColor(255, 255, 255, 0) );
g.setColorAt( 0.5, QColor(128, 128, 128, 255) );
QPainter mask(&m_imgMask);
mask.setRenderHint(QPainter::Antialiasing);
mask.setCompositionMode(QPainter::CompositionMode_Source);
mask.setBrush(g);
mask.setPen(Qt::NoPen);
mask.drawRect( m_imgMask.rect() );
mask.setBrush( QColor(Qt::transparent) );
mask.drawEllipse(g.center(), ring, ring);
mask.end();
}
}
示例3: paint
//!
//! Paints the graphics item into a graphics view.
//!
//! \param painter The object to use for painting.
//! \param option Style options for painting the graphics item.
//! \param widget The widget into which to paint the graphics item.
//!
void PinGraphicsItem::paint ( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget /* = 0 */ )
{
const QColor penColor (30, 30, 30);
QRadialGradient radialGradient (rect().center(), 5);
radialGradient.setColorAt(1, m_color.darker(200));
radialGradient.setColorAt(0, m_color);
// set the brush
QBrush brush;
if (isEnabled())
if (m_hovered && m_clicked)
radialGradient.setColorAt(0.5, m_color.lighter(100));
else if (m_hovered || m_clicked)
radialGradient.setColorAt(0.5, m_color.lighter(100));
else
radialGradient.setColorAt(0.5, m_color.darker(150));
else
brush = Qt::NoBrush;
// paint the pin
brush = QBrush(radialGradient);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(QPen(QBrush(penColor), 1));
painter->setBrush(brush);
painter->drawEllipse(rect().center(), 5, 5);
// check if the parameter the pin represents is a parameter group
//if (m_abstractParameter && m_abstractParameter->isGroup()) {
// painter->setPen(QPen(penColor));
// painter->setBrush(QBrush(QColor(Qt::black)));
// painter->setRenderHint(QPainter::Antialiasing);
// if (m_abstractParameter->getName().isEmpty()) {
// // draw two dots for parameter roots
// painter->drawEllipse(rect().center() + QPointF(-2, 0.5), 1, 1);
// painter->drawEllipse(rect().center() + QPointF(2, 0.5), 1, 1);
// } else
// // draw one dot for other parameter groups
// painter->drawEllipse(rect().center(), 1, 1);
//}
if (m_isGroup) {
painter->setPen(QPen(penColor));
painter->setBrush(QBrush(QColor(Qt::black)));
painter->setRenderHint(QPainter::Antialiasing);
if (m_isRootGroup) {
// draw two dots for parameter roots
painter->drawEllipse(rect().center() + QPointF(-2, 0.5), 1, 1);
painter->drawEllipse(rect().center() + QPointF(2, 0.5), 1, 1);
} else
// draw one dot for other parameter groups
painter->drawEllipse(rect().center(), 1, 1);
}
}
示例4: repaint
void DashBar::repaint(QPainter &painter){
float v;
float min = qMin(value1,value2);
float max = qMax(value1,value2);
int size = orientation == Qt::Horizontal? width-10 : height-10;
QRadialGradient gradient;
QPen pen(Qt::black);
pen.setWidth(1);
painter.save();
painter.setRenderHint(QPainter::Antialiasing);
painter.translate(x,y);
gradient = QRadialGradient(QPointF(0,0), qSqrt(width*width+height*height)*2, QPointF(0,0));
gradient.setColorAt(0, QColor(224,224,224));
gradient.setColorAt(1, QColor(28,28,28));
painter.setPen(pen);
painter.setBrush(QBrush(gradient));
painter.drawRect(0,0,width, height);
gradient = QRadialGradient(QPointF(width,height), qSqrt(width*width+height*height)*2, QPointF(width,height));
gradient.setColorAt(0, QColor(88,88,88));
gradient.setColorAt(1, QColor(28,28,28));
painter.setPen(pen);
painter.setBrush(QBrush(gradient));
painter.drawRect(5,5,width-10,height-10);
painter.setBrush(Qt::white);
painter.setPen(Qt::white);
if(value>max)value = max;
if(value<min)value = min;
v = (max-value)/(max-min)*size;
for(int i=0; i<size; i+=4){
if(i>size*0.4f){
painter.setPen(i>=v || isSelected? Qt::green : QColor(Qt::green).darker());
}else if(i>=size*0.1f && i<=size*0.4f){
painter.setPen(i>=v || isSelected? Qt::yellow : QColor(Qt::yellow).darker());
}else{
painter.setPen(i>=v || isSelected? Qt::red : QColor(Qt::red).darker());
}
if(orientation == Qt::Horizontal){ //Orizzontale
painter.drawLine(width-6-i,6,width-6-i,height-6); //Linee verticali
}else{
painter.drawLine(6,6+i,width-6,6+i);
}
}
painter.restore();
}
示例5: paint
void Highlight::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QColor pen_color = pen.color();
painter->setPen(pen);
if(time < total_time ){ //don't want to keep adding them past animation length
int expected_num_rings = (int)ceil(frequency * time);
if( expected_num_rings > rings.length()){
rings.append(time);
}
//velocity= 200.0 - (time*total_time*2.0);//pretty cool
//velocity= 200.0*(1.0-done_ratio);//pretty cool, about the same
//frequency = 3.0*(1.0-done_ratio);//pretty cool
for(int i=0; i<rings.length(); i++){
//qreal dist = diameter + ( velocity * (time - rings.at(i)));
qreal t = (time - rings.at(i));
qreal dist = diameter + ( velocity * t ) + (0.5 * -5.0 * t*t);
//qDebug() << "dist:" << dist << " outerDiameter:" << outerDiameter;
QRectF s(x()-dist/2.0, y()-dist/2.0,dist,dist);
QRectF r = mapRectFromScene(x()-dist/2.0, y()-dist/2.0,dist,dist);
pen.setWidth(20.0+50.0* dist/outerDiameter);
QRadialGradient radialGrad;
radialGrad.setCenter(r.center());
radialGrad.setFocalPoint(r.center());
radialGrad.setCenterRadius(r.width()/2.0+pen.widthF()/2.0);
radialGrad.setFocalRadius(r.width()/2.0-pen.widthF()/2.0);
/* not entirely sure I get it, but I think focal radius
* needs to be either the center of the pen or its inner edge
* while center radius is the outer edge.
*/
QColor green(0,255,0,255);
QColor yellow(255,255,0,255);
/*
pen_color.setAlphaF(1.0-(dist/outerDiameter)); //surface waves don't inverse square
*/
green.setAlphaF(1.0-(dist/outerDiameter));
yellow.setAlphaF((1.0-(dist/outerDiameter)));
radialGrad.setColorAt(.0, yellow );
radialGrad.setColorAt( .5, green );
radialGrad.setColorAt(1, yellow );
brush = QBrush(radialGrad);
pen.setBrush(brush);
painter->setPen(pen);
painter->drawEllipse(r);
}
}
}
示例6: paint
void BrushEngine::paint(const QPointF& point, float pressure) {
QPainter painter(eraser > 50 ? canvasItem->getPixmap() : canvasBuffer->getPixmap());
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(Qt::NoPen);
if (eraser > 50) {
painter.setCompositionMode(QPainter::CompositionMode_DestinationOut);
}
color.setAlpha(qRound(255 * flow / 100.0));
QColor pressureColor = color;
pressureColor.setAlpha(qRound(color.alpha() * pressure));
QColor alphaColor = color;
alphaColor.setAlpha(0);
QRadialGradient radialGradient;
radialGradient.setRadius(size / 2.0);
radialGradient.setColorAt(0, pressureColor);
radialGradient.setColorAt(1, alphaColor);
radialGradient.setColorAt(hardness / 100.0, pressureColor);
painter.setBrush(QBrush(radialGradient));
if (startPoint.isNull()) {
startPoint = QPointF(point);
lastPoint = QPointF(point);
topleft = QPoint(0, 0);
bottomright = QPoint(canvasBuffer->getPixmap()->width(), canvasBuffer->getPixmap()->height());
paintDab(point, painter);
} else {
qreal length = qSqrt(qPow(lastPoint.x() - point.x(), 2) + qPow(lastPoint.y() - point.y(), 2));
qreal delta = size * spacing / 2.0 / 100.0;
if (length >= delta) {
int dabs = qRound(length / delta);
qreal angle = qAtan2(point.x() - lastPoint.x(), point.y() - lastPoint.y());
qreal deltaX = delta * qSin(angle);
qreal deltaY = delta * qCos(angle);
QPointF betweenPoint;
for (int i = 1; i <= dabs; i++) {
qreal x = lastPoint.x() + deltaX * i +
(10000 - qrand() % 20000) / 10000.0 * size * jitter / 100;
qreal y = lastPoint.y() + deltaY * i +
(10000 - qrand() % 20000) / 10000.0 * size * jitter / 100;
betweenPoint = QPointF(x, y);
paintDab(betweenPoint, painter);
}
lastPoint = betweenPoint;
}
}
}
示例7: updateBrush
void PainterWidget::updateBrush()
{
QRadialGradient g;
g.setCenter(brush_size/2, brush_size/2);
g.setFocalPoint(brush_size/2, brush_size/2);
g.setRadius(brush_size/2);
g.setColorAt(1.0, Qt::black);
g.setColorAt(0, QColor(100,100,100));
QImage mask(brush_size, brush_size,QImage::Format_RGB32);
mask.fill(qRgb(0,0,0));
QPainter painter2(&mask);
painter2.fillRect(mask.rect(), g);
painter2.end();
soft_brush = QImage(brush_size, brush_size,QImage::Format_RGB32);
soft_brush.fill(brush_color.rgb());
soft_brush.setAlphaChannel(mask);
}
示例8: convert_filter_gradient
void ConvertDialogTest::convert_filter_gradient()
{
EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
QGroupBox *filterGroupBox = effectsScrollArea->filterGroupBox;
filterGroupBox->setChecked(true);
QRadioButton *filterGradientRadioButton = effectsScrollArea->filterGradientRadioButton;
filterGradientRadioButton->setChecked(true);
QRadialGradient gradient = QRadialGradient(QPoint(1, 2), 2.5);
gradient.setColorAt(0.0, Qt::green);
gradient.setColorAt(1.0, Qt::red);
BrushFrame *filterBrushFrame = effectsScrollArea->filterBrushFrame;
filterBrushFrame->setBrush(gradient);
convertDialog->convert();
SharedInformation *sharedInfo = convertDialog->sharedInfo;
EffectsConfiguration conf = sharedInfo->effectsConfiguration();
QCOMPARE(conf.getFilterType(), int(Gradient));
QCOMPARE(conf.getFilterBrush(), QBrush(gradient));
}
示例9: paint
void Point::paint ( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * /*widget*/ )
{
QRadialGradient gradient ( 0.0, 0.0, _radius );
// If we are selected, use a lighter color.
if ( option->state & QStyle::State_Sunken )
{
gradient.setColorAt ( 0, QColor ( Qt::yellow ).light ( 120 ) );
gradient.setColorAt ( 1, QColor ( Qt::darkYellow ).light ( 120 ) );
painter->setPen ( QPen ( Qt::red, 0 ) );
}
else
{
gradient.setColorAt ( 0, Qt::yellow );
gradient.setColorAt ( 1, Qt::darkYellow );
painter->setPen ( QPen ( Qt::black, 0 ) );
}
painter->setBrush ( gradient );
const double diameter ( _radius * 2 );
painter->drawEllipse ( -_radius, -_radius, diameter, diameter);
}
示例10: EllipseShape
KoShape *EllipseShapeFactory::createDefaultShape(KoDocumentResourceManager *) const
{
EllipseShape *ellipse = new EllipseShape();
ellipse->setStroke(new KoShapeStroke(1.0));
ellipse->setShapeId(KoPathShapeId);
QRadialGradient *gradient = new QRadialGradient(QPointF(0.5,0.5), 0.5, QPointF(0.25,0.25));
gradient->setCoordinateMode(QGradient::ObjectBoundingMode);
gradient->setColorAt(0.0, Qt::white);
gradient->setColorAt(1.0, Qt::green);
ellipse->setBackground(new KoGradientBackground(gradient));
return ellipse;
}
示例11: p
SpaceObjectSun::SpaceObjectSun(int x, int y)
: SpaceObject(x, y, SO_TYPE_SUN)
{
mPixmap->fill(Qt::transparent);
QPainter p(mPixmap);
QRadialGradient rd;
rd.setCenter(40, 40);
rd.setRadius(40);
rd.setFocalPoint(40, 40);
rd.setColorAt(0, QColor(0xFF, 0xFF, 0xDD, 0xFF));
rd.setColorAt(0.45, QColor(0xFF, 0xFF, 0xDD, 0xFF));
rd.setColorAt(0.55, QColor(0xFF, 0xFF, 0x33, 0xFF));
rd.setColorAt(0.6, QColor("#FF9900"));
rd.setColorAt(1, QColor( 0, 0, 0, 0x00 ));
p.setPen(Qt::NoPen);
p.setBrush( rd );
p.drawEllipse(0, 0, 80, 80);
}
示例12: paint
void dot::paint ( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
{
Q_UNUSED ( widget );
painter->setPen ( Qt::NoPen );
painter->setBrush ( Qt::darkGray );
painter->drawEllipse ( -1, -1, 5, 5 );
QRadialGradient gradient ( -3, -3, 10 );
if( this->isSelected() )
{
if ( option->state & QStyle::State_Sunken )
{
gradient.setCenter ( 3, 3 );
gradient.setFocalPoint ( 3, 3 );
gradient.setColorAt ( 1, QColor ( Qt::green ).light ( 100 ) );
gradient.setColorAt ( 0, QColor ( Qt::darkGreen ).light ( 100 ) );
}
else
{
gradient.setColorAt ( 0, Qt::green );
gradient.setColorAt ( 1, Qt::darkGreen );
}
}
else
{
if ( option->state & QStyle::State_Sunken )
{
gradient.setCenter ( 3, 3 );
gradient.setFocalPoint ( 3, 3 );
gradient.setColorAt ( 1, QColor ( Qt::yellow ).light ( 100 ) );
gradient.setColorAt ( 0, QColor ( Qt::darkYellow ).light ( 100 ) );
}
else
{
gradient.setColorAt ( 0, Qt::yellow );
gradient.setColorAt ( 1, Qt::darkYellow );
}
}
painter->setBrush ( gradient );
painter->setPen ( QPen ( Qt::black, 0 ) );
painter->drawEllipse ( -2, -2, 6, 6 );
painter->scale ( 1.0,-1.0 );
painter->setFont(QFont("Arial", 14));
painter->drawText(0,10,message);
}
示例13: getRadialGradient
QRadialGradient* getRadialGradient(const CLRadialGradient* radial, const CLBoundingBox* bounds, const CLRenderResolver* resolver)
{
double cx = bounds->getPosition().getX() + radial->getCenterX().getAbsoluteValue() + radial->getCenterX().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth();
double cy = bounds->getPosition().getY() + radial->getCenterY().getAbsoluteValue() + radial->getCenterY().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight();
double fx = bounds->getPosition().getX() + radial->getFocalPointX().getAbsoluteValue() + radial->getFocalPointX().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth();
double fy = bounds->getPosition().getY() + radial->getFocalPointY().getAbsoluteValue() + radial->getFocalPointY().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight();
double r = radial->getRadius().getAbsoluteValue() + radial->getRadius().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth();
QRadialGradient* result = new QRadialGradient(cx, cy, r, fx, fy);
switch (radial->getSpreadMethod())
{
case CLGradientBase::REFLECT:
result->setSpread(QGradient::ReflectSpread);
break;
case CLGradientBase::REPEAT:
result->setSpread(QGradient::RepeatSpread);
break;
case CLGradientBase::PAD:
result->setSpread(QGradient::PadSpread);
break;
default:
break;
}
for (size_t i = 0; i < radial->getNumGradientStops(); ++i)
{
const CLGradientStop* stop = radial->getGradientStop(i);
result->setColorAt(stop->getOffset().getAbsoluteValue() + stop->getOffset().getRelativeValue() / 100.0, getColor(stop->getStopColor(), resolver));
}
return result;
}
示例14: paintEvent
void LedIndicator::paintEvent(QPaintEvent *event) {
qreal realSize = qMin(width(), height());
QRadialGradient gradient;
QPainter painter(this);
QPen pen(Qt::black);
pen.setWidth(1);
painter.setRenderHint(QPainter::Antialiasing);
painter.translate(width()/2, height()/2);
painter.scale(realSize/scaledSize, realSize/scaledSize);
gradient = QRadialGradient (QPointF(-500,-500), 1500, QPointF(-500,-500));
gradient.setColorAt(0, QColor(224,224,224));
gradient.setColorAt(1, QColor(28,28,28));
painter.setPen(pen);
painter.setBrush(QBrush(gradient));
painter.drawEllipse(QPointF(0,0), 500, 500);
gradient = QRadialGradient (QPointF(500,500), 1500, QPointF(500,500));
gradient.setColorAt(0, QColor(224,224,224));
gradient.setColorAt(1, QColor(28,28,28));
painter.setPen(pen);
painter.setBrush(QBrush(gradient));
painter.drawEllipse(QPointF(0,0), 450, 450);
painter.setPen(pen);
if( isDown() ) {
gradient = QRadialGradient (QPointF(-500,-500), 1500, QPointF(-500,-500));
gradient.setColorAt(0, onColor1);
gradient.setColorAt(1, onColor2);
} else {
gradient = QRadialGradient (QPointF(500,500), 1500, QPointF(500,500));
gradient.setColorAt(0, offColor1);
gradient.setColorAt(1, offColor2);
}
painter.setBrush(gradient);
painter.drawEllipse(QPointF(0,0), 400, 400);
}
示例15: generateFuzzyRect
QPixmap PostEffect::generateFuzzyRect(const QSize& size, const QColor& color, int radius)
{
QPixmap pix(size);
const QColor transparent(0, 0, 0, 0);
pix.fill(transparent);
QPainter painter(&pix);
painter.setRenderHint(QPainter::Antialiasing, true);
// Fill middle
painter.fillRect(pix.rect().adjusted(radius, radius, -radius, -radius), color);
// Corners
QRadialGradient gradient;
gradient.setColorAt(0, color);
gradient.setColorAt(1, transparent);
gradient.setRadius(radius);
QPoint center;
// Top Left
center = QPoint(radius, radius);
gradient.setCenter(center);
gradient.setFocalPoint(center);
painter.fillRect(0, 0, radius, radius, gradient);
// Top right
center = QPoint(size.width() - radius, radius);
gradient.setCenter(center);
gradient.setFocalPoint(center);
painter.fillRect(center.x(), 0, radius, radius, gradient);
// Bottom left
center = QPoint(radius, size.height() - radius);
gradient.setCenter(center);
gradient.setFocalPoint(center);
painter.fillRect(0, center.y(), radius, radius, gradient);
// Bottom right
center = QPoint(size.width() - radius, size.height() - radius);
gradient.setCenter(center);
gradient.setFocalPoint(center);
painter.fillRect(center.x(), center.y(), radius, radius, gradient);
// Borders
QLinearGradient linearGradient;
linearGradient.setColorAt(0, color);
linearGradient.setColorAt(1, transparent);
// Top
linearGradient.setStart(0, radius);
linearGradient.setFinalStop(0, 0);
painter.fillRect(radius, 0, size.width() - 2 * radius, radius, linearGradient);
// Bottom
linearGradient.setStart(0, size.height() - radius);
linearGradient.setFinalStop( 0, size.height() );
painter.fillRect(radius, int( linearGradient.start().y() ), size.width() - 2 * radius, radius, linearGradient);
// Left
linearGradient.setStart(radius, 0);
linearGradient.setFinalStop(0, 0);
painter.fillRect(0, radius, radius, size.height() - 2 * radius, linearGradient);
// Right
linearGradient.setStart(size.width() - radius, 0);
linearGradient.setFinalStop(size.width(), 0);
painter.fillRect(int( linearGradient.start().x() ), radius, radius, size.height() - 2 * radius, linearGradient);
return pix;
}