void PathDeformRenderer::generateLensPixmap() { qreal rad = m_radius + LENS_EXTENT; QRect bounds = circle_bounds(QPointF(), rad, 0); QPainter painter; if (preferImage()) { m_lens_image = QImage(bounds.size(), QImage::Format_ARGB32_Premultiplied); m_lens_image.fill(0); painter.begin(&m_lens_image); } else { m_lens_pixmap = QPixmap(bounds.size()); m_lens_pixmap.fill(Qt::transparent); painter.begin(&m_lens_pixmap); } QRadialGradient gr(rad, rad, rad, 3 * rad / 5, 3 * rad / 5); gr.setColorAt(0.0, QColor(255, 255, 255, 191)); gr.setColorAt(0.2, QColor(255, 255, 127, 191)); gr.setColorAt(0.9, QColor(150, 150, 200, 63)); gr.setColorAt(0.95, QColor(0, 0, 0, 127)); gr.setColorAt(1, QColor(0, 0, 0, 0)); painter.setRenderHint(QPainter::Antialiasing); painter.setBrush(gr); painter.setPen(Qt::NoPen); painter.drawEllipse(0, 0, bounds.width(), bounds.height()); }
void PathDeformRenderer::paint(QPainter *painter) { int pad_x = 5; int pad_y = 5; int skip_x = qRound(m_pathBounds.width() + pad_x + m_fontSize/2); int skip_y = qRound(m_pathBounds.height() + pad_y); painter->setPen(Qt::NoPen); painter->setBrush(Qt::black); QRectF clip(painter->clipPath().boundingRect()); int overlap = pad_x / 2; for (int start_y=0; start_y < height(); start_y += skip_y) { if (start_y > clip.bottom()) break; int start_x = -overlap; for (; start_x < width(); start_x += skip_x) { if (start_y + skip_y >= clip.top() && start_x + skip_x >= clip.left() && start_x <= clip.right()) { for (int i=0; i<m_paths.size(); ++i) { QPainterPath path = lensDeform(m_paths[i], QPointF(start_x, start_y)); painter->drawPath(path); } } } overlap = skip_x - (start_x - width()); } if (preferImage()) { painter->drawImage(m_pos - QPointF(m_radius + LENS_EXTENT, m_radius + LENS_EXTENT), m_lens_image); } else { painter->drawPixmap(m_pos - QPointF(m_radius + LENS_EXTENT, m_radius + LENS_EXTENT), m_lens_pixmap); } }
void ArthurFrame::paintEvent(QPaintEvent *e) { #ifdef Q_WS_QWS static QPixmap *static_image = 0; #else static QImage *static_image = 0; #endif QPainter painter; if (preferImage() #ifdef QT_OPENGL_SUPPORT && !m_use_opengl #endif ) { if (!static_image || static_image->size() != size()) { delete static_image; #ifdef Q_WS_QWS static_image = new QPixmap(size()); #else static_image = new QImage(size(), QImage::Format_RGB32); #endif } painter.begin(static_image); int o = 10; QBrush bg = palette().brush(QPalette::Background); painter.fillRect(0, 0, o, o, bg); painter.fillRect(width() - o, 0, o, o, bg); painter.fillRect(0, height() - o, o, o, bg); painter.fillRect(width() - o, height() - o, o, o, bg); } else { #ifdef QT_OPENGL_SUPPORT if (m_use_opengl) { painter.begin(glw); painter.fillRect(QRectF(0, 0, glw->width(), glw->height()), palette().color(backgroundRole())); } else { painter.begin(this); } #else painter.begin(this); #endif } painter.setClipRect(e->rect()); painter.setRenderHint(QPainter::Antialiasing); QPainterPath clipPath; QRect r = rect(); qreal left = r.x() + 1; qreal top = r.y() + 1; qreal right = r.right(); qreal bottom = r.bottom(); qreal radius2 = 8 * 2; clipPath.moveTo(right - radius2, top); clipPath.arcTo(right - radius2, top, radius2, radius2, 90, -90); clipPath.arcTo(right - radius2, bottom - radius2, radius2, radius2, 0, -90); clipPath.arcTo(left, bottom - radius2, radius2, radius2, 270, -90); clipPath.arcTo(left, top, radius2, radius2, 180, -90); clipPath.closeSubpath(); painter.save(); painter.setClipPath(clipPath, Qt::IntersectClip); painter.drawTiledPixmap(rect(), m_tile); // client painting paint(&painter); painter.restore(); painter.save(); if (m_show_doc) paintDescription(&painter); painter.restore(); int level = 180; painter.setPen(QPen(QColor(level, level, level), 2)); painter.setBrush(Qt::NoBrush); painter.drawPath(clipPath); if (preferImage() #ifdef QT_OPENGL_SUPPORT && !m_use_opengl #endif ) { painter.end(); painter.begin(this); #ifdef Q_WS_QWS painter.drawPixmap(e->rect(), *static_image, e->rect()); #else painter.drawImage(e->rect(), *static_image, e->rect()); #endif } #ifdef QT_OPENGL_SUPPORT if (m_use_opengl && (inherits("PathDeformRenderer") || inherits("PathStrokeRenderer") || inherits("CompositionRenderer") || m_show_doc)) glw->swapBuffers(); #endif }
void ArthurFrame::paintEvent(QPaintEvent *e) { static QImage *static_image = 0; QPainter painter; if (preferImage()) { if (!static_image) { static_image = new QImage(size(), QImage::Format_RGB32); } else if (static_image->size() != size()) { delete static_image; static_image = new QImage(size(), QImage::Format_RGB32); } painter.begin(static_image); int o = 10; QBrush bg = palette().brush(QPalette::Background); painter.fillRect(0, 0, o, o, bg); painter.fillRect(width() - o, 0, o, o, bg); painter.fillRect(0, height() - o, o, o, bg); painter.fillRect(width() - o, height() - o, o, o, bg); } else { painter.begin(this); } painter.setClipRect(e->rect()); painter.setRenderHint(QPainter::Antialiasing); QPainterPath clipPath; QRect r = rect(); double left = r.x() + 1; double top = r.y() + 1; double right = r.right(); double bottom = r.bottom(); double radius2 = 8 * 2; clipPath.moveTo(right - radius2, top); clipPath.arcTo(right - radius2, top, radius2, radius2, 90, -90); clipPath.arcTo(right - radius2, bottom - radius2, radius2, radius2, 0, -90); clipPath.arcTo(left, bottom - radius2, radius2, radius2, 270, -90); clipPath.arcTo(left, top, radius2, radius2, 180, -90); clipPath.closeSubpath(); painter.save(); painter.setClipPath(clipPath, Qt::IntersectClip); painter.drawTiledPixmap(rect(), m_tile); // client painting paint(&painter); painter.restore(); painter.save(); if (m_show_doc) paintDescription(&painter); painter.restore(); int level = 180; painter.setPen(QPen(QColor(level, level, level), 2)); painter.setBrush(Qt::NoBrush); painter.drawPath(clipPath); if (preferImage()) { painter.end(); painter.begin(this); painter.drawImage(e->rect(), *static_image, e->rect()); } }