2016-11-15 138 views
0

我正在使用wx python绘制标尺。我使用drawarc和drawCircle。 但结果并非如我所料。圆弧和圆不精确绘制,看起来很丑。 GaugeImagewx python绘制圆弧和圆

   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) 

回答

2

上当前正在使用的DC的顶端创建wx.GraphicsContext。请参阅in wxPython Phoenix docs以了解如何。在GraphicsContext上绘制将提供很好的抗锯齿图形。请注意,GraphicsContext的绘图命令可能略有不同。

+1

'wx.GCDC'是将代码转换为使用图形上下文的好方法。它在'wx.GraphicsContext'的顶部实现了'wx.DC' API。 – RobinDunn

+0

@RobinDunn:我没有提及''GCDC'',因为我在wxPython经典版中使用它时遇到了问题(发现很难将GCDC放在现有的DC之上),但是好点! – nepix32