1
我想創建動畫漸變箭頭。 我想創建一個箭頭的動畫背景。 我使用了下面的代碼,但它不顯示箭頭背景中的動畫漸變。創建動畫漸變箭頭
Canvas {
id: arrowDown
width: parent.height/3
height: width
antialiasing: true
...
property real centerWidth: width/2
property real centerHeight: height/2
property real radius: (Math.min(arrowDown.width, arrowDown.height)*2)/(2*Math.PI)
onPaint: {
var ctx = getContext("2d");
ctx.save();
ctx.clearRect(0, 0, arrowDown.width, arrowDown.height);
ctx.beginPath();
ctx.lineWidth = 8;
ctx.moveTo(arrowDown.centerWidth,arrowDown.centerHeight-arrowDown.radius/2);
ctx.strokeStyle = secondaryColor
ctx.lineTo(arrowDown.centerWidth,
arrowDown.centerHeight+arrowDown.radius/2);
ctx.lineTo(arrowDown.centerWidth+arrowDown.centerWidth/4,
arrowDown.centerHeight+arrowDown.radius/4);
ctx.moveTo(arrowDown.centerWidth,
arrowDown.centerHeight+arrowDown.radius/2);
ctx.lineTo(arrowDown.centerWidth-arrowDown.centerWidth/4,
arrowDown.centerHeight+arrowDown.radius/4);
var gradient = ctx.createLinearGradient(0, 0, 100, 100);
gradient.addColorStop(0.3, Qt.rgba(1, 0, 0, 1));
gradient.addColorStop(0.7, "white");
ctx.stroke();
ctx.restore();
}
Timer {
......
}
哪裏'arrowDown'從何而來?您需要提供一個最小的完整示例。 – Mitch