QML:我可以舍入用 canvas 绘制的圆弧的起点和终点吗

QML: Can I rounded the start and end point of an arc painted with canvas

如何在 QML 中圆弧的终点和起点线 canvas?

Canvas
{
    id: canvas
    property real degree: 180
    anchors.fill: parent
    onPaint:
    {
        var ctx = getContext("2d")
        var x = 90
        var y = 90
        var radius = 85
        var startAngle = (Math.PI / 180) * 270
        var fullAngle = (Math.PI / 180) * (270 + 360)
        var progressAngle = (Math.PI / 180) * (270 + degree)
        ctx.lineWidth = 5
        ctx.beginPath()
        ctx.arc(x, y, radius, startAngle, progressAngle)
        ctx.strokeStyle = "red"
        ctx.stroke()
    }
}

Canvas 有 lineCap 属性:

ctx.lineCap = "round";

应该可以了。请注意,它是纯 js,与 QML 没有特别的关系,因此如果没有 c++ 和 qml 关键字,您可能会更幸运地搜索类似的东西。