Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Painting inside a transformed Canvas

$
0
0
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, Bernd PieSlice.qml: import QtQuick 2.0   Canvas {  antialiasing: true    property string color: "green"  property real angle: Math.PI/6.0    onAngleChanged: 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.0   Item {  width:600  height:600    PieSlice {   id: pieslice1   anchors.fill: parent   renderStrategy: Canvas.Immediate   color: "blue"   opacity: 0.5     NumberAnimation on rotation {    running: true    loops: Animation.Infinite    from: 0    to: 360    duration: 10000   }  }    PieSlice {   id: pieslice2   anchors.fill: parent   color: "yellow"   opacity: 0.5     NumberAnimation on rotation {    running: true    loops: Animation.Infinite    from: 0    to: 360    duration: 7000   }  } }

Viewing all articles
Browse latest Browse all 4972

Trending Articles