void Game::drawPlayerModel(int x, int y, int r, int g, int b) { lineUp(30, x, y, r, g, b,0); lineLeft(40,x,y,r,g,b,0); lineUp(30,x - 40,y,r,g,b,0); lineRight(40,x - 40,y - 30,r,g,b,0); }
void KisPerspectiveGridManager::drawDecoration(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter) { Q_UNUSED(updateRect); KisImageWSP image = m_view->resourceProvider()->currentImage(); Q_ASSERT(image); KisPerspectiveGrid* pGrid = image->perspectiveGrid(); QPen mainPen = KisGridPainterConfiguration::mainPen(); QPen subdivisionPen = KisGridPainterConfiguration::subdivisionPen(); QPen errorPen = mainPen; errorPen.setColor(Qt::red); QTransform transform = converter->imageToWidgetTransform(); gc.save(); gc.setTransform(transform); for (QList<KisSubPerspectiveGrid*>::const_iterator it = pGrid->begin(); it != pGrid->end(); ++it) { const KisSubPerspectiveGrid* grid = *it; /** * Note that the notion of top-bottom-right-left * is purely theorical */ LineWrapper lineTop(*grid->topLeft(), *grid->topRight()); LineWrapper lineRight(*grid->topRight(), *grid->bottomRight()); LineWrapper lineBottom(*grid->bottomRight(), *grid->bottomLeft()); LineWrapper lineLeft(*grid->bottomLeft(), *grid->topLeft()); QPointF horizIntersection; QPointF vertIntersection; bool linesNotNull = true; bool polygonIsConvex = true; if(lineTop.isNull(SMALLEST_LINE) || lineBottom.isNull(SMALLEST_LINE) || lineLeft.isNull(SMALLEST_LINE) || lineRight.isNull(SMALLEST_LINE)) { linesNotNull = false; } if(linesNotNull) { horizIntersection = lineTop.intersects(lineBottom); vertIntersection = lineLeft.intersects(lineRight); if(lineTop.contains(horizIntersection) || lineBottom.contains(horizIntersection) || lineLeft.contains(vertIntersection) || lineRight.contains(vertIntersection)) { polygonIsConvex = false; } } if(polygonIsConvex && linesNotNull) { gc.setPen(subdivisionPen); SubdivisionLinesInfo info; info = getSubdivisionsInfo(lineTop, lineBottom, vertIntersection, grid->subdivisions()); drawSubdivisions(gc, info); info = getSubdivisionsInfo(lineLeft, lineRight, horizIntersection, grid->subdivisions()); drawSubdivisions(gc, info); } gc.setPen(polygonIsConvex && linesNotNull ? mainPen : errorPen); gc.drawLine(*grid->topLeft(), *grid->topRight()); gc.drawLine(*grid->topRight(), *grid->bottomRight()); gc.drawLine(*grid->bottomRight(), *grid->bottomLeft()); gc.drawLine(*grid->bottomLeft(), *grid->topLeft()); } gc.restore(); }