Пример #1
0
        void DrawShapes(QPainter painter)
        {
            painter.SetRenderHint(QPainter.RenderHint.Antialiasing);
            painter.Pen   = new QPen(new QBrush(new QColor("Gray")), 1);
            painter.Brush = new QColor("Gray");

            var path = new QPainterPath();

            path.MoveTo(5, 5);
            path.CubicTo(40, 5, 50, 50, 99, 99);
            path.CubicTo(5, 99, 50, 50, 5, 5);
            painter.DrawPath(path);

            painter.DrawPie(130, 20, 90, 60, 30 * 16, 120 * 16);
            painter.DrawChord(240, 30, 90, 60, 0, 16 * 180);
            var rectangle = new QRect(new QPoint(20, 120), new QSize(80, 50));

            painter.DrawRoundedRect(rect: rectangle, xRadius: 10, yRadius: 10);

            // to be implemented
            //var points = new List<QPoint>();
            //points.Add ( new QPoint ( 130, 140 ) );
            //points.Add ( new QPoint ( 180, 170 ) );
            //points.Add ( new QPoint ( 180, 140 ) );
            //points.Add ( new QPoint ( 220, 110 ) );
            //points.Add ( new QPoint ( 140, 100 ) );

            //// http://doc.qt.io/qt-5/qpolygon.html#QPolygon-2 , we should be able to pase point list
            //var polygon = new QPolygon(points);
            //painter.DrawPolygon ( polygon );

            // this is workaround for DrawPolygon
            unsafe
            {
                var polygon = new QPolygon();
                var points  = new int[] { 130, 140, 180, 170, 180, 140, 220, 110, 140, 100 };
                fixed(int *point = points)
                {
                    polygon.SetPoints(points.Length / 2, ref *point);
                }

                painter.DrawPolygon(polygon);
            }

            painter.DrawRect(250, 110, 60, 60);

            var baseline  = new QPointF(20, 250);
            var font      = new QFont("Georgia", 55);
            var forntPath = new QPainterPath();

            forntPath.AddText(baseline, font, "Q");
            painter.DrawPath(forntPath);

            painter.DrawEllipse(140, 200, 60, 60);
            painter.DrawEllipse(240, 200, 90, 60);
        }
Пример #2
0
    private void PaintCannon(QPainter painter)
    {
        painter.SetPen(Qt.PenStyle.NoPen);
        painter.SetBrush(Qt.GlobalColor.blue);

        painter.Save();
        painter.Translate(0, Height());
        painter.DrawPie(new QRect(-35, -35, 70, 70), 0, 90 * 16);
        painter.Rotate(-currentAngle);
        painter.DrawRect(barrelRect);
        painter.Restore();
    }
Пример #3
0
 protected override void PaintEvent(QPaintEvent ev)
 {
     using (QPainter painter = new QPainter(this)) {
         painter.SetPen(Qt.PenStyle.NoPen);
         painter.SetBrush(new QBrush(new QColor(0,0,255)));
         painter.Translate(0,Rect.Height());
         painter.DrawPie(new QRect(-35,-35,70,70),0,90 * 16);
         painter.Rotate(-currentAngle);
         painter.DrawRect(30,-5,20,10);
         painter.End();
     }
 }
Пример #4
0
    private void paintCannon(QPainter painter)
    {
        painter.Begin(this);         // should not be necessary
        painter.SetPen(Qt.PenStyle.NoPen);
        painter.SetBrush(new QBrush(Qt.GlobalColor.blue));

        painter.Save();
        painter.Translate(0, Height());
        painter.DrawPie(new QRect(-35, -35, 70, 70), 0, 90 * 16);
        painter.Rotate(-currentAngle);
        painter.DrawRect(barrelRect);
        painter.Restore();
        painter.End();         // should not be necessary
    }
Пример #5
0
    public override void Paint(QPainter painter, QStyleOptionGraphicsItem option, QWidget widget)
    {
        painter.SetBrush(Qt.GlobalColor.gray);
        painter.DrawRect(-20, -58, 40, 2); // front axel
        painter.DrawRect(-20, 7, 40, 2);   // rear axel

        painter.SetBrush(color);
        painter.DrawRect(-25, -79, 50, 10);     // front wing

        painter.DrawEllipse(-25, -48, 50, 20);  // side pods
        painter.DrawRect(-25, -38, 50, 35);     // side pods
        painter.DrawRect(-5, 9, 10, 10);        // back pod

        painter.DrawEllipse(-10, -81, 20, 100); // main body

        painter.DrawRect(-17, 19, 34, 15);      // rear wing

        painter.SetBrush(Qt.GlobalColor.black);
        painter.DrawPie(-5, -51, 10, 15, 0, 180 * 16);
        painter.DrawRect(-5, -44, 10, 10); // cocpit

        painter.Save();
        painter.Translate(-20, -58);
        painter.Rotate(wheelsAngle);
        painter.DrawRect(-10, -7, 10, 15); // front left
        painter.Restore();

        painter.Save();
        painter.Translate(20, -58);
        painter.Rotate(wheelsAngle);
        painter.DrawRect(0, -7, 10, 15); // front left
        painter.Restore();

        painter.DrawRect(-30, 0, 12, 17); // rear left
        painter.DrawRect(19, 0, 12, 17);  // rear right
    }