void DrawPatternsEx(QPainter ptr) { ptr.SetPen(PenStyle.SolidLine); ptr.SetPen(QColor.FromRgb(255, 0, 0)); ptr.DrawLine(0, Y, Size.Width, Y); ptr.DrawLine(X, 0, X, Size.Height); }
protected override void PaintEvent(QPaintEvent ev) { using (QPainter painter = new QPainter(this)) { painter.DrawText(200,200,string.Format("Angle = {0}",currentAngle)); painter.End(); } }
protected override void MouseMoveEvent(Qyoto.QGraphicsSceneMouseEvent evnt) { var app = ((QApplication)QApplication.Instance()); if (new QLineF(evnt.ScreenPos(), evnt.ButtonDownScreenPos(Qt.MouseButton.LeftButton)) .Length() < app.StartDragDistance) { return; } if (m_Grid.Model is IAvatarGridEditableModel <T> ) { QDrag drag = new QDrag(evnt.Widget()); QMimeData mime = new RosterItemMimeData <T>(this, m_Grid); drag.SetMimeData(mime); QPixmap pixmap = new QPixmap(m_Grid.IconSize, m_Grid.IconSize); pixmap.Fill(m_Grid.Palette.Color(QPalette.ColorRole.Base)); var painter = new QPainter(pixmap); Paint(painter, null, null); painter.End(); drag.SetPixmap(pixmap); drag.Exec((uint)Qt.DropAction.MoveAction | (uint)Qt.DropAction.CopyAction | (uint)Qt.DropAction.IgnoreAction); } }
protected override void MouseMoveEvent(Qyoto.QGraphicsSceneMouseEvent evnt) { if (m_LeftButtonDown) { if (evnt.Pos().Y() > m_Grid.HeaderHeight) { return; } var app = ((QApplication)QApplication.Instance()); if (new QLineF(evnt.ScreenPos(), evnt.ButtonDownScreenPos(Qt.MouseButton.LeftButton)) .Length() < app.StartDragDistance) { return; } if (m_Grid.Model is IAvatarGridEditableModel <T> ) { QDrag drag = new QDrag(evnt.Widget()); drag.SetHotSpot(evnt.Pos().ToPoint()); var mime = new RosterItemGroupMimeData(this, m_Grid); drag.SetMimeData(mime); var pixmap = new QPixmap((int)BoundingRect().Width(), m_Grid.HeaderHeight); pixmap.Fill(m_Grid.Palette.Color(QPalette.ColorRole.Base)); var painter = new QPainter(pixmap); Paint(painter, null, null); painter.End(); drag.SetPixmap(pixmap); drag.Exec(); } } }
void DrawPatternsEx(QPainter ptr) { ptr.SetPen(PenStyle.NoPen); ptr.SetBrush(BrushStyle.HorPattern); ptr.DrawRect(10, 15, 90, 60); ptr.SetBrush(BrushStyle.VerPattern); ptr.DrawRect(130, 15, 90, 60); ptr.SetBrush(BrushStyle.CrossPattern); ptr.DrawRect(250, 15, 90, 60); ptr.SetBrush(BrushStyle.Dense7Pattern); ptr.DrawRect(10, 105, 90, 60); ptr.SetBrush(BrushStyle.Dense6Pattern); ptr.DrawRect(130, 105, 90, 60); ptr.SetBrush(BrushStyle.Dense5Pattern); ptr.DrawRect(250, 105, 90, 60); ptr.SetBrush(BrushStyle.BDiagPattern); ptr.DrawRect(10, 195, 90, 60); ptr.SetBrush(BrushStyle.FDiagPattern); ptr.DrawRect(130, 195, 90, 60); ptr.SetBrush(BrushStyle.DiagCrossPattern); ptr.DrawRect(250, 195, 90, 60); }
public override void Paint(QPainter painter, QStyleOptionGraphicsItem option, QWidget widget) { // Body painter.SetBrush(color); painter.DrawEllipse(-10, -20, 20, 40); // Eyes painter.SetBrush(Qt.GlobalColor.white); painter.DrawEllipse(-10, -17, 8, 8); painter.DrawEllipse(2, -17, 8, 8); // Nose painter.SetBrush(Qt.GlobalColor.black); painter.DrawEllipse(new QRectF(-2, -22, 4, 4)); // Pupils painter.DrawEllipse(new QRectF(-8.0 + mouseEyeDirection, -17, 4, 4)); painter.DrawEllipse(new QRectF(4.0 + mouseEyeDirection, -17, 4, 4)); // Ears painter.SetBrush(Scene().CollidingItems(this).Count == 0 ? Qt.GlobalColor.darkYellow : Qt.GlobalColor.red); painter.DrawEllipse(-17, -12, 16, 16); painter.DrawEllipse(1, -12, 16, 16); // Tail QPainterPath path = new QPainterPath(new QPointF(0, 20)); path.CubicTo(-5, 22, -5, 22, 0, 25); path.CubicTo(5, 27, 5, 32, 0, 30); path.CubicTo(-5, 32, -5, 42, 0, 35); painter.SetBrush(Qt.BrushStyle.NoBrush); painter.DrawPath(path); }
private void paintShot(QPainter painter) { painter.Begin(this); // should not be necessary painter.SetPen(Qt.PenStyle.NoPen); painter.SetBrush(new QBrush(Qt.GlobalColor.black)); painter.DrawRect(shotRect()); painter.End(); // should not be necessary }
protected override void OnPaintEvent(QPaintEvent e) { base.OnPaintEvent(e); var painter = new QPainter(this); DrawImages(painter); painter.End( ); }
protected override void OnPaintEvent(QPaintEvent e) { base.OnPaintEvent(e); var painter = new QPainter(this); painter.SetRenderHint(QPainter.RenderHint.Antialiasing); DrawPatternsEx(painter); painter.End(); }
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); }
void DrawRectangles(QPainter painter) { painter.SetPen(PenStyle.NoPen); for (int i = 1; i < 11; i++) { painter.Brush = new QColor(0, 0, 255, i * 25); painter.DrawRect(50 * i, 20, 40, 40); } }
protected override void OnPaintEvent(QPaintEvent e) { base.OnPaintEvent(e); // this is example from Qt site, http://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html var painter = new QPainter(this); DrawRectangles(painter); painter.End( ); }
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(); } }
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(); }
protected override void OnPaintEvent(QPaintEvent e) { base.OnPaintEvent(e); // this is example from Qt site, http://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html var painter = new QPainter(this); painter.SetRenderHint(QPainter.RenderHint.Antialiasing); DrawPatternsEx(painter); painter.End(); }
void DrawLyrics(QPainter painter) { painter.Brush = new QColor(25, 25, 25); painter.Font = new QFont("Courier", 10); painter.DrawText(new QPoint(20, 30), "Most relationships seem so transitory"); painter.DrawText(new QPoint(20, 60), "They're good but not the permanent one"); painter.DrawText(new QPoint(20, 120), "Who doesn't long for someone to hold"); painter.DrawText(new QPoint(20, 150), "Who knows how to love without being told"); painter.DrawText(new QPoint(20, 180), "Somebody tell me why I'm on my own"); painter.DrawText(new QPoint(20, 210), "If there's a soulmate for everyone"); }
protected override void PaintEvent(QPaintEvent arg1) { QPainter painter = new QPainter(this); paintCannon(painter); if (autoShootTimer.Active) { paintShot(painter); } paintTarget(painter); painter.End(); }
public void TestPointerPassedAsItsSecondaryBase() { using (QApplication application = new QApplication()) { using (QWidget widget = new QWidget()) { using (QPainter painter = new QPainter(widget)) { Assert.That(widget.Test, Is.EqualTo(5)); } } } }
protected override void PaintEvent(QPaintEvent e) { QColor hourColor = new QColor(127, 0, 127); QColor minuteColor = new QColor(0,127,127,191); int side = QMin(Width(), Height()); QTime time = QTime.CurrentTime(); QPainter painter = new QPainter(this); painter.SetRenderHint(QPainter.RenderHint.Antialiasing); painter.Translate(Width() / 2, Height() / 2); painter.Scale(side / 200.0, side / 200.0); painter.SetPen(Qt.PenStyle.NoPen); painter.SetBrush(hourColor); painter.Save(); painter.Rotate(30.0 * ((time.Hour() + time.Minute() / 60.0))); painter.DrawConvexPolygon(new QPolygon(hourHand)); painter.Restore(); painter.SetPen(hourColor); for (int i = 0; i < 12; ++i) { painter.DrawLine(88, 0, 96, 0); painter.Rotate(30.0); } painter.SetPen(Qt.PenStyle.NoPen); painter.SetBrush(minuteColor); painter.Save(); painter.Rotate(6.0 * (time.Minute() + time.Second() / 60.0)); painter.DrawConvexPolygon(new QPolygon(minuteHand)); painter.Restore(); painter.SetPen(minuteColor); for (int j = 0; j < 60; ++j) { if ((j % 5) != 0) { painter.DrawLine(92, 0, 96, 0); } painter.Rotate(6.0); } painter.End(); }
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 }
void HandleAvatarUpdated(string jid, string hash) { if (jid == m_Account.Jid.Bare) { QApplication.Invoke(delegate { QPixmap pixmap = new QPixmap(36, 36); pixmap.Fill(GlobalColor.transparent); QPainter painter = new QPainter(pixmap); Gui.DrawAvatar(painter, m_AvatarLabel.Width(), m_AvatarLabel.Height(), (QPixmap)AvatarManager.GetAvatar(hash)); painter.Dispose(); m_AvatarLabel.Pixmap = pixmap; }); } }
void DrawDonut(QPainter painter) { var color = new QColor(); color.SetNamedColor("#333333"); painter.Pen = new QPen(color, 0.5); painter.SetRenderHint(QPainter.RenderHint.Antialiasing); painter.Translate(new QPoint(Width / 2, Height / 2)); for (double rot = 0; rot < 360.0; rot += 5.0) { painter.DrawEllipse(-125, -40, 250, 80); painter.Rotate(5.0); } }
protected override void PaintEvent(Qyoto.QPaintEvent arg1) { using (QPainter p = new QPainter(this)) { var rect = ContentsRect(); //var fm = new QFontMetrics(Font); //if (fm.Width(Text) > rect.Width()) { var gradient = new QLinearGradient(rect.TopLeft(), rect.TopRight()); gradient.SetColorAt(0.8, Palette.Color(QPalette.ColorRole.WindowText)); gradient.SetColorAt(1.0, new QColor(Qt.GlobalColor.transparent)); var pen = new QPen(); pen.SetBrush(new QBrush(gradient)); p.SetPen(pen); //} p.DrawText(rect, (int)Qt.TextFlag.TextSingleLine, Text); } }
protected override void PaintEvent(QPaintEvent arg1) { QPainter painter = new QPainter(this); if (gameEnded) { painter.SetPen(new QColor(Qt.GlobalColor.black)); painter.SetFont(new QFont("Courier", 48, (int)QFont.Weight.Bold)); painter.DrawText(Rect, (int)Qt.AlignmentFlag.AlignCenter, Tr("Game Over")); } paintCannon(painter); if (isShooting()) { paintShot(painter); } if (!gameEnded) { paintTarget(painter); } painter.End(); }
public static void DrawAvatar(QPainter painter, int width, int height, QPixmap avatarPixmap) { QPainterPath path = new QPainterPath(); // Draw a rect without corners. path.MoveTo(0, 1); path.LineTo(1, 1); path.LineTo(1, 0); path.LineTo(width - 1, 0); path.LineTo(width, 1); path.LineTo(width, height - 1); path.LineTo(width - 1, height - 1); path.LineTo(width - 1, height); path.LineTo(1, height); path.LineTo(1, height - 1); path.LineTo(0, height - 1); path.LineTo(0, 1); QLinearGradient g1 = new QLinearGradient(0, 0, 0, height); g1.SetColorAt(0, new QColor("#888781")); g1.SetColorAt(1, new QColor("#abaaa8")); QBrush b1 = new QBrush(g1); painter.FillPath(path, b1); painter.FillRect(1, 1, width - 2, height - 2, new QBrush(Qt.GlobalColor.black)); // Darken the corners... var b2 = new QBrush(new QColor(61, 61, 61, 102)); painter.FillRect(0, 0, 3, 3, b2); painter.FillRect(width - 3, 0, 3, 3, b2); painter.FillRect(0, width - 3, 3, 3, b2); painter.FillRect(width - 3, width - 3, 3, 3, b2); painter.DrawPixmap(2, 2, width - 4, height - 4, avatarPixmap); }
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 }
void DrawImages(QPainter painter) { painter.DrawImage(5, 15, colorImage); painter.DrawImage(5, colorImage.Height + 10, grayscaleImage); }
public bool Play(QPainter p) { return((bool)interceptor.Invoke("play#", "play(QPainter*)", typeof(bool), typeof(QPainter), p)); }
public override void Paint(QPainter painter, QStyleOptionViewItem option, QModelIndex index) { interceptor.Invoke("paint###", "paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const", typeof(void), typeof(QPainter), painter, typeof(QStyleOptionViewItem), option, typeof(QModelIndex), index); }
private void PaintBarrier(QPainter painter) { painter.SetPen(Qt.GlobalColor.black); painter.SetBrush(Qt.GlobalColor.yellow); painter.DrawRect(BarrierRect()); }