本文整理汇总了C++中QRadialGradient::setCenterRadius方法的典型用法代码示例。如果您正苦于以下问题:C++ QRadialGradient::setCenterRadius方法的具体用法?C++ QRadialGradient::setCenterRadius怎么用?C++ QRadialGradient::setCenterRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRadialGradient
的用法示例。
在下文中一共展示了QRadialGradient::setCenterRadius方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}