Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.2, 6.5.1
-
None
Description
The rotation angle draw lines. The lines drawn by qpainter default setting are uneven, but the lines drawn by qml canvas default setting are uniform.
Because qml canvas default capStyle is flat. Why does capStyle affect uniformity?
import QtQuick 2.15 Canvas { id: control property real mLineCount: 360 * 2 property real mRotation: 0 onPaint: { var r = Math.min(width, height) / 2 - 2 var ctx = getContext("2d") ctx.clearRect(0, 0, width, height) ctx.save() ctx.translate(width / 2, height / 2) ctx.strokeStyle = Qt.rgba(0.5, 0, 0, 1) ctx.lineWidth = 0.5 // + 1E-7 // Qml default flat, qpainter default square // If not flat, multiple rotate will be uneven ctx.lineCap = "square" for (var i = 0; i < mLineCount; i++) { // If not save/restore, multiple rotate will be uneven ctx.save() ctx.rotate((mRotation + 360.0 / mLineCount * i) * Math.PI / 180.0) ctx.beginPath() ctx.moveTo(0, 0) ctx.lineTo(r, 0) ctx.stroke() ctx.restore() } ctx.restore() } }