【问题标题】:wx python draw arc and circlewx python绘制圆弧和圆
【发布时间】:2016-11-15 18:27:15
【问题描述】:

我正在使用 wx python 来绘制仪表。我使用drawarc和drawCircle。 但结果并不如我所料。圆弧和圆没有精确绘制,看起来很丑。 GaugeImage

                pen = wx.Pen(wx.WHITE,2)
                dc.SetPen(pen)
                xFullCoordinate = (x + (OutsideRadius * math.cos((0.5 * math.pi) + (FullDeg * math.pi * newValue)/((MaxValue - MinValue) * 180))))
                yFullCoordinate = (y + (OutsideRadius * math.sin((0.5 * math.pi) + (FullDeg * math.pi * newValue)/((MaxValue - MinValue) * 180))))
                xStartCoodrinate = (x + (OutsideRadius * math.cos((0.5 * math.pi) + (StartDeg * math.pi) / 180)))
                yStartCoodrinate = (y + (OutsideRadius * math.sin((0.5 * math.pi) + (StartDeg * math.pi) / 180)))
                dc.DrawArc((xFullCoordinate,yFullCoordinate),(xStartCoodrinate,yStartCoodrinate),(x, y))
                dc.SetBrush(wx.Brush((48,100,175)))
                dc.DrawCircle(x, y, InsideRadius)

【问题讨论】:

    标签: wxpython automatic-ref-counting draw


    【解决方案1】:

    在您当前使用的 DC 上创建一个wx.GraphicsContext。请参阅in wxPython Phoenix docs 了解如何操作。在 GraphicsContext 上绘图会产生很好的抗锯齿图形。请注意,GraphicsContext 的绘图命令可能略有不同。

    【讨论】:

    • wx.GCDC 是将代码转换为使用图形上下文的好方法。它在wx.GraphicsContext 之上实现了wx.DC API。
    • @RobinDunn:我没有提到GCDC,因为我在 wxPython 经典版中使用它时遇到了麻烦(发现很难将 GCDC 放在现有 DC 之上),但很好!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-10
    • 1970-01-01
    • 1970-01-01
    • 2014-11-20
    • 1970-01-01
    • 2018-04-02
    • 1970-01-01
    相关资源
    最近更新 更多