void MouseHoverable::DrawMouseHoverRect(QPainter &painter) const { qreal old = painter.opacity(); painter.setOpacity(m_alpha); painter.fillRect(m_composite->rect(), m_mouseOverColor); painter.setOpacity(old); }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- void tBoatWidget::DrawBoat( QPainter& painter ) { painter.save(); // Draw boat QColor color; if( tSystemSettings::Instance()->NightMode() ) { color = Qt::white; painter.setOpacity(0.2); } else { color = Qt::black; painter.setOpacity(0.5); } painter.setPen(QPen(color, 6, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin)); painter.translate(QPointF((width()/2.0)+0.5, 15.0)); QPainterPath p; p.moveTo( 28, 146 ); p.cubicTo( 34, 90, 44, 70, 0, 0 ); p.cubicTo( -44, 70, -34, 90, -28, 146 ); p.lineTo( 28, 146 ); painter.drawPath(p); painter.restore(); }
void TextureMapperQt::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* maskTexture) { const BitmapTextureQt& textureQt = static_cast<const BitmapTextureQt&>(texture); QPainter* painter = m_painter; QPixmap pixmap = textureQt.m_pixmap; if (m_currentSurface) painter = &m_currentSurface->m_painter; if (maskTexture && maskTexture->isValid()) { const BitmapTextureQt* mask = static_cast<const BitmapTextureQt*>(maskTexture); QPixmap intermediatePixmap(pixmap.size()); intermediatePixmap.fill(Qt::transparent); QPainter maskPainter(&intermediatePixmap); maskPainter.setCompositionMode(QPainter::CompositionMode_Source); maskPainter.drawPixmap(0, 0, pixmap); maskPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); maskPainter.drawPixmap(QRect(0, 0, pixmap.width(), pixmap.height()), mask->m_pixmap, mask->sourceRect()); maskPainter.end(); pixmap = intermediatePixmap; } const qreal prevOpacity = painter->opacity(); const QTransform prevTransform = painter->transform(); painter->setOpacity(opacity); painter->setTransform(matrix, true); painter->drawPixmap(targetRect, pixmap, FloatRect(textureQt.sourceRect())); painter->setTransform(prevTransform); painter->setOpacity(prevOpacity); }
void CanvasRenderer::paintCurrentFrame( QPainter& painter ) { for ( int i = 0; i < mObject->getLayerCount(); ++i ) { Layer* layer = mObject->getLayer( i ); if ( i == mLayerIndex || mOptions.nShowAllLayers != 1 ) { painter.setOpacity( 1.0 ); } else { painter.setOpacity( 0.8 ); } if ( i == mLayerIndex || mOptions.nShowAllLayers > 0 ) { switch ( layer->type() ) { case Layer::BITMAP: { paintBitmapFrame( painter, i, mFrameNumber ); break; } case Layer::VECTOR: { paintVectorFrame( painter, i, mFrameNumber ); break; } case Layer::CAMERA: break; case Layer::SOUND: break; default: Q_ASSERT( false ); break; } } } }
void PictureZoneEditor::onPaint(QPainter& painter, InteractionState const& interaction) { painter.setWorldTransform(QTransform()); painter.setRenderHint(QPainter::Antialiasing); if (!validateScreenPictureMask()) { schedulePictureMaskRebuild(); } else { double const sn = sin(constants::DEG2RAD * m_pictureMaskAnimationPhase); double const scale = 0.5 * (sn + 1.0); // 0 .. 1 double const opacity = 0.35 * scale + 0.15; QPixmap mask(m_screenPictureMask); { QPainter mask_painter(&mask); mask_painter.translate(-m_screenPictureMaskOrigin); paintOverPictureMask(mask_painter); } painter.setOpacity(opacity); painter.drawPixmap(m_screenPictureMaskOrigin, mask); painter.setOpacity(1.0); if (!m_pictureMaskAnimateTimer.isActive()) { m_pictureMaskAnimateTimer.start(); } } }
void SelectLocation::paintEvent(QPaintEvent *paintevent) { QPainter painter; QPainterPath roundedrect; roundedrect.addRoundRect(this->rect(),20); painter.setOpacity(0.8); painter.fillPath(roundedrect,QColor(Qt::black)); painter.setOpacity(1); }
void Timeline::Render(QPainter& painter) { std::vector<QImage*> onions; for (size_t i = 0; i < mLayers.size(); ++i) { Layer* layer = mLayers[i]; if (!layer->IsEnabled()) { continue; } if (layer->GetType() == LayerTypeRaster) { QImage* img = mLayers[i]->GetImage(mFrameIndex); if (img) { if (mEditor->IsOnionEnabled() && mLayerIndex == (int)i) { if (layer->GetType() == LayerTypeRaster && layer->IsOnionEnabled()) { RasterLayer* l = (RasterLayer*)mLayers[i]; QImage* prev = l->GetImage(l->GetPrevImageIndex(mFrameIndex)); if(prev && prev != img) { onions.push_back(prev); } QImage* next = l->GetImage(l->GetNextImageIndex(mFrameIndex)); if(next && next != img) { onions.push_back(next); } } } painter.setOpacity(layer->GetOpacity() / 255.0f); painter.drawImage(0, 0, *img); } } else if (layer->GetType() == LayerTypeTrace) { TraceLayer* tl = (TraceLayer*)layer; tl->Render(painter); } } painter.setOpacity(0.25f); for (size_t i = 0; i < onions.size(); ++i) { painter.drawImage(0, 0, *onions[i]); } }
void ChessBoardWidget::drawChess(QPainter& painter) { if(!showBoard) return; int i,j,step; bool flag; ChessBoard::ChessType type; painter.setFont(QFont("arial", cellHeight*0.35)); painter.translate(gridLeft-cellWidth*0.5, gridTop-cellHeight*0.5); for(i=0;i<B_HEIGHT;++i) { for(j=0;j<B_WIDTH;++j) { type=showBoard->getGrid(i, j); if(type==ChessBoard::invalid) continue; painter.save(); painter.translate(cellWidth*i, cellHeight*j); if(type==ChessBoard::empty) { if(historyStep==0&&!showBoard->isFinished()&&i==mouseX&&j==mouseY &&showHint&&showBoard->checkMove(i, j, isNextBlack)) { painter.setOpacity(0.3); painter.drawImage(QRectF(0, 0, cellWidth, cellHeight), isNextBlack?imgChessBlack[0]:imgChessWhite[0]); } } else { step=showBoard->getStep(i, j); flag=(i==currentX&&j==currentY); if(historyStep>0&&historyStep<step) painter.setOpacity(0.2); painter.drawImage(QRectF(0, 0, cellWidth, cellHeight), type==ChessBoard::black?imgChessBlack[flag]:imgChessWhite[flag]); if(showGuide||historyStep>=step) { painter.setPen(type==ChessBoard::black?"white":"black"); painter.drawText(QRectF(0, 0, cellWidth, cellHeight), Qt::AlignCenter, QString("%0").arg(step)); } } painter.restore(); } } }
void ProfileWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) { if (animating() && _showing) { p.setOpacity(a_bgAlpha.current()); p.drawPixmap(a_bgCoord.current(), 0, _bgAnimTopBarCache); p.setOpacity(a_alpha.current()); p.drawPixmap(a_coord.current(), 0, _animTopBarCache); } else { p.setOpacity(st::topBarBackAlpha + (1 - st::topBarBackAlpha) * over); p.drawPixmap(QPoint(st::topBarBackPadding.left(), (st::topBarHeight - st::topBarBackImg.height()) / 2), App::sprite(), st::topBarBackImg); p.setFont(st::topBarBackFont->f); p.setPen(st::topBarBackColor->p); p.drawText(st::topBarBackPadding.left() + st::topBarBackImg.width() + st::topBarBackPadding.right(), (st::topBarHeight - st::titleFont->height) / 2 + st::titleFont->ascent, lang(peer()->chat ? lng_profile_group_info : lng_profile_info)); } }
void Bubble::draw_bubble(QPainter &painter) { QPen pen; pen.setWidth(stroke); pen.setBrush(colour); painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.setPen(Qt::NoPen); painter.setBrush(colour); painter.setOpacity(opacity); painter.drawEllipse(QPointF(position()[0],position()[1]), r, r); painter.setPen(pen); painter.setBrush(Qt::NoBrush); painter.setOpacity(1.0); painter.drawEllipse(QPointF(position()[0],position()[1]), r, r); }
void PerspectivePixmap::drawUsingPainter(QPainter &painter) { if (!mPixMap.isNull()) { qreal opOld = painter.opacity(); QTransform transOld = painter.transform(); QTransform trans = painter.transform(); trans.scale(1, -1); painter.setTransform(trans); painter.setOpacity(0.8); painter.drawPixmap(-mXOffset / mScale, -mYOffset / mScale, mPixMap.width() / mScale, mPixMap.height() / mScale, mPixMap); painter.setOpacity(opOld); painter.setTransform(transOld); } }
void QQuickShapeSoftwareRenderNode::render(const RenderState *state) { if (m_sp.isEmpty()) return; QSGRendererInterface *rif = m_item->window()->rendererInterface(); QPainter *p = static_cast<QPainter *>(rif->getResource(m_item->window(), QSGRendererInterface::PainterResource)); Q_ASSERT(p); const QRegion *clipRegion = state->clipRegion(); if (clipRegion && !clipRegion->isEmpty()) p->setClipRegion(*clipRegion, Qt::ReplaceClip); // must be done before setTransform p->setTransform(matrix()->toTransform()); p->setOpacity(inheritedOpacity()); for (const ShapePathRenderData &d : qAsConst(m_sp)) { if (d.hidden) { continue; } // QTransform oldTransform = p->transform(); // p->setTransform(d.transform, true); // p->setOpacity(inheritedOpacity() * d.opacity); p->setPen(d.strokeWidth >= 0.0f && d.pen.color() != Qt::transparent ? d.pen : Qt::NoPen); p->setBrush(d.brush.color() != Qt::transparent ? d.brush : Qt::NoBrush); p->drawPath(d.path); // p->setTransform(oldTransform); } }
void LevelWinDialog::paintContent(QPainter &p) { GamePanel::paintContent(p); p.setOpacity(1); p.setFont(gameStock->Font40); p.setPen(QPen(QColor(0x030055))); drawHCentered(p, 50, tr("Level %1 completed!").arg(level)); p.setFont(gameStock->Font20); const int y30 = DY(40); const int x1 = DX(300), x2 = DX(380), x3 = DX(600); const int y1 = DY(250), y2 = DY(350); p.drawPixmap(x1,y1, gameStock->Clock); p.drawText(x3,y1+y30, QString("%1:%2").arg(time/60, 2, 10, QChar('0')).arg(time%60, 2, 10, QChar('0'))); p.drawPixmap(x1,y2, gameStock->Score); p.drawText(x3,y2+y30, QString::number(score)); p.setPen(QPen(Qt::black)); p.drawText(x2,y1+y30, tr("Time left:")); p.drawText(x2,y2+y30, tr("Score:")); }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void Circle::draw(QPainter& painter, const QPointF& startTile, const QRect& viewport, const int& zoom) { if ( !isVisible() ) return; QPointF coords; coord2screen(geoPosition(), coords, startTile, zoom); if ( !viewport.contains(coords.toPoint()) ) coord2screen(geoPosition(), coords, startTile, zoom, true); setScreenPosition(coords); qreal yu = size().height() / WGS84CELLSIZE / pow(2, 18 - zoom) * 1000; qreal xu = size().width() / WGS84CELLSIZE / pow(2, 18 - zoom) * 1000; painter.save(); painter.setPen(pen()); painter.setBrush(brush()); painter.setOpacity(opacity()); painter.setRenderHint(QPainter::Antialiasing, isAntialiased()); if ( isSizeInKm() ) painter.drawEllipse(coords, xu, yu); else painter.drawEllipse(coords, size().width(), size().height()); painter.restore(); }
void AudioGraphWidget::drawDbLabels(QPainter& p, const QRect &rect) { int dbLabelCount = m_dbLabels.size(); int textHeight = fontMetrics().ascent(); int x = 0; int y = 0; int yline = 0; if (dbLabelCount == 0) return; int maxWidth = fontMetrics().width(QStringLiteral("-50")); // dB scale is vertical along the left side int prevY = height(); QColor textCol = palette().text().color(); QColor lineCol = textCol; p.setOpacity(0.8); lineCol.setAlpha(100); for (int i = 0; i < dbLabelCount; i++) { int value = m_dbLabels[i]; QString label = QString::number(value); x = rect.left() + maxWidth - fontMetrics().width(label); yline = rect.bottom() - IEC_ScaleMax(value, m_maxDb) * rect.height(); y = yline + textHeight / 2; if (y - textHeight < 0) { y = textHeight; } if (prevY - y >= 2) { p.setPen(textCol); p.drawText(x, y, label); p.setPen(lineCol); p.drawLine(rect.left() + maxWidth + 2, yline, rect.width(), yline); prevY = y - textHeight; } } }
void GameWinDialog::paintContent(QPainter &p) { GamePanel::paintContent(p); p.setOpacity(1); p.setFont(gameStock->Font60); p.setPen(QPen(QColor(0x030055))); drawHCentered(p, 50, tr("You're the Winner!")); p.setFont(gameStock->Font40); drawHCentered(p, 200, tr("You finished all the levels!")); p.setFont(gameStock->Font20); const int y30 = DY(40); const int x1 = DX(300), x2 = DX(420), x3 = DX(600); const int /*y1 = DY(250), */y2 = DY(350)/*, y3 = DY(350)*/; p.drawPixmap(x1,y2, gameStock->Score); p.drawText(x3,y2+y30, QString::number(score)); p.setPen(QPen(Qt::black)); p.drawText(x2,y2+y30, tr("Score:")); }
void Bubble::do_draw(QPainter& painter) { draw_bubble(painter); painter.setPen(Qt::red); painter.setBrush(Qt::NoBrush); painter.setOpacity(1.0); painter.drawRect(get_bounding_box()); }
void GraphicsContext::setAlpha(float opacity) { if (paintingDisabled()) return; QPainter *p = m_data->p(); p->setOpacity(opacity); }
void TextItem::paint(QPainter &painter) { painter.setOpacity(myOpacity); painter.setFont(myFont); painter.setPen(QPen(myColor)); painter.drawText(myRect, myFlags, myText); }
void ImageBufferDataPrivateAccelerated::platformTransformColorSpace(const Vector<int>& lookUpTable) { QPainter* painter = paintDevice()->paintEngine()->painter(); QImage image = toQImage().convertToFormat(QImage::Format_ARGB32); ASSERT(!image.isNull()); uchar* bits = image.bits(); const int bytesPerLine = image.bytesPerLine(); for (int y = 0; y < image.height(); ++y) { quint32* scanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine); for (int x = 0; x < image.width(); ++x) { QRgb& pixel = scanLine[x]; pixel = qRgba(lookUpTable[qRed(pixel)], lookUpTable[qGreen(pixel)], lookUpTable[qBlue(pixel)], qAlpha(pixel)); } } painter->save(); painter->resetTransform(); painter->setOpacity(1.0); painter->setClipping(false); painter->setCompositionMode(QPainter::CompositionMode_Source); // Should coordinates be flipped? painter->drawImage(QPoint(0,0), image); painter->restore(); }
bool eventFilter(QObject *pO, QEvent *event) { if ( event->type() == QEvent::Paint) { QWidget* pW = qobject_cast<QWidget*>(pO); QColor backColor = NotificationServerSettings::instance()->value("notification_backgroundColor").value<QColor>(); float fOpacity = NotificationServerSettings::instance()->value("notification_opacity").value<float>(); QPainter painter ( pW ); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing); // corners const int kShadowCornerSize = scShadowSize + scRadiusSize; painter.drawPixmap(0, 0, shadowsCorners.at(0)); painter.drawPixmap(pW->width() - kShadowCornerSize, 0, shadowsCorners.at(1)); painter.drawPixmap(pW->width() - kShadowCornerSize, pW->height() - kShadowCornerSize, shadowsCorners.at(2)); painter.drawPixmap(0, pW->height() - kShadowCornerSize, shadowsCorners.at(3)); //edges painter.drawTiledPixmap(kShadowCornerSize, 0,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(0)); painter.drawTiledPixmap(pW->width() - scShadowSize, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(1)); painter.drawTiledPixmap(kShadowCornerSize, pW->height() - scShadowSize,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(2)); painter.drawTiledPixmap(0, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(3)); // rounded pixmap painter.setBrush(backColor); painter.setPen(backColor); painter.setOpacity(fOpacity); painter.drawRoundedRect(scShadowSize,scShadowSize,pW->width()-2*scShadowSize, pW->height()-2*scShadowSize,scRadiusSize,scRadiusSize); } }
void QUProfileController::drawLoadingMessage(QPainter & p) { if( avail() < m_total || m_total == 0) { p.save(); p.setFont ( m_captionFont); p.setOpacity(1); QString txt = QString( "Loading %1/%2").arg( avail()).arg(m_total); QRectF anchor( m_buffer.width()/2.0, m_buffer.height()/2.0, 1, 1); QRectF brect = p.boundingRect( anchor, Qt::AlignCenter | Qt::TextDontClip, txt); brect.adjust( -3, -3, 3, 3); QColor bg( 255, 255, 255, 225); QColor border( 128, 0, 0, 225); p.setPen( border); p.setBrush( bg); p.drawRoundedRect( brect, 5, 5); p.setPen( QColor(0, 0, 0)); p.drawText(anchor, Qt::AlignCenter | Qt::TextDontClip, txt); p.setPen( QPen(QColor( 0, 0, 0, 128), 1, Qt::DashLine)); p.restore(); } }
void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity) { m_context->markLayerComposited(); blitMultisampleFramebufferAndRestoreContext(); if (textureMapper->accelerationMode() == TextureMapper::OpenGLMode) { TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper); TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0); IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight); texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity); return; } // Alternatively read pixels to a memory buffer. GraphicsContext* context = textureMapper->graphicsContext(); QPainter* painter = context->platformContext(); painter->save(); painter->setTransform(matrix); painter->setOpacity(opacity); const int height = m_context->m_currentHeight; const int width = m_context->m_currentWidth; painter->beginNativePainting(); makeCurrentIfNeeded(); glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_fbo); QImage offscreenImage = qt_gl_read_framebuffer(QSize(width, height), true, true); glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_state.boundFBO); painter->endNativePainting(); painter->drawImage(targetRect, offscreenImage); painter->restore(); }
void Scene::drawTextHint(QPainter& painter) { painter.setOpacity(1); painter.setPen(QPen(Qt::white)); painter.setFont(gameStock->font12); QString hintText = "Hint"; painter.drawText(0, DY(690), DX(860), DY(30), Qt::AlignRight, hintText); }
void painterUtils::drawRectangleBar(QPainter &qp ,int const &startPos,int const &width, int const &height ,const float value, bool drawText , QColor &color1 , QColor &color2) { //Calculate how many pixel our rectangle will cover in width, we base the computation on the current input value // which should be a percentage int pixToCover = width * value/100.0f ; //Lets check the result iis not too small if ( value < 1.0 || pixToCover < 0 ) { pixToCover =4; } //or too big if (pixToCover >= width) { pixToCover = width - 4; } //Lets build the backaground rectangle QRect myQRect = QRect(QPoint(startPos,3) , QSize(pixToCover-1,height-6)); //Lets build the gradient QLinearGradient gradient(myQRect.topLeft(), myQRect.topRight()); // diagonal gradient from top-left to bottom-right //Lets set the color for the start positon gradient.setColorAt(0, color1); float r =(255*value/100.0f); if (r<0) r=0; if (r>255) r=255; r /= 255; //Lets interpolate the second color based on the percentage value gradient.setColorAt(1, QColor(color1.red()* (1-r) + color2.red()*r, color1.green()* (1-r) + color2.green()*r, color1.blue()* (1-r) + color2.blue()*r, 255)); //Lets draw the gradient qp.fillRect(myQRect, gradient); //Lets draw the text in the center of the triangle if needed if (drawText == true) { qp.setOpacity(0.4); qp.setFont(QFont("Helvetica", 20, QFont::Bold)); qp.drawText(startPos + (width/2),height/2,QString::number(int(value)) + " %"); qp.setOpacity(1.0); } }
bool QtDNDTabBar::event(QEvent* event) { QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event); if (mouseEvent) { QWidget* childAtPoint = window()->childAt(mapTo(window(), mouseEvent->pos())); QtDNDTabBar* underMouse = dynamic_cast<QtDNDTabBar*>(childAtPoint); if (!underMouse && childAtPoint) { underMouse = dynamic_cast<QtDNDTabBar*>(childAtPoint->parent()); } if (!underMouse && currentIndex() >= 0) { // detach and drag // stop move event QMouseEvent* finishMoveEvent = new QMouseEvent (QEvent::MouseMove, mouseEvent->pos (), Qt::NoButton, Qt::NoButton, Qt::NoModifier); QTabBar::event(finishMoveEvent); delete finishMoveEvent; finishMoveEvent = NULL; // start drag QDrag* drag = new QDrag(this); QMimeData* mimeData = new QMimeData; // distinguish tab-reordering drops from other ones mimeData->setData("action", "application/tab-detach") ; drag->setMimeData(mimeData); // set drag image QRect rect = tabRect( currentIndex() ); #if QT_VERSION >= 0x050000 QPixmap pixmap = grab(rect); #else QPixmap pixmap = QPixmap::grabWidget(this, rect); #endif QPixmap targetPixmap (pixmap.size ()); QPainter painter (&targetPixmap); painter.setOpacity(0.9); painter.drawPixmap(0,0, pixmap); painter.end (); drag->setPixmap (targetPixmap); drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height())); dragIndex = currentIndex(); dragText = tabText(dragIndex); dragWidget = dynamic_cast<QTabWidget*>(parent())->widget(dragIndex); assert(dragWidget); dynamic_cast<QTabWidget*>(parent())->removeTab(currentIndex()); Qt::DropAction dropAction = drag->exec(); if (dropAction == Qt::IgnoreAction) { // aborted drag, put tab back in place // disable event handling during the insert for the tab to prevent infinite recursion (stack overflow) dragWidget->blockSignals(true); dynamic_cast<QTabWidget*>(parent())->insertTab(dragIndex, dragWidget, dragText); dragWidget->blockSignals(false); } return true; } } return QTabBar::event(event); }
void IScene::drawTextHint(QPainter &p) { p.setOpacity(1); p.setPen(QPen(Qt::yellow)); p.setFont(gameStock->Font12); //p.drawText(0,DY(690),DX(860),DY(30), Qt::AlignRight, hintText); p.drawText(0,DY(675),WIDTH,DY(30), Qt::AlignCenter, hintText); }
void AnimationViewerPanel::renderTargetSprite(const QPoint& centerPoint, QPainter& painter) { painter.setOpacity(mpAnimationModel->getTargetSprite()->mSpriteDescriptor.mAlpha); painter.translate(centerPoint.x(), centerPoint.y()); mpAnimationModel->getTargetSprite()->render(QPoint(0, 0), painter, NULL, false, mEmittedAnimationList); painter.translate(-centerPoint.x(), -centerPoint.y()); }
void CanvasRenderer::paintCameraBorder(QPainter &painter) { for ( int i = 0; i < mObject->getLayerCount(); ++i ) { Layer* layer = mObject->getLayer( i ); if ( layer->type() == Layer::CAMERA && (i == mLayerIndex || mOptions.nShowAllLayers > 0) && layer->visible() ) { if ( i == mLayerIndex || mOptions.nShowAllLayers != 1 ) { painter.setOpacity( 1.0 ); } else { painter.setOpacity( 0.8 ); } QRectF viewRect = painter.viewport(); QRect boundingRect = mViewTransform.inverted().mapRect( viewRect ).toRect(); LayerCamera* cameraLayer = dynamic_cast< LayerCamera* >( layer ); QRect cameraRect = cameraLayer->getViewRect(); painter.setWorldMatrixEnabled( true ); painter.setPen( Qt::NoPen ); painter.setBrush( QColor( 0, 0, 0, 160 ) ); QRegion rg1(boundingRect); QRegion rg2(cameraRect); QRegion rg3=rg1.subtracted(rg2); painter.setClipRegion(rg3); painter.drawRect( boundingRect ); painter.setClipping(false); painter.setPen( Qt::black ); painter.setBrush( Qt::NoBrush ); painter.drawRect( cameraRect ); } } }
void OraHandler::render_stack( xml_node node, QPainter &painter, int offset_x, int offset_y ) const{ for( xml_node_iterator it = --node.end(); it != --node.begin(); it-- ){ std::string name( (*it).name() ); if( name == "stack" ){ int x = (*it).attribute( "x" ).as_int( 0 ); int y = (*it).attribute( "y" ).as_int( 0 ); render_stack( *it, painter, offset_x+x, offset_y+y ); } else if( name == "text" ){ qWarning( "No support for text" ); } else if( name == "layer" ){ QString source( QString::fromUtf8( (*it).attribute( "src" ).value() ) ); int x = (*it).attribute( "x" ).as_int( 0 ) + offset_x; int y = (*it).attribute( "y" ).as_int( 0 ) + offset_y; std::string visibility = (*it).attribute( "visibility" ).value(); if( visibility == "" || visibility == "visible" ){ //composite-op std::string composite = (*it).attribute( "composite-op" ).value(); QPainter::CompositionMode mode = QPainter::CompositionMode_SourceOver; if( !ora_composite_mode( composite, mode ) ) qWarning( "Unsupported composite-op: %s", composite.c_str() ); painter.setCompositionMode( mode ); double opacity = (*it).attribute( "opacity" ).as_double( 1.0 ); painter.setOpacity( opacity ); std::map<QString,QImage>::const_iterator img_it = images.find( source ); if( img_it != images.end() ) painter.drawImage( x, y, img_it->second ); else qWarning( "Layer source not found: %s", source.toLocal8Bit().constData() ); //Restore modified settings painter.setOpacity( 1.0 ); painter.setCompositionMode( QPainter::CompositionMode_SourceOver ); } } else{ qWarning( "Unrecognized element: %s", name.c_str() ); } } }