本文整理汇总了C++中QRadialGradient::center方法的典型用法代码示例。如果您正苦于以下问题:C++ QRadialGradient::center方法的具体用法?C++ QRadialGradient::center怎么用?C++ QRadialGradient::center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRadialGradient
的用法示例。
在下文中一共展示了QRadialGradient::center方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unoptimizedPaint
void BoxStyle::unoptimizedPaint(QPainter* painter, int xOffset, int yOffset, int contentBoxWidth,
int contentBoxHeight) const
{
qreal x = xOffset;
qreal y = yOffset;
int outlineWidth = outline_.style()!=Qt::NoPen ? outline_.width() : 0;
// Move the figure when using antialiasing. The outline will start at a pixel boundary. This makes it sharper.
if ( painter->testRenderHint(QPainter::Antialiasing) || painter->testRenderHint(QPainter::HighQualityAntialiasing) )
if ( outline().style() != Qt::NoPen)
{
x = xOffset + outlineWidth/2.0;
y = yOffset + outlineWidth/2.0;
}
// Draw shadow
if ( shadow() != Qt::NoBrush )
{
painter->setPen(Qt::NoPen);
painter->setBrush(shadow());
painter->drawPath(getRectanglePath(xOffset + xShadowOffset(), yOffset + yShadowOffset(),
contentBoxWidth, contentBoxHeight));
}
// Draw box.
painter->setPen(outline());
// Set the brush and fix the gradient if needed.
if ( background().style() == Qt::LinearGradientPattern
&& background().gradient()->coordinateMode() == QGradient::LogicalMode )
{
QLinearGradient g = *(static_cast<const QLinearGradient*> (background().gradient()));
g.setStart(x + g.start().x(), y + g.start().y());
g.setFinalStop(x + g.finalStop().x(), y + g.finalStop().y());
painter->setBrush(g);
}
else if ( background().style() == Qt::RadialGradientPattern
&& background().gradient()->coordinateMode() == QGradient::LogicalMode )
{
QRadialGradient g = *(static_cast<const QRadialGradient*> (background().gradient()));
g.setCenter(x + g.center().x(), y + g.center().y());
g.setFocalPoint(x + g.focalPoint().x(), y + g.focalPoint().y());
painter->setBrush(g);
}
else
{
painter->setBrush(background());
}
painter->drawPath(getRectanglePath(x, y, contentBoxWidth - outlineWidth, contentBoxHeight - outlineWidth));
}
示例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: color
KoStopGradient * KoStopGradient::fromQGradient(QGradient * gradient)
{
if (! gradient)
return 0;
KoStopGradient * newGradient = new KoStopGradient("");
newGradient->setType(gradient->type());
newGradient->setSpread(gradient->spread());
switch (gradient->type()) {
case QGradient::LinearGradient: {
QLinearGradient * g = static_cast<QLinearGradient*>(gradient);
newGradient->m_start = g->start();
newGradient->m_stop = g->finalStop();
newGradient->m_focalPoint = g->start();
break;
}
case QGradient::RadialGradient: {
QRadialGradient * g = static_cast<QRadialGradient*>(gradient);
newGradient->m_start = g->center();
newGradient->m_stop = g->center() + QPointF(g->radius(), 0);
newGradient->m_focalPoint = g->focalPoint();
break;
}
case QGradient::ConicalGradient: {
QConicalGradient * g = static_cast<QConicalGradient*>(gradient);
qreal radian = g->angle() * M_PI / 180.0;
newGradient->m_start = g->center();
newGradient->m_stop = QPointF(100.0 * cos(radian), 100.0 * sin(radian));
newGradient->m_focalPoint = g->center();
break;
}
default:
delete newGradient;
return 0;
}
Q_FOREACH (const QGradientStop & stop, gradient->stops()) {
KoColor color(newGradient->colorSpace());
color.fromQColor(stop.second);
newGradient->m_stops.append(KoGradientStop(stop.first, color));
}
return newGradient;
}
示例4: sipConvertFromNewType
static PyObject *meth_QRadialGradient_center(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QRadialGradient *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QRadialGradient, &sipCpp))
{
QPointF *sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = new QPointF(sipCpp->center());
Py_END_ALLOW_THREADS
return sipConvertFromNewType(sipRes,sipType_QPointF,NULL);
}
}
示例5: paintBackground
void RadialVolumeWidgetPrivate::paintBackground() // QGradient is soooo sloooow
{
QPainter p(&bg);
p.setRenderHint(QPainter::Antialiasing, true);
int r = spectrum.radius();
QPoint c = spectrum.center().toPoint();
p.setBrush(spectrum);
p.setPen(QPen(Qt::NoPen));
p.drawEllipse(c.x()-r, c.y()-r, 2*r, 2*r); // Gradient background
p.setBrush(QBrush()); // Do not fill
//p.setPen(QPen(QColor(255, 255, 255, 160), 0, Qt::DashLine));
for (int i=0; i<n_levels; i++)
{
int l_r = r*levels[i];
p.setPen(QPen(QColor(255, 255, 255, 255-(180*(i+1))/n_levels), 1, Qt::DashLine));
p.drawEllipse(c.x()-l_r, c.y()-l_r, 2*l_r, 2*l_r);
}
}
示例6: drawEllipse
void BitmapImage::drawEllipse( QRectF rectangle, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
{
int width = pen.width();
extend( rectangle.adjusted(-width,-width,width,width).toRect() );
if (brush.style() == Qt::RadialGradientPattern)
{
QRadialGradient* gradient = (QRadialGradient*)brush.gradient();
gradient->setCenter( gradient->center() - topLeft() );
gradient->setFocalPoint( gradient->focalPoint() - topLeft() );
}
if (mImage != NULL && !mImage->isNull() )
{
QPainter painter(mImage);
painter.setCompositionMode(cm);
painter.setRenderHint(QPainter::Antialiasing, antialiasing);
painter.setPen(pen);
painter.setBrush(brush);
//if (brush == Qt::NoBrush)
painter.drawEllipse( rectangle.translated(-topLeft()) );
painter.end();
}
}
示例7: drawRect
void BitmapImage::drawRect(QRectF rectangle, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
{
int width = pen.width();
setCompositionModeBounds(rectangle.adjusted(-width, -width, width, width).toRect(), true, cm);
if (brush.style() == Qt::RadialGradientPattern)
{
QRadialGradient* gradient = (QRadialGradient*)brush.gradient();
gradient->setCenter(gradient->center() - mBounds.topLeft());
gradient->setFocalPoint(gradient->focalPoint() - mBounds.topLeft());
}
if (!image()->isNull())
{
QPainter painter(image());
painter.setCompositionMode(cm);
painter.setRenderHint(QPainter::Antialiasing, antialiasing);
painter.setPen(pen);
painter.setBrush(brush);
painter.drawRect(rectangle.translated(-mBounds.topLeft()));
painter.end();
}
modification();
}
示例8: paintEvent
void LightMaps::paintEvent(QPaintEvent *event)
{
QPainter p;
p.begin(this);
m_normalMap->render(&p, event->rect());
p.setPen(Qt::black);
p.drawText(rect(), Qt::AlignBottom | Qt::TextWordWrap,
"Map data CCBYSA 2009 OpenStreetMap.org contributors");
p.end();
if (zoomed) {
int dim = qMin(width(), height());
int magnifierSize = qMin(MAX_MAGNIFIER, dim * 2 / 3);
int radius = magnifierSize / 2;
int ring = radius - 15;
QSize box = QSize(magnifierSize, magnifierSize);
// reupdate our mask
if (maskPixmap.size() != box) {
maskPixmap = QPixmap(box);
maskPixmap.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(&maskPixmap);
mask.setRenderHint(QPainter::Antialiasing);
mask.setCompositionMode(QPainter::CompositionMode_Source);
mask.setBrush(g);
mask.setPen(Qt::NoPen);
mask.drawRect(maskPixmap.rect());
mask.setBrush(QColor(Qt::transparent));
mask.drawEllipse(g.center(), ring, ring);
mask.end();
}
QPoint center = dragPos - QPoint(0, radius);
center = center + QPoint(0, radius / 2);
QPoint corner = center - QPoint(radius, radius);
QPoint xy = center * 2 - QPoint(radius, radius);
// only set the dimension to the magnified portion
if (zoomPixmap.size() != box) {
zoomPixmap = QPixmap(box);
zoomPixmap.fill(Qt::lightGray);
}
if (true) {
QPainter p(&zoomPixmap);
p.translate(-xy);
m_largeMap->render(&p, QRect(xy, box));
p.end();
}
QPainterPath clipPath;
clipPath.addEllipse(center, ring, ring);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
p.setClipPath(clipPath);
p.drawPixmap(corner, zoomPixmap);
p.setClipping(false);
p.drawPixmap(corner, maskPixmap);
p.setPen(Qt::gray);
p.drawPath(clipPath);
}
if (invert) {
QPainter p(this);
p.setCompositionMode(QPainter::CompositionMode_Difference);
p.fillRect(event->rect(), Qt::white);
p.end();
}
}
示例9: mask_slot
void Mask::mask_slot(){
int countSel = gsri->countSelected();
GObjectInterface *iObj, *endObj=gsri->selected(gsri->countSelected()-1);//создаём контейнер с выделенными рамкой объектами
qreal k_h, k_w, width_iObj, width_endObj = endObj->boundingRect().width(),
height_iObj, height_endObj = endObj->boundingRect().height();
QBrush endObjBrush = endObj->brush();
if(endObjBrush.style() == Qt::RadialGradientPattern
|| endObjBrush.style() == Qt::ConicalGradientPattern
|| endObjBrush.style() == Qt::LinearGradientPattern){
for (int i=0; i<countSel-1; i++){
iObj = gsri->selected(i);
QBrush inters = iObj->brush();
qreal iObjAlpha = inters.color().alphaF();
QGradient qg = *endObjBrush.gradient();
height_iObj = iObj->boundingRect().height();
width_iObj = iObj->boundingRect().width();
k_h = height_endObj/height_iObj;//считаем коэффициенты пропорциональности фигур для умножения-->
k_w = width_endObj/width_iObj;//-->на точки градиента(чтобы градиенты не зависели от размеров фигур).
int d_x = iObj->boundingRect().x() - endObj->boundingRect().x();//вычисляем расстояния между левыми краями фигур
int d_y = iObj->boundingRect().y() - endObj->boundingRect().y();
qreal k_shift_x = ( d_x / width_endObj) * k_w,//вычисляем коэффициенты сдвига градиента по ширине-->
k_shift_y = (d_y / height_endObj) * k_h;//--> и по высотке
QGradientStops grStops(qg.stops());//копируем точки/цвета задаваемого градиента.
QColor BrushColor = inters.gradient()->stops()[0].second;
for(int j=0; j<grStops.count(); j++){
grStops[j].second.setRgbF( BrushColor.redF(), BrushColor.greenF(), BrushColor.blueF(),
grStops[j].second.alphaF()*iObjAlpha);
}
if(qg.type() == QGradient::LinearGradient){
QLinearGradient qlg = *static_cast<const QLinearGradient *>(endObjBrush.gradient());
QLinearGradient qlgLinear(qlg.start().x() * k_w - k_shift_x, qlg.start().y() * k_h - k_shift_y,
qlg.finalStop().x() * k_w - k_shift_x, qlg.finalStop().y() * k_h - k_shift_y);
qlgLinear.setStops(grStops);
iObj->setBrush(qlgLinear);
}
if(qg.type() == QGradient::RadialGradient){
for(int j=0; j<grStops.count(); j++)
grStops[j].first *= k_w;
QRadialGradient qlg = *static_cast<const QRadialGradient *>(endObjBrush.gradient());
QRadialGradient qlgRadial(QPointF(qlg.center().x()*k_w - k_shift_x, qlg.center().y()*k_h - k_shift_y),
qlg.radius(), QPointF(qlg.focalPoint().x()*k_w - k_shift_x, qlg.focalPoint().y()*k_h - k_shift_y),
qlg.focalRadius());
qlgRadial.setStops(grStops);
iObj->setBrush(qlgRadial);
}
if(qg.type() == QGradient::ConicalGradient){
QConicalGradient qlg = *static_cast<const QConicalGradient *>(endObjBrush.gradient());
QConicalGradient qlgConical(QPointF(qlg.center().x()*k_w - k_shift_x, qlg.center().y()*k_h - k_shift_y),
qlg.angle());
qlgConical.setStops(grStops);
iObj->setBrush(qlgConical);
}
}
endObj->setVisible(false);
}
else{
QMessageBox m;
m.setText(tr("upper figure does not contain a gradient"));
m.exec();
}
gsri->reset();
}
示例10: drawPressed
void Ckeyb::drawPressed(QImage *_img)
{
if (keyPressedList.isEmpty()) {
return;
}
keyPressing.lock();
QMapIterator<int, quint64> i(keyPressedList);
keyPressing.unlock();
while (i.hasNext()) {
i.next();
QRect _rect = getKey(i.key()).Rect;
_rect.setCoords(_rect.x()*pPC->internalImageRatio,
_rect.y()*pPC->internalImageRatio,
(_rect.x()+_rect.width())*pPC->internalImageRatio,
(_rect.y()+_rect.height())*pPC->internalImageRatio);
int _m = qMin(_rect.width(), _rect.height())*.25;
_rect+= QMargins(_m,_m,_m,_m);
int dim = qMax(_rect.width(), _rect.height());
int magnifierSize = dim * 2;
int radius = magnifierSize / 2;
int ring = radius - 15;
QSize box = QSize(magnifierSize, magnifierSize);
QPixmap maskPixmap;
maskPixmap = QPixmap(box);
maskPixmap.fill(Qt::transparent);
QRadialGradient g;
g.setCenter(radius, radius);
g.setFocalPoint(radius, radius);
g.setRadius(radius);
g.setColorAt(1.0, QColor(64, 64, 64, 0));
g.setColorAt(0.5, QColor(0, 0, 0, 255));
QPainter mask(&maskPixmap);
mask.setRenderHint(QPainter::Antialiasing);
mask.setCompositionMode(QPainter::CompositionMode_Source);
mask.setBrush(g);
mask.setPen(Qt::NoPen);
mask.drawRect(maskPixmap.rect());
mask.setBrush(QColor(Qt::transparent));
mask.drawEllipse(g.center(), ring, ring);
mask.end();
QPoint center = _rect.center() - QPoint(0, radius);
center = center + QPoint(0, radius / 2);
QPoint corner = center - QPoint(radius, radius);
QPoint xy = center * 2 - QPoint(radius, radius);
// only set the dimension to the magnified portion
QPixmap zoomPixmap = QPixmap(box);
zoomPixmap.fill(Qt::lightGray);
QPainter pz(&zoomPixmap);
// pz.translate(-xy);
QRect target=QRect(QPoint(0,0),box);
pz.drawImage(target, *_img,_rect);
pz.end();
QPainterPath clipPath;
clipPath.addEllipse(center, ring, ring);
QPainter p(_img);
p.setRenderHint(QPainter::Antialiasing);
p.setClipPath(clipPath);
p.drawPixmap(corner, zoomPixmap);
p.setClipping(false);
p.drawPixmap(corner, maskPixmap);
p.setPen(Qt::gray);
p.drawPath(clipPath);
p.end();
}
}