擅长:python、mysql、java
<p>使用PyQt,您可以轻松地设置这些属性,并且应用程序可以没有gui(例如,只创建一个图像并保存到文件中)。在</p>
<p>只需查看关于设置抗锯齿的<a href="http://doc.qt.nokia.com/latest/qpainter.html" rel="nofollow noreferrer">QPainter</a>文档(使用setrenderInts)和关于设置cap和join样式的<a href="http://doc.qt.nokia.com/latest/qpen.html" rel="nofollow noreferrer">QPen</a>类的文档。在</p>
<pre><code>from PyQt4.Qt import *
import math
app = QApplication([])
img = QImage(256, 256, QImage.Format_RGB32)
dc = QPainter(img)
dc.fillRect(0, 0, 256, 256, QColor(192, 192, 192))
dc.setRenderHints(QPainter.Antialiasing)
dc.setPen(QPen(QColor(128, 128, 192),
12.0,
Qt.SolidLine,
Qt.RoundCap,
Qt.RoundJoin))
pts = []
for i in xrange(7):
t = i * 2 * 3 * math.pi / 7
pts.append(QPointF(128 + 100 * math.cos(t),
128 + 100 * math.sin(t)))
dc.drawPolyline(QPolygonF(pts))
dc = None
img.save("output.png")
</code></pre>
<p><img src="https://i.stack.imgur.com/Pl2UP.png" alt="Output of the example program"/></p>