void PolygonObject::updatePath(const QPainterPath& p)
{
    normalPath = p;
    QPainterPath closedPath = normalPath;
    closedPath.closeSubpath();
    QPainterPath reversePath = closedPath.toReversed();
    reversePath.connectPath(closedPath);
    setObjectPath(reversePath);
}
QPainterPath UBGraphicsCompass::needleShape() const
{
    QPainterPath path;
    path.moveTo(rect().left(), rect().center().y());
    path.lineTo(rect().left() + sNeedleLength, rect().center().y() - 2);
    path.lineTo(rect().left() + sNeedleLength, rect().center().y() + 2);
    path.closeSubpath();
    return path;
}
Exemple #3
0
static bool parseGlyphPathData(const char *svgPath, const char *svgPathEnd, QPainterPath &path,
                               qreal fontPixelSize, const QPointF &offset, bool hinted)
{
    Q_UNUSED(hinted)
    QPointF p1, p2, firstSubPathPoint;
    qreal *elementValues[] =
        {&p1.rx(), &p1.ry(), &p2.rx(), &p2.ry()};
    const int unitsPerEm = 2048; // See: http://en.wikipedia.org/wiki/Em_%28typography%29
    const qreal resizeFactor = fontPixelSize / unitsPerEm;

    while (svgPath < svgPathEnd) {
        skipSpacesAndComma(svgPath, svgPathEnd);
        const char pathElem = *svgPath++;
        skipSpacesAndComma(svgPath, svgPathEnd);

        if (pathElem != 'Z') {
            char *endStr = 0;
            int elementValuesCount = 0;
            for (int i = 0; i < 4; ++i) { // 4 = size of elementValues[]
                qreal coordinateValue = strtod(svgPath, &endStr);
                if (svgPath == endStr)
                    break;
                if (i % 2) // Flip vertically
                    coordinateValue = -coordinateValue;
                *elementValues[i] = coordinateValue * resizeFactor;
                elementValuesCount++;
                svgPath = endStr;
                skipSpacesAndComma(svgPath, svgPathEnd);
            }
            p1 += offset;
            if (elementValuesCount == 2)
                p2 = firstSubPathPoint;
            else
                p2 += offset;
        }

        switch (pathElem) {
        case 'M':
            firstSubPathPoint = p1;
            path.moveTo(p1);
            break;
        case 'Z':
            path.closeSubpath();
            break;
        case 'L':
            path.lineTo(p1);
            break;
        case 'Q':
            path.quadTo(p1, p2);
            break;
        default:
            return false;
        }
    }
    return true;
}
Exemple #4
0
void
CQGroupBox::
drawArcShape(QPainter *painter, double xc, double yc, double r, double startAngle, int sides) const
{
  auto Deg2Rad = [](double d) -> double { return M_PI*d/180.0; };
//auto Rad2Deg = [](double r) -> double { return 180.0*r/M_PI; };

  double x1 = xc - r;
  double y1 = yc - r;
  double x2 = xc + r;
  double y2 = yc + r;

  double xm = (x1 + x2)/2;
  double ym = (y1 + y2)/2;

  double da = 360.0/sides;
  double dc = 360.0/40;

  QPainterPath path;

  for (int i = 0; i < sides; ++i) {
    double angle = startAngle + i*da;

    double a1 = Deg2Rad(angle - dc);
    double a2 = Deg2Rad(angle + dc);

    double c1 = cos(a1), s1 = sin(a1);
    double c2 = cos(a2), s2 = sin(a2);

    QPointF p1(xm + r*c1, ym + r*s1);
    QPointF p2(xm + r*c2, ym + r*s2);

    if (i == 0)
      path.moveTo(p1);
    else
      path.lineTo(p1);

    //---

    QPointF p12 = (p1 + p2)/2;

    double ar = 2*hypot(p1.x() - p12.x(), p1.y() - p12.y())/sides;

    double a = Deg2Rad(angle);

    double c = cos(a), s = sin(a);

    QPointF pq(xm + (r + ar)*c, ym + (r + ar)*s);

    path.quadTo(pq, p2);
  }

  path.closeSubpath();

  painter->drawPath(path);
}
QPainterPath PolygonObject::objectSavePath() const
{
    QPainterPath closedPath = normalPath;
    closedPath.closeSubpath();
    qreal s = scale();
    QTransform trans;
    trans.rotate(rotation());
    trans.scale(s,s);
    return trans.map(closedPath);
}
void UIGDetailsElement::paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
{
    /* Save painter: */
    pPainter->save();

    /* Prepare variables: */
    int iMargin = data(ElementData_Margin).toInt();
    int iHeaderHeight = 2 * iMargin + m_iMinimumHeaderHeight;
    QRect optionRect = pOption->rect;
    QRect fullRect = !m_fAnimationRunning ? optionRect :
                     QRect(optionRect.topLeft(), QSize(optionRect.width(), iHeaderHeight + m_iAdditionalHeight));
    int iFullHeight = fullRect.height();

    /* Prepare color: */
    QPalette pal = palette();
    QColor headerColor = pal.color(QPalette::Active, QPalette::Button);
    QColor strokeColor = pal.color(QPalette::Active, QPalette::Mid);
    QColor bodyColor = pal.color(QPalette::Active, QPalette::Base);

    /* Add clipping: */
    QPainterPath path;
    path.moveTo(m_iCornerRadius, 0);
    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, 0), 90, 90);
    path.lineTo(path.currentPosition().x(), iFullHeight - m_iCornerRadius);
    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(0, -m_iCornerRadius), 180, 90);
    path.lineTo(fullRect.width() - m_iCornerRadius, path.currentPosition().y());
    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, -2 * m_iCornerRadius), 270, 90);
    path.lineTo(path.currentPosition().x(), m_iCornerRadius);
    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-2 * m_iCornerRadius, -m_iCornerRadius), 0, 90);
    path.closeSubpath();
    pPainter->setClipPath(path);

    /* Calculate top rectangle: */
    QRect tRect = fullRect;
    tRect.setBottom(tRect.top() + iHeaderHeight);
    /* Calculate bottom rectangle: */
    QRect bRect = fullRect;
    bRect.setTop(tRect.bottom());

    /* Prepare top gradient: */
    QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft());
    tGradient.setColorAt(0, headerColor.darker(110));
    tGradient.setColorAt(1, headerColor.darker(animationDarkness()));

    /* Paint all the stuff: */
    pPainter->fillRect(tRect, tGradient);
    pPainter->fillRect(bRect, bodyColor);

    /* Stroke path: */
    pPainter->setClipping(false);
    pPainter->strokePath(path, strokeColor);

    /* Restore painter: */
    pPainter->restore();
}
Exemple #7
0
QPainterPath Paths::triangle2()
{  
    QPainterPath path;

    path.moveTo(0, 120);
    path.lineTo(60, 120);
    path.lineTo(60, 60);
    path.closeSubpath();

    return path;
}
void ShapeSizeVisitor::visitTriangle(const TriangleShape *shapeTriangle)
{
    QPainterPath path;
    QPointF center = shapeTriangle->center().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
    QSizeF size = shapeTriangle->size().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
    path.moveTo(center + QPointF(size.width() / 2.0, size.height() / 2.0));
    path.lineTo(center + QPointF(-size.width() / 2.0, size.height() / 2.0));
    path.lineTo(center + QPointF(0.0, -size.height() / 2.0));
    path.closeSubpath();
    m_boundingRect |= path.boundingRect();
}
Exemple #9
0
QPainterPath Paths::frame3()
{
    QPainterPath path;
    path.moveTo(200,80.933609);
    path.lineTo(682.85715,80.933609);
    path.lineTo(682.85715,446.6479);
    path.lineTo(200,446.6479);
    path.lineTo(200,80.933609);
    path.closeSubpath();
    return path;
}
Exemple #10
0
void Stem::draw(QPainter* painter) const
      {
      Staff* st = staff();
      bool useTab = st && st->isTabStaff();

      if (useTab && st->staffType()->slashStyle())
            return;
      qreal lw = lineWidth();
      painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap));
      painter->drawLine(line);
      if (!useTab)
            return;

      // TODO: adjust bounding rectangle in layout() for dots and for slash
      StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st->staffType());
      qreal sp = spatium();

      // slashed half note stem
      if (chord() && chord()->durationType().type() == TDuration::V_HALF
         && stt->minimStyle() == TAB_MINIM_SLASHED) {
            qreal wdt   = sp * STAFFTYPE_TAB_SLASH_WIDTH;
            qreal sln   = sp * STAFFTYPE_TAB_SLASH_SLANTY;
            qreal thk   = sp * STAFFTYPE_TAB_SLASH_THICK;
            qreal displ = sp * STAFFTYPE_TAB_SLASH_DISPL;
            QPainterPath path;

            qreal y = stt->stemsDown() ?
                         _len - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp :
                        -_len + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp;
            for (int i = 0; i < 2; ++i) {
                  path.moveTo( wdt*0.5-lw, y);        // top-right corner
                  path.lineTo( wdt*0.5-lw, y+thk);    // bottom-right corner
                  path.lineTo(-wdt*0.5,    y+thk+sln);// bottom-left corner
                  path.lineTo(-wdt*0.5,    y+sln);    // top-left corner
                  path.closeSubpath();
                  y += displ;
                  }
//            setbbox(path.boundingRect());
            painter->setBrush(QBrush(curColor()));
            painter->setPen(Qt::NoPen);
            painter->drawPath(path);
            }

      // dots
      // NOT THE BEST PLACE FOR THIS?
      // with tablatures, dots are not drawn near 'notes', but near stems
      int nDots = chord()->dots();
      if (nDots > 0) {
            qreal y = stemLen() - (stt->stemsDown() ?
                        (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 );
            symbols[score()->symIdx()][dotSym].draw(painter, magS(),
                        QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots);
            }
      }
Exemple #11
0
QPainterPath Paths::simpleCurve3()
{
    QPainterPath path;

    path.moveTo(0, 0);
    path.cubicTo(400,0,
                 0,400,
                 0,0);
    path.closeSubpath();

    return path;
}
Exemple #12
0
// w=width, h=height, indent=degree of indentation of pertubring glyph sides
QPainterPath PerturbingEPN::singleShape(int w, int h, int indent) const
{
    QPainterPath p;
    p.moveTo( -w/2, -h/2 );
    p.lineTo( -w/2+indent, 0);
    p.lineTo( -w/2, h/2);
    p.lineTo( w/2, h/2 );
    p.lineTo( w/2-indent, 0 );
    p.lineTo( w/2, -h/2 );
    p.closeSubpath();
    return p;
}
QPainterPath UBGraphicsCompass::pencilShape() const
{
    int penWidthIndex = UBSettings::settings()->penWidthIndex();
    int logicalCompassPencilWidth = penWidthIndex > 1 ? 8 : (penWidthIndex > 0 ? 4 : 2);
    QPainterPath path;
    path.moveTo(rect().right() - sPencilLength, rect().center().y() - logicalCompassPencilWidth / 2);
    path.lineTo(rect().right() - logicalCompassPencilWidth / 2, rect().center().y() - logicalCompassPencilWidth / 2);
    QRectF tipRect(rect().right() - logicalCompassPencilWidth, rect().center().y() - logicalCompassPencilWidth / 2, logicalCompassPencilWidth, logicalCompassPencilWidth);
    path.arcTo(tipRect, 90, -180);
    path.lineTo(rect().right() - sPencilLength, rect().center().y() + logicalCompassPencilWidth / 2);
    path.closeSubpath();
    return path;
}
Exemple #14
0
QPainterPath HalfOvalSymbol::painterPath(void)
{
  QPainterPath path;

  if (m_w > m_h) {
    qreal rad = m_h / 2;
    path.moveTo(rad, -rad);
    path.arcTo(0, -m_h/2, m_h, m_h, 90, -180);
    path.lineTo(m_h - m_w, m_h/2);
    path.lineTo(m_h - m_w, -m_h/2);
    path.closeSubpath();
  } else {
    qreal rad = m_w / 2;
    path.moveTo(rad, -rad);
    path.arcTo(-m_w/2, -m_w, m_w, m_w, 0, 180);
    path.lineTo(-m_w/2, m_h - m_w);
    path.lineTo(m_w/2, m_h - m_w);
    path.closeSubpath();
  }

  return path;
}
Exemple #15
0
QPainterPath Paths::frame4()
{
    QPainterPath path;

    path.moveTo(88.571434,206.64789);
    path.lineTo(231.42858,206.64789);
    path.lineTo(231.42858,246.64789);
    path.lineTo(88.571434,246.64789);
    path.lineTo(88.571434,206.64789);
    path.closeSubpath();

    return path;
}
QPainterPath QSysMLAction::shapeInternal() const
{
	QPainterPath p;
	if (property("actionType") == "default"){
		p.addRoundedRect(0, 50, geometry().width(), geometry().height() - 100, 40, 40);
	} else if (property("actionType") == "event"){
		p.moveTo(0, 50);
		p.lineTo(geometry().width(), 50);
		p.lineTo(geometry().width(), geometry().height() - 50);
		p.lineTo(0, geometry().height() - 50);
		p.lineTo((geometry().height() - 100) / 2, geometry().height() / 2);
		p.closeSubpath();
	} else if (property("actionType") == "sendSignal"){
		p.moveTo(0, 50);
		p.lineTo(geometry().width() - (geometry().height() - 100) / 2, 50);
		p.lineTo(geometry().width(), geometry().height() / 2);
		p.lineTo(geometry().width() - (geometry().height() - 100) / 2, geometry().height() - 50);
		p.lineTo(0, geometry().height() - 50);
		p.closeSubpath();
	}
	return p;
}
Exemple #17
0
QPainterPath TriangleSymbol::painterPath(void)
{
  QPainterPath path;

  //The co-ordinates of y needs to be flipped
  //due to it is screen co-ordination ( increase from top to down )
  path.moveTo(0, - m_h / 2);
  path.lineTo(- m_base / 2, m_h / 2);
  path.lineTo(m_base / 2, m_h / 2);
  path.closeSubpath();

  return path;
}
Exemple #18
0
void Smb4KToolTip::paintEvent(QPaintEvent *e)
{
  // Copied from Dolphin's meta data tool tips.
  Q_UNUSED(e);

  QPainter painter(this);

  QColor toColor = palette().brush(QPalette::ToolTipBase).color();
  QColor fromColor = KColorScheme::shade(toColor, KColorScheme::LightShade, 0.2);

  const bool haveAlphaChannel = KWindowSystem::compositingActive();
  
  if (haveAlphaChannel)
  {
    painter.setRenderHint(QPainter::Antialiasing);
    painter.translate(0.5, 0.5);
    toColor.setAlpha(220);
    fromColor.setAlpha(220);
  }
  else
  {
    // Do nothing
  }

  QLinearGradient gradient(QPointF(0.0, 0.0), QPointF(0.0, height()));
  gradient.setColorAt(0.0, fromColor);
  gradient.setColorAt(1.0, toColor);
  painter.setPen(Qt::NoPen);
  painter.setBrush(gradient);

  const QRect rect(0, 0, width(), height());
    
  if (haveAlphaChannel) 
  {
    const qreal radius = 5.0;

    QPainterPath path;
    path.moveTo(rect.left(), rect.top() + radius);
    arc(path, rect.left() + radius, rect.top() + radius, radius, 180, -90);
    arc(path, rect.right() - radius, rect.top() + radius, radius, 90, -90);
    arc(path, rect.right() - radius, rect.bottom() - radius, radius, 0, -90);
    arc(path, rect.left() + radius, rect.bottom() - radius, radius, 270, -90);
    path.closeSubpath();

    painter.drawPath(path);
  } 
  else 
  {
    painter.drawRect(rect);
  }
}
Exemple #19
0
void UIMiniToolBar::rebuildShape()
{
#ifdef VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR
    /* Rebuild shape: */
    QPainterPath shape;
    switch (m_alignment)
    {
        case Qt::AlignTop:
        {
            shape.moveTo(0, 0);
            shape.lineTo(shape.currentPosition().x(), height() - 10);
            shape.arcTo(QRectF(shape.currentPosition(), QSizeF(20, 20)).translated(0, -10), 180, 90);
            shape.lineTo(width() - 10, shape.currentPosition().y());
            shape.arcTo(QRectF(shape.currentPosition(), QSizeF(20, 20)).translated(-10, -20), 270, 90);
            shape.lineTo(shape.currentPosition().x(), 0);
            shape.closeSubpath();
            break;
        }
        case Qt::AlignBottom:
        {
            shape.moveTo(0, height());
            shape.lineTo(shape.currentPosition().x(), 10);
            shape.arcTo(QRectF(shape.currentPosition(), QSizeF(20, 20)).translated(0, -10), 180, -90);
            shape.lineTo(width() - 10, shape.currentPosition().y());
            shape.arcTo(QRectF(shape.currentPosition(), QSizeF(20, 20)).translated(-10, 0), 90, -90);
            shape.lineTo(shape.currentPosition().x(), height());
            shape.closeSubpath();
            break;
        }
        default:
            break;
    }
    m_shape = shape;

    /* Update: */
    update();
#endif /* VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR */
}
QPainterPath VerticalHexagonSymbol::painterPath(void)
{
  QPainterPath path;

  path.moveTo( 0, -m_h/2 );
  path.lineTo( -m_w/2, -m_h/2 + m_r );
  path.lineTo( -m_w/2, m_h/2 - m_r );
  path.lineTo( 0, m_h/2 );
  path.lineTo( m_w/2, m_h/2 - m_r );
  path.lineTo( m_w/2, -m_h/2 + m_r );
  path.closeSubpath();

  return path;
}
Exemple #21
0
QPainterPath Paths::simpleCurve2()
{
    QPainterPath path;
    path.moveTo(54, 140);
    path.cubicTo( 54, 140,
                 254, 386,
                 405, 146);
    path.cubicTo(557, -93,
                  57, 140,
                  54, 140);
    path.closeSubpath();

    return path;
}
Exemple #22
0
QPainterPath Paths::simpleCurve()
{
    QPainterPath path;
    path.moveTo(74, 160);
    path.cubicTo( 74, 160,
                 274, 406,
                 425, 166);
    path.cubicTo(577, -73,
                  77, 160,
                  74, 160);
    path.closeSubpath();

    return path;
}
Exemple #23
0
QPainterPath Paths::mailbox()
{
    QPainterPath path;
    path.moveTo(355.22951,136.82424);
    path.lineTo(332.03629,112.56585);
    path.lineTo(325.71086,57.501867);
    path.cubicTo(325.71086,57.501867, 410.12308,19.428758, 427.45202,29.094560);
    path.cubicTo(444.78096,38.760366, 443.62570,54.289660, 443.62570,54.289660);
    path.lineTo(443.62570,100.11509);
    path.lineTo(355.22951,136.82424);
    path.closeSubpath();
    
    return path;
}
void ShapePaintVisitor::visitTriangle(const TriangleShape *shapeTriangle)
{
    m_painter->save();
    m_painter->setRenderHint(QPainter::Antialiasing, true);
    QPainterPath path;
    QPointF center = shapeTriangle->center().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
    QSizeF size = shapeTriangle->size().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
    path.moveTo(center + QPointF(size.width() / 2.0, size.height() / 2.0));
    path.lineTo(center + QPointF(-size.width() / 2.0, size.height() / 2.0));
    path.lineTo(center + QPointF(0.0, -size.height() / 2.0));
    path.closeSubpath();
    m_painter->drawPath(path);
    m_painter->restore();
}
QPainterPath
Shapes::max(const QRectF &bound, Style style)
{
    _S(3) _S(4) _S(8)
    QPainterPath path;
    switch (style)
    {
    case Square:
        path.addRect(bound);
        path.addRect(bound.adjusted(0, s4, -s4, 0));
        path.addRect(bound.adjusted(0, 2*s3, -2*s3, 0));
        break;
    case LasseKongo:
    {
        _S(5);
        const float d = 3*s5;
        QRectF rect = bound.adjusted(0,0,-d,-d);
        QRectF rect2(0,0,d,d);
        
        path.addRect(rect);
        rect2.moveCenter(rect.bottomRight());
        path.moveTo(rect2.center()); path.arcTo(rect2, 90, 90); path.closeSubpath();

        rect.translate(d,0);
        path.addRect(rect);
        rect2.moveCenter(rect.bottomLeft());
        path.moveTo(rect2.center()); path.arcTo(rect2, 0, 90); path.closeSubpath();
        
        rect.translate(0,d);
        path.addRect(rect);
        rect2.moveCenter(rect.topLeft());
        path.moveTo(rect2.center()); path.arcTo(rect2, -90, 90); path.closeSubpath();
        
        rect.translate(-d,0);
        path.addRect(rect);
        rect2.moveCenter(rect.topRight());
        path.moveTo(rect2.center()); path.arcTo(rect2, -180, 90); path.closeSubpath();
        break;
    }
    default:
    case Round:
        //path.moveTo(bound.center());
        //path.arcTo(bound, 0, 180);
        //path.closeSubpath();
        break;
    case TheRob:
        path.moveTo(bound.center());
        path.arcTo(bound, 0, 180);
        path.closeSubpath();
        path.moveTo(bound.center());
        path.arcTo(bound.adjusted(s8,s8,-s8,-s8), 0, 180);
        path.closeSubpath();
        path.addEllipse(bound.adjusted(s4,s4,-s4,-s4));
        break;
    }
    return path;
}
void qt_opengl_draw_test_pattern(QPainter* painter, int width, int height)
{
    QPainterPath intersectingPath;
    intersectingPath.moveTo(0, 0);
    intersectingPath.lineTo(100, 0);
    intersectingPath.lineTo(0, 100);
    intersectingPath.lineTo(100, 100);
    intersectingPath.closeSubpath();

    QPainterPath trianglePath;
    trianglePath.moveTo(50, 0);
    trianglePath.lineTo(100, 100);
    trianglePath.lineTo(0, 100);
    trianglePath.closeSubpath();

    painter->setTransform(QTransform()); // reset xform
    painter->fillRect(-1, -1, width+2, height+2, Qt::red); // Background
    painter->translate(14, 14);
    painter->fillPath(intersectingPath, Qt::blue); // Test stencil buffer works
    painter->translate(128, 0);
    painter->setClipPath(trianglePath); // Test depth buffer works
    painter->setTransform(QTransform()); // reset xform ready for fill
    painter->fillRect(-1, -1, width+2, height+2, Qt::green);
}
QPainterPath
Shapes::min(const QRectF &bound, Style style)
{
    _S(3) _S(4) _S(8)
    QPainterPath path;
    switch (style)
    {
    case Square:
    {
        path.addRect(bound);
        path.addRect(bound.adjusted(s4, 0, 0, -s4));
        path.addRect(bound.adjusted(2*s3, 0, 0, -2*s3));
        break;
    }
    case LasseKongo:
        path.addRect(bound.adjusted(0, 2*s3, 0, 0));
        path.addRect(bound.adjusted(s8, 2*s3, -s8, -s8));
        break;
    default:
    case Round:
       // path.moveTo(bound.center());
       // path.arcTo(bound, 180, 180);
       // path.closeSubpath();
        break;
    case TheRob:
        path.moveTo(bound.center());
        path.arcTo(bound, 180, 180);
        path.closeSubpath();
        path.moveTo(bound.center());
        path.arcTo(bound.adjusted(s8,s8,-s8,-s8), 180, 180);
        path.closeSubpath();
        path.addEllipse(bound.adjusted(s4,s4,-s4,-s4));
        break;
    }
    return path;
}
Exemple #28
0
Spark::Spark(Sprite* p)
    :Sprite(p)
{
    this->width = 100;
    this->height = 100;
    starPath.moveTo(90, 50);
    for (int i = 1; i < 5; ++i) {
        starPath.lineTo(50 + 40 * cos(0.8 * i * Pi),
                        50 + 40 * sin(0.8 * i * Pi));
    }
    starPath.closeSubpath();
    timer = new QTimer(this);
    this->connect(timer,SIGNAL(timeout()),this,SLOT(clear()));
    timer->start(1500);
}
QPainterPath DrawingPolygonItem::shape() const
{
	// This code should work, but doesn't
	QPainterPath path;

	QList<DrawingItemPoint*> points = DrawingPolygonItem::points();
	path.moveTo(points.first()->pos());
	for(auto pointIter = points.begin()+1; pointIter != points.end(); pointIter++)
		path.lineTo((*pointIter)->pos());
	path.closeSubpath();

	QPainterPath shape = itemShapeFromPath(path, pen());
	if (brush().color().alpha() > 0) shape = shape.united(path);
	return shape;
}
QPainterPath LineOfSightGraphics::shape() const
{
    QPainterPath p;

    //p.moveTo(0,(WIDTH/2)*ONE_INCH);
    p.lineTo(X1);
    p.arcTo(QRectF(QPointF(-radius + baseWidth/2, -radius + baseWidth/2),
                   QPointF(radius + baseWidth/2, radius + baseWidth/2)),
            135,
            -90);
    p.lineTo(baseWidth, 0);
    p.closeSubpath();

    return p;
}