Painting inside a transformed Canvas
-
Hi,
I have trouble drawing inside a Canvas if the renderStrategy is not Canvas.Immediate after/during a fast resize of the window.
In the image https://www.dropbox.com/s/tmbht4g19sqa9kl/QtPieSlice.png only pieslice1(blue) is correctly rendered,
pieslice2(yellow) is not centred and sometime parts of the rendering are missing.Am I missing something using the Canvas?
Regards,
BerndPieSlice.qml:
@
import QtQuick 2.0Canvas {
antialiasing: trueproperty string color: "green"
property real angle: Math.PI/6.0onAngleChanged: requestPaint()
onPaint: {
var w = width
var h = height
var a = angle
var ctx = getContext('2d');
ctx.save();
ctx.clearRect(0, 0, w, h);
ctx.translate(w/2.0, h/2.0);
ctx.fillStyle = color;
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.arc(0, 0, Math.min(w, h)/2.0, -a/2.0, a/2.0, false);
ctx.closePath();
ctx.fill();
ctx.restore();
}
}@
main.qml:
@
import QtQuick 2.0Item {
width:600
height:600PieSlice {
id: pieslice1
anchors.fill: parent
renderStrategy: Canvas.Immediate
color: "blue"
opacity: 0.5NumberAnimation on rotation {
running: true
loops: Animation.Infinite
from: 0
to: 360
duration: 10000
}
}PieSlice {
id: pieslice2
anchors.fill: parent
color: "yellow"
opacity: 0.5NumberAnimation on rotation {
running: true
loops: Animation.Infinite
from: 0
to: 360
duration: 7000
}
}
}
@